Last active
June 16, 2019 23:37
-
-
Save mhoran/1d8cbe8ccb61bef7a9fb2d93baf2fb85 to your computer and use it in GitHub Desktop.
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 -e | |
# Email used for registration and recovery contact. | |
EMAIL="" | |
BASEDIR="%%ETCDIR%%" | |
SSLDIR="%%PREFIX%%/etc/ssl/lego" | |
DOMAINSFILE="${BASEDIR}/domains.txt" | |
if [ -z "${EMAIL}" ]; then | |
echo "Please set EMAIL to a valid address in ${BASEDIR}/lego.sh" | |
exit 1 | |
fi | |
if [ ! -e "${DOMAINSFILE}" ]; then | |
echo "Please create ${DOMAINSFILE} as specified in ${BASEDIR}/lego.sh" | |
exit 1 | |
fi | |
if [ "$1" = "run" ]; then | |
command="run" | |
else | |
command="renew --days 30" | |
fi | |
run_or_renew() { | |
%%PREFIX%%/bin/lego --path "${SSLDIR}" \ | |
--email="${EMAIL}" \ | |
$(printf -- "--domains=%s " $line) \ | |
--http --http.webroot="%%WWWDIR%%" \ | |
$1 | |
} | |
while read line <&3; do | |
if [ "$command" = "run" ]; then | |
run_or_renew "$command" | |
else | |
output=$(run_or_renew "$command") || (echo "$output" && exit 1) | |
fi | |
done 3<"${DOMAINSFILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment