ungleich-certbot/entrypoint.sh

40 lines
1.1 KiB
Bash
Raw Normal View History

2021-06-19 14:41:43 +00:00
#!/bin/sh
if [ -z "$DOMAIN" -o -z "$EMAIL" ]; then
echo Missing DOMAIN or EMAIL parameter - aborting. >&2
exit 1
fi
if [ "$STAGING" = no ]; then
STAGING=""
else
STAGING="--staging"
fi
2021-07-17 15:17:56 +00:00
# Try to get a certificate, accept failures
2021-07-17 15:20:20 +00:00
while [ ! -f "/etc/letsencrypt/live/${DOMAIN}/fullchain.pem" ]; do
2021-07-17 15:17:56 +00:00
certbot certonly --agree-tos --cert-name "${DOMAIN}" \
--email "$EMAIL" --expand --non-interactive \
--domain "$DOMAIN" --standalone $STAGING
2021-07-17 15:20:20 +00:00
sleep 30
2021-07-17 15:17:56 +00:00
# Correct permissions for multi user container/pod deployments
# if not indicated otherwise
if [ -z "$LEAVE_PERMISSIONS_AS_IS" ]; then
find /etc/letsencrypt -type d -exec chmod 0755 {} \;
find /etc/letsencrypt -type f -exec chmod 0644 {} \;
fi
done
# Try to renew once per day
while true; do
/usr/bin/certbot renew
2021-07-17 15:20:20 +00:00
# And again, correct permissions if not told otherwise
if [ -z "$LEAVE_PERMISSIONS_AS_IS" ]; then
find /etc/letsencrypt -type d -exec chmod 0755 {} \;
find /etc/letsencrypt -type f -exec chmod 0644 {} \;
fi
2021-07-17 15:17:56 +00:00
sleep 86400
done