Created
December 4, 2016 08:22
-
-
Save hoducha/ee6bf9ad22a41b4743aff0a55437dbcd to your computer and use it in GitHub Desktop.
This script run letsencrypt renew and reload Nginx if there is any certificates renewed
This file contains 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
#!/bin/sh | |
# This script renews all the Let's Encrypt certificates with a validity < 30 days | |
RENEW_LOG=/var/log/letsencrypt/renew.log | |
if ! letsencrypt renew > $RENEW_LOG 2>&1 ; then | |
echo Automated renewal failed: | |
cat $RENEW_LOG | |
exit 1 | |
fi | |
cat $RENEW_LOG | |
# Restart nginx if there is any renewal attempted | |
if ! grep -Fq "No renewals were attempted" $RENEW_LOG ; then | |
/usr/sbin/nginx -t && /usr/sbin/nginx -s reload | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks bud!