Last active
February 10, 2020 03:05
-
-
Save jfurcean/0f0b16e81bc9926023a0c98392aa79fa to your computer and use it in GitHub Desktop.
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/bash | |
# | |
# Based off ScottHelme's Lets Encrypt Smart Renew | |
# https://github.com/ScottHelme/Lets-Encrypt-Smart-Renew | |
# | |
# Repalce DOMAIN with the domain of the certificate you are renewing | |
# | |
# crontab | |
# 0 * * * * /path/to/smartRenew.sh | |
# The remaining life on our certificate below which we should renew (7 days). | |
RENEW=21 | |
# Set date for backup | |
TODAY=`date '+%Y_%m_%d'` | |
# If the certificate has less life remaining than we want. | |
if ! openssl x509 -checkend $[ 86400 * $RENEW ] -noout -in /etc/lego/certificates/DOMAIN.crt | |
then | |
# Then make backup copy of existing cert before starting renew | |
cp /etc/lego/certificates/DOMAIN.crt /etc/lego/certificates/DOMAIN_$TODAY.crt | |
# Then call the renewal script. | |
/etc/lego/renew-certificate.sh | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment