Created
December 12, 2015 06:41
-
-
Save Ttech/38b4ab7b1811a7b25597 to your computer and use it in GitHub Desktop.
The first revision of my Automated LetsEncrypt updater for ZNC and Friends using the letsencrypt tool
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 | |
domain_list="domains.txt" | |
# format is: | |
# domain1.abc.com,abc.com | |
# domain2.xyz.com,test.xyz.com,xyz.com | |
LEBIN="letsencrypt" | |
LE="$LEBIN --text certonly --agree-tos --renew-by-default --standalone --standalone-supported-challenges tls-sni-01 " | |
## Web Server Update | |
# shutdown server | |
monit stop nginx | |
sleep 120 | |
# update domains | |
cert_domains=$(cat $domain_list|grep -v \#) | |
for raw_domains in $cert_domains | |
do | |
domains=$(echo $raw_domains | sed -e "s/, / -d /g" -e "s/,/ -d /g") | |
echo $LE -d $domains | |
sleep 1 | |
done | |
# start server (hopefully things worked) | |
monit start nginx | |
## technically, reload should do it though... | |
## ZNC Update | |
# update to fit needs | |
ZNCSERV="test.abc.com" | |
ZNCDEST="/etc/znc" | |
cat /etc/letsencrypt/live/$ZNCSERV/privkey.pem /etc/letsencrypt/live/$ZNCSERV/fullchain.pem > $ZNCDEST/znc.pem | |
kill -HUP `pidof znc` | |
## Hope everything worked... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment