Created
May 1, 2016 21:37
-
-
Save austriancoder/911ca10c26dd24ac6b585ad4a62242a6 to your computer and use it in GitHub Desktop.
Let’s Encrypt
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 | |
valid_days=5 | |
cert_dir='/home/cgmeiner/.config/letsencrypt/live' | |
cert_file='cert.pem' | |
domains='www.christian-gmeiner.info' | |
export PATH=/usr/local/bin/:$PATH | |
for domain in $domains; do | |
# find all certificates | |
export cert="$(find $cert_dir/$domain/ -iname $cert_file | sort -k1)" | |
# check certificate validation date | |
openssl x509 -checkend $(( $valid_days * 86400 )) -in "$cert" > /dev/null | |
# renew certifiacates if they are only 5 more days valid | |
if [ $? != 0 ]; then | |
letsencrypt certonly | |
uberspace-prepare-certificate -k $cert_dir/$domain/privkey.pem -c $cert_dir/$domain/$cert_file | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment