2016-09-21 23:35:19 +00:00
|
|
|
echo "Running certbot for domains $DOMAINS"
|
|
|
|
|
2016-11-19 21:22:07 +00:00
|
|
|
get_certificate() {
|
|
|
|
# Gets the certificate for the domain(s) CERT_DOMAINS (a comma separated list)
|
|
|
|
# The certificate will be named after the first domain in the list
|
|
|
|
# To work, the following variables must be set:
|
|
|
|
# - CERT_DOMAINS : comma separated list of domains
|
|
|
|
# - EMAIL
|
|
|
|
# - args
|
|
|
|
|
|
|
|
local d=${CERT_DOMAINS//,*/} # read first domain
|
|
|
|
echo "Getting certificate for $CERT_DOMAINS"
|
2017-01-02 08:46:53 +00:00
|
|
|
certbot certonly --agree-tos --keep -n \
|
2016-11-19 21:22:07 +00:00
|
|
|
--text --server https://acme-v01.api.letsencrypt.org/directory \
|
|
|
|
--email $EMAIL -d $CERT_DOMAINS $args
|
|
|
|
ec=$?
|
|
|
|
echo "certbot exit code $ec"
|
|
|
|
if [ $ec -eq 0 ]
|
|
|
|
then
|
2017-01-02 23:31:30 +00:00
|
|
|
echo "Certificates for $CERT_DOMAINS can be found in /etc/letsencrypt/live/$d"
|
2016-11-19 21:22:07 +00:00
|
|
|
else
|
|
|
|
echo "Cerbot failed for $CERT_DOMAINS. Check the logs for details."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:35:19 +00:00
|
|
|
args=""
|
|
|
|
if [ $WEBROOT ]
|
|
|
|
then
|
|
|
|
args=" --webroot -w $WEBROOT"
|
|
|
|
else
|
2016-11-19 21:22:07 +00:00
|
|
|
args=" --standalone --standalone-supported-challenges http-01"
|
2016-09-21 23:35:19 +00:00
|
|
|
fi
|
|
|
|
|
2016-09-22 00:55:28 +00:00
|
|
|
if $DEBUG
|
|
|
|
then
|
|
|
|
args=$args" --debug"
|
|
|
|
fi
|
|
|
|
|
2017-01-02 05:34:59 +00:00
|
|
|
set -x
|
2016-11-19 21:22:07 +00:00
|
|
|
if $SEPARATE
|
2016-09-21 23:35:19 +00:00
|
|
|
then
|
2016-09-22 00:55:28 +00:00
|
|
|
for d in $DOMAINS
|
|
|
|
do
|
2016-11-19 21:22:07 +00:00
|
|
|
CERT_DOMAINS=$d
|
|
|
|
get_certificate
|
2016-09-22 00:55:28 +00:00
|
|
|
done
|
2016-09-21 23:35:19 +00:00
|
|
|
else
|
2016-11-19 21:22:07 +00:00
|
|
|
CERT_DOMAINS=${DOMAINS// /,}
|
|
|
|
get_certificate
|
2016-09-21 23:35:19 +00:00
|
|
|
fi
|