Last active
September 24, 2016 21:26
-
-
Save ShonFrazier/b6e8154a48c909bc11d2f620127dd438 to your computer and use it in GitHub Desktop.
Renew a Let's Encrypt cert within a week of expiration. Run weekly. Or Daily.
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/fish | |
# Get dates in seconds since epoch | |
set -x EXPIRES (date --date=(cat /etc/letsencrypt/live/api.fyrestead.com/cert.pem | openssl x509 -noout -enddate | awk -F "=" '{print $2}') +%s) | |
set -x TODAY (date +%s) | |
set -x SPAN (expr $EXPIRES - $TODAY) | |
# if the span is <= seven days ... | |
if test $SPAN -le 604800 | |
# renew the cert | |
certbot renew --quiet | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment