Skip to content

Instantly share code, notes, and snippets.

@hoducha
Created December 4, 2016 08:22
Show Gist options
  • Save hoducha/ee6bf9ad22a41b4743aff0a55437dbcd to your computer and use it in GitHub Desktop.
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
#!/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
@GAZ082
Copy link

GAZ082 commented Mar 27, 2018

Thanks bud!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment