cert renewal script functional
This commit is contained in:
parent
8eb0f01e14
commit
bb76e223fd
1 changed files with 18 additions and 8 deletions
|
@ -1,16 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Initial check for certificates
|
||||
#TODO check if `certbot certonly` can automatically skip renewal (eliminated need for document here operator)
|
||||
certbot certonly --manual --preferred-challenges dns --manual-auth-hook /scripts/auth \
|
||||
--manual-cleanup-hook /scripts/cleanup -m "${LETSENCRYPT_EMAIL}" --no-eff-email \
|
||||
-d "${LETSENCRYPT_DOMAIN}" --agree-tos --manual-public-ip-logging-ok << EOF
|
||||
certbot certonly --manual --preferred-challenges dns --manual-auth-hook \
|
||||
/scripts/auth.sh --manual-cleanup-hook /scripts/cleanup.sh \
|
||||
-m "${LETSENCRYPT_EMAIL}" --no-eff-email -d "${DUCKDNS_DOMAIN}" \
|
||||
--agree-tos --manual-public-ip-logging-ok << EOF
|
||||
1
|
||||
EOF
|
||||
|
||||
# Loop generation at a random time every 12 hours
|
||||
# Basic check for successful certificate generation
|
||||
if [ ! -d "/etc/letsencrypt/live" ]; then
|
||||
echo ERROR: Failed to create SSL certificates
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if certificates require renewal twice a day
|
||||
while :; do
|
||||
# Generate random delay within 12 hours of seconds
|
||||
# sleep the required time
|
||||
# Run renew command
|
||||
# Wait for a random period within the next 12 hours
|
||||
LETSENCRYPT_DELAY=$(shuf -i 1-720 -n 1)
|
||||
echo Sleeping for $(($LETSENCRYPT_DELAY / 60)) hour\(s\) and $(($LETSENCRYPT_DELAY % 60)) minute\(s\)
|
||||
sleep $((${LETSENCRYPT_DELAY} * 60))
|
||||
|
||||
echo Attempting SSL certificate renewal
|
||||
certbot --manual-public-ip-logging-ok renew
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue