Created
December 7, 2015 19:08
-
-
Save ipha/3befe443599581b1bbf0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
domains=(domain1 domain2) | |
for domain in "${domains[@]}"; do | |
if openssl x509 -checkend 1209600 -noout -in ~/keys/"$domain".crt 2> /dev/null; then | |
echo "$domain renew not needed" | |
else | |
echo "$domain expires in less than 2 weeks, renewing" | |
python2 ~/acme-tiny/acme_tiny.py \ | |
--account-key ~/keys/user.key \ | |
--csr ~/keys/"$domain".csr \ | |
--acme-dir /var/www/html/.well-known/acme-challenge/ > ~/keys/"$domain"-new.crt | |
if openssl x509 -checkend 1209600 -noout -in ~/keys/"$domain"-new.crt 2> /dev/null; then | |
mv ~/keys/"$domain".crt ~/keys/"$domain"-old.crt | |
mv ~/keys/"$domain"-new.crt ~/keys/"$domain".crt | |
cat ~/keys/"$domain".key ~/keys/"$domain".crt > /etc/lighttpd/"$domain".pem | |
sudo systemctl restart lighttpd | |
echo "$domain successfully renewed" | |
else | |
echo "$domain renew failed" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment