2015-12-31 18:50:25 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# SIGTERM-handler
|
|
|
|
term_handler() {
|
|
|
|
[[ -n "$docker_gen_pid" ]] && kill $docker_gen_pid
|
|
|
|
[[ -n "$letsencrypt_service_pid" ]] && kill $letsencrypt_service_pid
|
|
|
|
|
2016-06-26 00:31:15 +02:00
|
|
|
source /app/functions.sh
|
2016-01-01 14:32:40 +01:00
|
|
|
remove_all_location_configurations
|
|
|
|
|
2015-12-31 18:50:25 +01:00
|
|
|
exit 143; # 128 + 15 -- SIGTERM
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'term_handler' INT QUIT KILL TERM
|
|
|
|
|
|
|
|
/app/letsencrypt_service &
|
|
|
|
letsencrypt_service_pid=$!
|
|
|
|
|
2016-02-11 21:18:20 +01:00
|
|
|
docker-gen -watch -only-exposed -notify '/app/update_certs' -wait 15s:60s /app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data &
|
2015-12-31 18:50:25 +01:00
|
|
|
docker_gen_pid=$!
|
|
|
|
|
|
|
|
# wait "indefinitely"
|
|
|
|
while [[ -e /proc/$docker_gen_pid ]]; do
|
|
|
|
wait $docker_gen_pid # Wait for any signals or end of execution of docker-gen
|
|
|
|
done
|
|
|
|
|
|
|
|
# Stop container properly
|
|
|
|
term_handler
|