Line 0
Link Here
|
|
|
1 |
#!/bin/sh -e |
2 |
|
3 |
# Email used for registration and recovery contact. |
4 |
EMAIL="" |
5 |
|
6 |
BASEDIR="%%PREFIX%%/etc/lego" |
7 |
SSLDIR="%%PREFIX%%/etc/ssl/lego" |
8 |
DOMAINSFILE="${BASEDIR}/domains.txt" |
9 |
|
10 |
if [ -z "${EMAIL}" ]; then |
11 |
echo "Please set EMAIL to a valid address in ${BASEDIR}/lego.sh" |
12 |
exit 1 |
13 |
fi |
14 |
|
15 |
if [ ! -e "${DOMAINSFILE}" ]; then |
16 |
echo "Please create ${DOMAINSFILE} as specified in ${BASEDIR}/lego.sh" |
17 |
exit 1 |
18 |
fi |
19 |
|
20 |
# %%PREFIX%%/etc/lego/domains.txt: |
21 |
# example.com www.example.com |
22 |
|
23 |
# Generates a certificate with CN=example.com and |
24 |
# SAN=example.com www.example.com |
25 |
|
26 |
# Each line will generate a separate certificate. |
27 |
|
28 |
while read line ; do |
29 |
output=$(%%PREFIX%%/bin/lego --path "${SSLDIR}" \ |
30 |
--email="${EMAIL}" \ |
31 |
$(printf -- "--domains=%s " $line) \ |
32 |
--http --http.webroot="%%WWWDIR%%" \ |
33 |
renew --days 30) || (echo "$output" && exit 1) |
34 |
done < "${DOMAINSFILE}" |