Created
July 11, 2016 11:45
-
-
Save wuftymerguftyguff/fb0162f5740a5d25b3d63a1de1872547 to your computer and use it in GitHub Desktop.
renew lets encrypt certs automatically when olde than 60 days for nginx
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 | |
# create new certs | |
cd /opt/letsencrypt | |
RESTART=false | |
for conf in $(ls -1 /etc/letsencrypt/live/); do | |
UPDATE=false | |
for file in $(find -L /etc/letsencrypt/live/$conf -type f -not -newermt '-60 days' );do | |
UPDATE=true | |
done | |
if [ "$UPDATE" = true ] | |
then | |
RESTART=true | |
./letsencrypt-auto --force-renewal --config "/etc/letsencrypt/configs/${conf}.conf" certonly | |
fi | |
done | |
# make sure nginx picks them up if its config is valid | |
if [ "$RESTART" = true ] | |
then | |
nginx -t && sudo nginx -s reload | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment