-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-up.sh
executable file
·70 lines (63 loc) · 2.01 KB
/
set-up.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
if [ ! $1 ] || [ $1 == "help" ]
then
echo "help - This menu"
echo "build - Build TTRPG Tools"
echo "restart - Restart all containers"
echo "ssl - Runs certbot script"
exit 1
fi
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
*) machine="UNKNOWN:${unameOut}"
esac
if [ $machine == "Linux" ]
then
sudo sysctl vm.max_map_count=262144 > /dev/null 2>&1
fi
source .env
if [ $1 == "build" ]
then
echo -e "[ \e[33mBuilding Docker\e[0m ]"
sudo docker-compose up -d --build --remove-orphans || exit 1
echo -e "[ \e[32mDocker Built\e[0m ]"
fi
if [ $1 == "restart" ]
then
sudo docker-compose restart
fi
HTTP="http://";
if [ $SSL == "ssl" ] && [ ! -f .certbot.lock ] || [ $1 == "ssl" ]
then
echo -e "[ \e[33mGenerating Certs\e[0m ]"
network_name=`sudo docker network ls --format "{{.Name}}" | grep web-network`
echo -en "[ \e[33mWaiting for nginx to come up\e[0m ]"
while [ "`sudo docker inspect -f {{.State.Running}} nginx 2> /dev/null`" != "true" ]
do
echo -en "."
sleep 3
done
echo -e "[ \e[32mNginx Up\e[0m ]"
nginx_ip=`sudo docker inspect -f '{{ $network := index .NetworkSettings.Networks "'$network_name'" }}{{ $network.IPAddress}}' nginx 2> /dev/null`
echo -en "[ \e[33mWaiting for nginx to have an IP\e[0m ]"
while [ -z "$nginx_ip" ]
do
echo -en "."
sleep 3
nginx_ip=`sudo docker inspect -f '{{ $network := index .NetworkSettings.Networks "'$network_name'" }}{{ $network.IPAddress}}' nginx 2> /dev/null`
done
echo -e "[ \e[32mNginx IP Found\e[0m ]"
sudo docker exec nginx bash /var/www/certbot.sh && touch .certbot.lock
sudo docker-compose restart nginx
echo -e "[ \e[32mGenerated Certs\e[0m ]"
HTTP="https://";
fi
echo ""
echo -e "[ \e[35mAll ready to use\e[0m ]"
echo "Improved Initiative : "$HTTP""$II_HOST"."$DOMAIN;
echo "Dungeon Revealer : "$HTTP""$DR_HOST"."$DOMAIN"/map";
echo "Paragon : "$HTTP""$PA_HOST"."$DOMAIN;
echo "File Serve : "$HTTP"www."$DOMAIN;
echo ""