Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env sh
# Automatically renew all installed letsencrypt certificates on this server
service nginx stop
/root/letsencrypt/letsencrypt-auto renew -nvv --standalone > /var/log/letsencrypt/renew.log 2>&1
RESULT=$?
service nginx start
# optional: notify yourself of succeeded/failed renewals
if ! grep -q "No renewals were attempted" /var/log/letsencrypt/renew.log; then
SUBJECT="Certificate Renewal $(if [ $RESULT -eq 0 ]; then echo SUCCEEDED; else echo FAILED; fi)"
TEXT=$(cat /var/log/letsencrypt/renew.log)
# send your notification, e.g. via email
fi
if ! [ $RESULT -eq 0 ] ; then
echo Automated renewal failed:
cat /var/log/letsencrypt/renew.log
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment