Skip to content

Instantly share code, notes, and snippets.

@padde
Last active August 2, 2016 10:03
Show Gist options
  • Save padde/ba57f4435bd77329ce08 to your computer and use it in GitHub Desktop.
Save padde/ba57f4435bd77329ce08 to your computer and use it in GitHub Desktop.
#!/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