Last active
August 2, 2016 10:03
-
-
Save padde/ba57f4435bd77329ce08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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