nginx-certbot/scripts/entrypoint.sh

24 lines
672 B
Bash
Raw Normal View History

#!/bin/sh
2017-01-20 02:17:56 +00:00
# When we get killed, kill all our children
2017-01-20 02:17:56 +00:00
trap "exit" INT TERM
trap "kill 0" EXIT
# Source in util.sh so we can have our nice tools
. $(cd $(dirname $0); pwd)/util.sh
# Immediately run auto_enable_configs so that nginx is in a runnable state
auto_enable_configs
# Start up nginx, save PID so we can reload config inside of run_certbot.sh
nginx -g "daemon off;" &
export NGINX_PID=$!
# Next, run certbot to request all the ssl certs we can find
/scripts/run_certbot.sh
# Run `cron -f &` so that it's a background job owned by bash and then `wait`.
# This allows SIGINT (e.g. CTRL-C) to kill cron gracefully, due to our `trap`.
cron -f &
wait "$NGINX_PID"