ports/security/lego/files/lego.sh.sample.in
Rodrigo Osorio 9b6f8163df Add new port security/lego
Lego is a new let's encrypt client write in Go with
support for number of ACME challenges and no external
dependencies.

PR:		237349
Submitted by:	Matthew Horan <matt@matthoran.com>
2019-07-24 07:50:14 +00:00

40 lines
820 B
Bash

#!/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}"