forked from ronaldgrn/docker-lua-resty-auto-ssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
49 lines (42 loc) · 1.5 KB
/
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
#!/bin/bash
if [[ -z "${DNS_DOMAIN}" ]]; then
echo "DNS_DOMAIN env is required"
exit 1
fi
if [[ -z "${PROXY_PASS}" ]]; then
echo "PROXY_PASS env is required"
exit 1
fi
if [[ -z "${STORAGE_ADAPTER}" ]]; then
# Should be one of 'file' or 'redis'
echo "STORAGE_ADAPTER env not provided. Falling back to file storage."
STORAGE_ADAPTER="file"
fi
if [[ -z "${RESOLVER}" ]]; then
# Should be one of 'file' or 'redis'
echo "RESOLVER env not provided. Defaulting to 8.8.8.8."
RESOLVER="8.8.8.8"
fi
if [ "${STORAGE_ADAPTER}" == "redis" ]; then
if [[ -z "${REDIS_HOST}" ]]; then
echo "REDIS_HOST env is required if using redis storage adapter."
exit 1
fi
if [[ -z "${REDIS_PORT}" ]]; then
echo "Warn: Using default REDIS_PORT [6379]"
REDIS_PORT="6379"
fi
else
# We need values anyways for the syntax to be valid
REDIS_HOST="127.0.0.1"
REDIS_PORT="6379"
fi
# replace with parameter expansion for slashes
sed -i -e "s/{{ DNS_DOMAIN }}/${DNS_DOMAIN//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ PROXY_PASS }}/${PROXY_PASS//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ STORAGE_ADAPTER }}/${STORAGE_ADAPTER}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ RESOLVER }}/${RESOLVER}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ REDIS_HOST }}/${REDIS_HOST//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ REDIS_PORT }}/${REDIS_PORT}/g" /usr/local/openresty/nginx/conf/nginx.conf
echo "SETUP OK"
exit 0