-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-workspace.sh
executable file
·30 lines (22 loc) · 1.24 KB
/
create-workspace.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
USERNAME="familyguy"
PASSWORD="web19"
SERVER_IP="127.0.1.42"
REPO="https://github.com/ionalexandru99/WebTech"
cd /var/www/workspaces
cp -R /var/www/workspaces/template /var/www/workspaces/$USERNAME
chown -R 1000:1000 /var/www/workspaces/$USERNAME/project
sed -i -e "s/{username}/$USERNAME/g" /var/www/workspaces/$USERNAME/project/README.md
git clone $REPO /var/www/workspaces/$USERNAME/project/app
chown -R 1000:1000 /var/www/workspaces/$USERNAME/project/app
cd /var/www/workspaces/$USERNAME
sed -i -e "s/{server_ip}/$SERVER_IP/g" /var/www/workspaces/$USERNAME/docker-compose.yml
docker-compose up -d
sudo htpasswd -b -c /etc/apache2/.htpasswd-$USERNAME $USERNAME $PASSWORD
cp /etc/nginx/sites-available/template-ide /etc/nginx/sites-available/$USERNAME-ide
sed -i -e "s/{username}/$USERNAME/g" -e "s/{server_ip}/$SERVER_IP/g" /etc/nginx/sites-available/$USERNAME-ide
ln -s /etc/nginx/sites-available/$USERNAME-ide /etc/nginx/sites-enabled/$USERNAME-ide
cp /etc/nginx/sites-available/template-app /etc/nginx/sites-available/$USERNAME-app
sed -i -e "s/{username}/$USERNAME/g" -e "s/{server_ip}/$SERVER_IP/g" /etc/nginx/sites-available/$USERNAME-app
ln -s /etc/nginx/sites-available/$USERNAME-app /etc/nginx/sites-enabled/$USERNAME-app
nginx -s reload