31 lines
496 B
Bash
31 lines
496 B
Bash
|
#!/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
|