forked from evertramos/nginx-proxy-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·68 lines (53 loc) · 1.9 KB
/
start.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
#!/bin/bash
#
# This file should be used to prepare and run your WebProxy after set up your .env file
# Source: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion
#
# 1. Check if .env file exists
if [ -e .env ]; then
source .env
else
echo "Please set up your .env file before starting your environment."
exit 1
fi
# 2. Create docker network
docker network create $NETWORK $NETWORK_OPTIONS
# 3. Verify if second network is configured
if [ ! -z ${SERVICE_NETWORK+X} ]; then
docker network create $SERVICE_NETWORK $SERVICE_NETWORK_OPTIONS
fi
# 4. Download the latest version of nginx.tmpl
curl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl > nginx.tmpl
# 5. Update local images
docker-compose pull
# 6. Add any special configuration if it's set in .env file
# Check if user set to use Special Conf Files
if [ ! -z ${USE_NGINX_CONF_FILES+X} ] && [ "$USE_NGINX_CONF_FILES" = true ]; then
# Create the conf folder if it does not exists
mkdir -p $NGINX_FILES_PATH/conf.d
# Copy the special configurations to the nginx conf folder
cp -R ./conf.d/* $NGINX_FILES_PATH/conf.d
# Check if there was an error and try with sudo
if [ $? -ne 0 ]; then
sudo cp -R ./conf.d/* $NGINX_FILES_PATH/conf.d
fi
# If there was any errors inform the user
if [ $? -ne 0 ]; then
echo
echo "#######################################################"
echo
echo "There was an error trying to copy the nginx conf files."
echo "The webproxy will still work, your custom configuration"
echo "will not be loaded."
echo
echo "#######################################################"
fi
fi
# 7. Start proxy
# Check if you have multiple network
if [ -z ${SERVICE_NETWORK+X} ]; then
docker-compose up -d
else
docker-compose -f docker-compose-multiple-networks.yml up -d
fi
exit 0