Last active
January 25, 2016 12:56
-
-
Save bviktor/a39d3d025d6334d4a713 to your computer and use it in GitHub Desktop.
Let's Encrypt renew script
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/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