nginx-certbot/scripts/run_certbot.sh

31 lines
754 B
Bash
Raw Normal View History

#!/bin/sh
2017-01-20 02:17:56 +00:00
# Source in util.sh so we can have our nice tools
. $(cd $(dirname $0); pwd)/util.sh
# We require an email to register the ssl certificate for
if [ -z "$CERTBOT_EMAIL" ]; then
error "CERTBOT_EMAIL environment variable undefined; certbot will do nothing"
2017-01-20 02:17:56 +00:00
exit 1
fi
2017-01-20 02:17:56 +00:00
exit_code=0
2017-01-02 05:34:59 +00:00
set -x
# Loop over every domain we can find
for domain in $(parse_domains); do
if ! get_certificate $domain $CERTBOT_EMAIL; then
error "Cerbot failed for $domain. Check the logs for details."
2017-01-20 02:17:56 +00:00
exit_code=1
fi
done
# After trying to get all our certificates, auto enable any configs that we
# did indeed get certificates for
auto_enable_configs
# Finally, tell nginx to reload the configs
kill -HUP $NGINX_PID
set +x
2017-01-20 02:17:56 +00:00
exit $exit_code