forked from Tommos0/docker-term-letsencrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcertbot.sh
35 lines (29 loc) · 788 Bytes
/
certbot.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
#!/bin/sh
source /etc/envvars
while ! nc -z -w1 localhost 80 ; do
sleep 1
done
DIR_NAME=`ls /etc/letsencrypt/live | head -n 1`
install_cert()
{
DIR_NAME=`ls /etc/letsencrypt/live | grep -v README | head -n 1`
cp -L /etc/letsencrypt/live/${DIR_NAME}/*.pem /cert
sv hup nginx
}
if [ -z "$DIR_NAME" ]; then
# There is no existing certbot configuration
DOMAIN_PARAMS="-d $(echo $SSL_DOMAINS | sed 's/,/ -d /g')"
( set -x; certbot certonly --webroot -w /acme -n --agree-tos --email ${SSL_ADMIN_EMAIL} ${DOMAIN_PARAMS} --expand )
if [ $? -ne 0 ]; then
echo "WARNING: Certbot failed to create certificate"
else
install_cert
fi
else
( set -x; certbot renew )
if [ $? -ne 0 ]; then
echo "WARNING: Certbot failed to renew certificate"
else
install_cert
fi
fi