Enhance update of certificates
Update or create the certificates as soon as possible
This commit is contained in:
parent
5bcb1956a8
commit
1a4422ecb3
4 changed files with 55 additions and 39 deletions
5
Procfile
5
Procfile
|
@ -1,4 +1,3 @@
|
||||||
nginx: nginx
|
nginx: /usr/sbin/nginx
|
||||||
dockergen: docker-gen -watch -only-exposed -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
dockergen: /usr/local/bin/docker-gen -watch -only-exposed -notify "/app/update_nginx" /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||||
letsencrypt_dockergen: docker-gen -watch -only-exposed /app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data
|
|
||||||
letsencrypt: /app/letsencrypt_service
|
letsencrypt: /app/letsencrypt_service
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
echo 'Waiting'
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Wait some amount of time
|
|
||||||
seconds_to_wait=3600
|
seconds_to_wait=3600
|
||||||
|
|
||||||
while true; do
|
update_certs() {
|
||||||
|
[[ ! -f "$DIR"/letsencrypt_service_data ]] && return
|
||||||
|
|
||||||
# Load relevant container settings
|
# Load relevant container settings
|
||||||
source "$DIR"/letsencrypt_service_data
|
source "$DIR"/letsencrypt_service_data
|
||||||
|
|
||||||
|
@ -39,13 +37,21 @@ while true; do
|
||||||
ln -sf ./$domain/fullchain.pem /etc/nginx/certs/$domain".crt"
|
ln -sf ./$domain/fullchain.pem /etc/nginx/certs/$domain".crt"
|
||||||
ln -sf ./$domain/key.pem /etc/nginx/certs/$domain".key"
|
ln -sf ./$domain/key.pem /etc/nginx/certs/$domain".key"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: Regenerate nginx config if simp_le created a certificate and key
|
|
||||||
#if [ "$simp_le_return" -eq 0 ]; then nginx -s reload; fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
unset LETSENCRYPT_CONTAINERS
|
unset LETSENCRYPT_CONTAINERS
|
||||||
|
}
|
||||||
|
|
||||||
date
|
pid=
|
||||||
echo "Waiting $seconds_to_wait seconds"; sleep $seconds_to_wait
|
trap '[[ $pid ]] && kill $pid; exec $0' EXIT
|
||||||
done
|
trap 'trap - EXIT' INT TERM
|
||||||
|
|
||||||
|
echo 'Waiting 10s before updating certs...'
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
update_certs
|
||||||
|
|
||||||
|
# Wait some amount of time
|
||||||
|
sleep $seconds_to_wait & pid=$!
|
||||||
|
wait
|
||||||
|
pid=
|
||||||
|
|
3
update_certs
Executable file
3
update_certs
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
pkill -f -SIGUSR1 /app/letsencrypt_service
|
8
update_nginx
Executable file
8
update_nginx
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
docker-gen \
|
||||||
|
-only-exposed \
|
||||||
|
-notify '/app/update_certs' \
|
||||||
|
/app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data
|
||||||
|
|
||||||
|
nginx -s reload
|
Loading…
Reference in a new issue