-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·47 lines (39 loc) · 1.18 KB
/
entrypoint.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
#!/bin/bash
# Check requirements
if [ "$LETSENCRYPT_EMAIL" == "none" ]; then echo "Please fill environment variable LETSENCRYPT_EMAIL"; exit; fi
# Wait for set period
echo "### Waiting for ${STARTUP_WAIT} seconds... "
sleep ${STARTUP_WAIT}
echo "Done"
# Renew existing and expiring certificates if existing
if [ -d "/etc/letsencrypt/live" ]; then
echo "### Renew existing and expiring certificates"
letsencrypt renew --rsa-key-size $RSA_KEY_SIZE
fi
# Generating each certificate
i=1
var=CERT1
echo "### Generating certificates..."
while [ "${!var}" ]
do
# Get differents subdomains
SUBDOMAINS=$(echo ${!var} | tr ";" "\n")
SUBDOMAINS_ARGS=" "
for subdomain in $SUBDOMAINS
do
SUBDOMAINS_ARGS+="-d $subdomain "
done
echo "SUBDOMAINS_ARGS: $SUBDOMAINS_ARGS"
# Generate certificates
echo "Generate ${!var} certificate"
letsencrypt certonly --text --non-interactive --rsa-key-size $RSA_KEY_SIZE \
--email $LETSENCRYPT_EMAIL --agree-tos --standalone --expand \
$SUBDOMAINS_ARGS -vvvvv --text
# Passing to the next certificate
i=$((i+1))
var="CERT$i"
done
# Launch reverse-proxy
nginx
# Nginx log
tail -f /var/log/nginx/error.log