Skip to content

Instantly share code, notes, and snippets.

@ShonFrazier
Last active September 24, 2016 21:26
Show Gist options
  • Save ShonFrazier/b6e8154a48c909bc11d2f620127dd438 to your computer and use it in GitHub Desktop.
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.
#!/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