Skip to content

Instantly share code, notes, and snippets.

@Ttech
Created December 12, 2015 06:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Ttech/38b4ab7b1811a7b25597 to your computer and use it in GitHub Desktop.
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
#!/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