Skip to content

Instantly share code, notes, and snippets.

Last active August 2, 2016 10:03
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
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
if ! [ $RESULT -eq 0 ] ; then
echo Automated renewal failed:
cat /var/log/letsencrypt/renew.log
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment