Last active
June 14, 2016 02:56
-
-
Save dlage/3048033c33b6fd9668e0 to your computer and use it in GitHub Desktop.
Auto-renew SSL script for a user & domain (Webmin or another control panel)
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 | |
# Auto-renew SSL script for a user & domain | |
# Can be used in Webmin for example | |
# Webmin has better integration but I believe it requires newer versions of python for now | |
DOMAINUSER="$1" | |
DOMAIN="$2" | |
if [ "$#" -ne "2" ]; then | |
echo "Bad usage: $0 <domain_user> <domain>\n" | |
exit 2; | |
fi | |
if [ !-d "/home/$DOMAINUSER/ssl_certificates/" ]; then | |
sudo -u $DOMAINUSER -H bash -c "mkdir -p /home/$DOMAINUSER/ssl_certificates/" | |
fi | |
cd /root/letsencrypt/ | |
./letsencrypt-auto certonly --debug --email admin@$DOMAIN --agree-tos --webroot --renew-by-default -w /home/$DOMAINUSER/public_html/ -d $DOMAIN -d www.$DOMAIN --authenticator webroot | |
cp -vf /etc/letsencrypt/live/$DOMAIN/cert.pem /home/$DOMAINUSER/ssl_certificates/${DOMAIN}_cert.pem | |
cp -vf /etc/letsencrypt/live/$DOMAIN/chain.pem /home/$DOMAINUSER/ssl_certificates/${DOMAIN}_chain.pem | |
cp -vf /etc/letsencrypt/live/$DOMAIN/fullchain.pem /home/$DOMAINUSER/ssl_certificates/${DOMAIN}_fullchain.pem | |
cp -vf /etc/letsencrypt/live/$DOMAIN/privkey.pem /home/$DOMAINUSER/ssl_certificates/${DOMAIN}_privkey.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment