2016-09-21 23:35:19 +00:00
|
|
|
echo "Running certbot for domains $DOMAINS"
|
|
|
|
|
2016-11-19 21:22:07 +00:00
|
|
|
get_certificate() {
|
2017-01-20 01:42:04 +00:00
|
|
|
# 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
|
2016-11-19 21:22:07 +00:00
|
|
|
|
2017-01-20 01:42:04 +00:00
|
|
|
local d=${CERT_DOMAINS//,*/} # read first domain
|
|
|
|
echo "Getting certificate for $CERT_DOMAINS"
|
|
|
|
certbot certonly --agree-tos --keep -n --text --email $EMAIL --server \
|
|
|
|
https://acme-v01.api.letsencrypt.org/directory -d $CERT_DOMAINS \
|
|
|
|
--standalone --standalone-supported-challenges http-01 --debug
|
|
|
|
ec=$?
|
|
|
|
echo "certbot exit code $ec"
|
|
|
|
if [ $ec -eq 0 ]; then
|
|
|
|
echo "Certificates for $CERT_DOMAINS can be found in /etc/letsencrypt/live/$d"
|
|
|
|
else
|
|
|
|
echo "Cerbot failed for $CERT_DOMAINS. Check the logs for details."
|
|
|
|
fi
|
2016-11-19 21:22:07 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 05:34:59 +00:00
|
|
|
set -x
|
2017-01-20 01:42:04 +00:00
|
|
|
for d in $DOMAINS
|
|
|
|
do
|
|
|
|
CERT_DOMAINS=$d
|
2016-11-19 21:22:07 +00:00
|
|
|
get_certificate
|
2017-01-20 01:42:04 +00:00
|
|
|
done
|
|
|
|
|