Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austriancoder/911ca10c26dd24ac6b585ad4a62242a6 to your computer and use it in GitHub Desktop.
Save austriancoder/911ca10c26dd24ac6b585ad4a62242a6 to your computer and use it in GitHub Desktop.
Let’s Encrypt
#!/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