Created
December 27, 2015 14:39
-
-
Save eniac111/c7146b3e59c7eff27fbe 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
#!/bin/bash | |
######################################################################## | |
## Script for updating Let's encrypt certs | |
## http://petrovs.info/2015/12/27/My-way-to-auto-update-Lets-Encrypt/ | |
## (C) 2015 Blagovest Petrov (blagovest <at> petrovs dot info) | |
## Released under the GPL | |
######################################################################## | |
cd /etc/letsencrypt/live | |
for DIRS in *; do | |
if ssl-cert-check -c $DIRS/fullchain.pem | grep -q "Valid"; then | |
echo On `date`, $DIRS is Valid. >> /var/log/letsencrypt-update.log | |
#cat $DIRS/fullchain.pem > /srv/certs/$DIRS.pem | |
#cat $DIRS/privkey.pem >> /srv/certs/$DIRS.pem | |
else | |
echo On `date`, $DIRS is NOT Valid. Generating a new certificate from Let\'s encrypt... >> /var/log/letsencrypt-update.log | |
/root/letsencrypt/letsencrypt-auto --email [email protected] -d $DIRS --authenticator standalone --tls-sni-01-port 63443 --renew-by-default --text auth --http-01-port 8099 >> /var/log/letsencrypt-update.log | |
echo Generating fullchain token for $DIRS to be used for HAProxy... >> /var/log/letsencrypt-update.log | |
cat $DIRS/fullchain.pem > /srv/certs/$DIRS.pem | |
cat $DIRS/privkey.pem >> /srv/certs/$DIRS.pem | |
echo Reloading the HAProxy configuration... >> /var/log/letsencrypt-update.log | |
service haproxy reload | |
echo Done :\) >> /var/log/letsencrypt-update.log | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment