ungleich-k8s/archive/containers/ungleich-nginx/watch-and-run.sh

31 lines
496 B
Bash
Raw Normal View History

2021-06-20 08:27:20 +00:00
#!/bin/sh
if [ -z ${DOMAIN} ]; then
exit 0
fi
file=/etc/letsencrypt/live/${DOMAIN}/fullchain.pem
while [ ! -f $file ]; do
echo "Waiting for ${file} ..."
sleep 2
done
# Now we can start nginx as a daemon
nginx
cksum=$(cksum $file)
cksum_new=$cksum
# Check every 10 minutes for new certs
# If they are there, reload nginx
while true; do
cksum_new=$(cksum $file)
if [ $cksum != $cksum_new ]; then
nginx -s reload
cksum=$cksum_new
fi
sleep 600
done