Skip to content

Instantly share code, notes, and snippets.

@bviktor

bviktor/le-renew.sh

Last active Jan 25, 2016
Embed
What would you like to do?
Let's Encrypt renew script
#!/bin/sh
# make sure the script can find the domain list even when invoked from a different dir
DIR=$(dirname $0)
# store your domain renewal commands here, one line per certificate, e.g.:
# -d foo.bar -d www.foo.bar
# -d foo2.foo.bar
DOMLIST="${DIR}/le-domains.txt"
# don't break at spaces
IFS=$'\n'
# make sure it works even in cron with different $PATH
LECMD='/bin/letsencrypt certonly'
# make sure port 80 is available
eval "/bin/systemctl stop nginx.service"
# don't parse lines starting with #
for DOM in $(grep -v ^# ${DOMLIST})
do
eval "${LECMD} ${DOM}"
# if failed, try until succeeds
while [ $? -ne 0 ]
do
# don't spam too much
sleep 10
eval "${LECMD} ${DOM}"
done
done
eval "/bin/systemctl start nginx.service"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.