-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
48 lines (38 loc) · 1.11 KB
/
run.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
#!/bin/bash
# generate pass based on env vars
htpasswd -b -c /etc/nginx/.htpasswd "${HTPASSWD_USER}" "${HTPASSWD_PASS}"
# determine hostname at runtime, maybe according
# to host specific bahaviour
/determine_hostname.sh
# prepare test cert command
if [ "${ENV}" = "debug" ]; then
TEST="--test-cert"
fi
# run cert getter. the TEST env should be
# cleared for a working cert
/root/letsencrypt/letsencrypt-auto \
certonly \
${TEST} \
--agree-tos \
--standalone \
--non-interactive \
--redirect \
--text \
--email ${EMAIL} \
-d ${DOMAIN}
# show generated certs
ls -l "/etc/letsencrypt/live/${DOMAIN}"
# in production, install certs in nginx
if [ "${ENV}" = "production" ]; then
# TODO: check if generation worked
# install certs in nginx
mkdir -p /etc/nginx/ssl/ && \
rm -rf /etc/nginx/ssl/docker-registry.{crt,key} && \
ln -s "/etc/letsencrypt/live/${DOMAIN}/fullchain.pem" "/etc/nginx/ssl/docker-registry.crt" && \
ln -s "/etc/letsencrypt/live/${DOMAIN}/privkey.pem" "/etc/nginx/ssl/docker-registry.key" && \
# start nginx
nginx -g "daemon off;"
# allow SSH debugging
else
sleep infinity
fi