-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-setup.sh
executable file
·54 lines (46 loc) · 1.5 KB
/
docker-setup.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
#!/bin/bash
# If following error is sent: /bin/bash^M - use `sed -i -e 's/\r$//' docker-setup.sh`
# import all env variables
set -o allexport
source .env
set +o allexport
# Handle flags when program is called
while getopts "dr" flag
do
case "${flag}" in
d) web_dir=${OPTARG};;
r) reverse_proxy=${OPTARG};;
*)
esac
done
# Check docker is running and can be accessed
if docker > /dev/null 2>&1 ; then
:
else
echo -e "${YELLOW}Docker is not running.${NC}";
exit 1;
fi
# Prepare and run directory set up
chmod u+x ./scripts/web-dir.sh && sed -i -e 's/\r$//' ./scripts/web-dir.sh
if ./scripts/web-dir.sh -d "${web_dir}" ; then
# echo -e "${GREEN}Directory correctly set up.${NC}";
:
else
echo -e "${RED}Failed directory creation.${NC}";
exit;
fi
echo "---------------------------------------------------------"
# Prepare and run reverse proxy setup
if [ "$reverse_proxy" == "nginx-proxy" ] ; then
chmod u+x ./scripts/nginx-reverse-proxy.sh && sed -i -e 's/\r$//' ./scripts/nginx-reverse-proxy.sh
if ./scripts/nginx-reverse-proxy.sh -d "${web_dir}" ; then
# echo -e "${GREEN}NGINX reverse proxy set up.${NC}";
:
else
echo -e "${RED}Failed NGINX reverse proxy set up.${NC}";
exit;
fi
echo "---------------------------------------------------------"
fi
# Run main part of code, to setup containers
chmod u+x ./scripts/container-setup.sh && sed -i -e 's/\r$//' ./scripts/container-setup.sh && ./scripts/container-setup.sh