Reload nginx if certificates has been created/updated

This commit is contained in:
JrCs 2015-11-27 12:46:12 +01:00
parent 109017566a
commit 7b40ad970f
2 changed files with 8 additions and 6 deletions

View file

@ -10,6 +10,7 @@ update_certs() {
# Load relevant container settings
source "$DIR"/letsencrypt_service_data
reload_nginx='false'
for cid in "${LETSENCRYPT_CONTAINERS[@]}"; do
# Derive host and email variable names
host_varname="LETSENCRYPT_${cid}_HOST"
@ -36,14 +37,15 @@ update_certs() {
# Symlink to created certificate and key.
ln -sf ./$domain/fullchain.pem /etc/nginx/certs/$domain".crt"
ln -sf ./$domain/key.pem /etc/nginx/certs/$domain".key"
# Update certificates configuration in nginx
/usr/local/bin/docker-gen -only-exposed /app/nginx.tmpl /etc/nginx/conf.d/default.conf
nginx -s reload
reload_nginx='true'
fi
done
done
unset LETSENCRYPT_CONTAINERS
if [[ "$reload_nginx" == 'true' ]]; then
/usr/local/bin/docker-gen -only-exposed /app/nginx.tmpl /etc/nginx/conf.d/default.conf
nginx -s reload
fi
}
pid=

View file

@ -1,8 +1,8 @@
#!/bin/bash
nginx -s reload
docker-gen \
-only-exposed \
-notify '/app/update_certs' \
/app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data
nginx -s reload