-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinit.sh
executable file
·39 lines (34 loc) · 1.38 KB
/
init.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
#!/bin/bash
ENV_FILE=${1:-.env}
set -o allexport
source $ENV_FILE
set +o allexport
if ! [ -x "$(command -v docker-compose)" ] || ! [ "$(command -v docker)" ] ; then
echo 'Error: Docker or docker-compose is not yet installed'
if grep -iq "amzn" /etc/os-release ; then
echo "Installing Docker and docker-compose on AWS EC2"
sudo chmod +x docker-aws-linux-install.sh && ./docker-aws-linux-install.sh
elif grep -iq "centos" /etc/os-release ; then
echo "Installing Docker and docker-compose on RHEL or Centos"
sudo chmod +x docker-centos-install.sh && ./docker-centos-install.sh
else
echo "Installing Docker and docker-compose on Ubuntu"
sudo chmod +x docker-ubuntu-install.sh && ./docker-ubuntu-install.sh
fi
fi
### Check for mysql and ghost home dir, if not found create it using the mkdir ##
[ ! -d "$MYSQL_DATA" ] && mkdir -p "$MYSQL_DATA"
[ ! -d "$GHOST_DATA" ] && mkdir -p "$GHOST_DATA"
### Check for Nginx Certificates ##
if ls ${CERT_PATH}/$CERT_CRT &>/dev/null && ls ${CERT_PATH}/$CERT_KEY &>/dev/null
then
sed -i "s/replaceme.crt/$CERT_CRT/g" $PWD/$NGINX_CONFIG_PATH/*.conf
sed -i "s/replaceme.key/$CERT_KEY/g" $PWD/$NGINX_CONFIG_PATH/*.conf
sed -i "s/SERVERNAME/$SERVER_NAME/g" $PWD/$NGINX_CONFIG_PATH/*.conf
echo "Creating Containers"
docker-compose up --force-recreate -d
exit 0
else
echo 'Error: Missing Nginx certificates'
exit 1
fi