-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·47 lines (42 loc) · 1.14 KB
/
entrypoint.sh
File metadata and controls
executable file
·47 lines (42 loc) · 1.14 KB
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/sh
set -e
exec_certbot(){
if [ -z "${EMAIL_ADDRESS}" ]; then
echo "Please set EMAIL_ADDRESS env variable to register ACME account"
exit 1
fi
if [ -z "${DOMAIN_NAME}" ]; then
echo "Please set DOMAIN_NAME for which to obtain certificates"
exit 1
fi
# build array of domains to get certificates for
set -- "-d" "${DOMAIN_NAME}"
if [ -n "${SUBDOMAINS}" ]; then
IFS=','
for subdomain in ${SUBDOMAINS}; do
set -- "$@" "-d" "${subdomain}.${DOMAIN_NAME}"
done
fi
certbot certonly \
--agree-tos \
--non-interactive \
-m "${EMAIL_ADDRESS}" \
--dns-cloudflare \
--dns-cloudflare-credentials "${CLOUDFLARE_CONFIG_LOCATION:-/config/cloudflare.ini}" \
--dns-cloudflare-propagation-seconds "${CLOUDFLARE_PROPAGATE_SECONDS:-60}" \
"$@"
# Setup a cron schedule
echo "SHELL=/bin/sh
0 0 * * 0 /run-certbot.sh >> /var/log/cron.log 2>&1
" > scheduler.txt
crontab scheduler.txt
crond -f
}
if [ -n "$1" ]; then
# If the entrypoint receives any command - execute it directly.
# Useful if someone wants to start a shell in the container
exec "$@"
else
# Default
exec_certbot
fi