33 lines
605 B
Bash
33 lines
605 B
Bash
#!/bin/ash
|
|
|
|
if [ ! -e /etc/letsencrypt ]
|
|
then
|
|
echo "[!!] Certbot directory is not initialized"
|
|
echo "[!!] Either it's the first run or you forgot to add a volume"
|
|
|
|
# check if stdin (fd 0) is assigned to a tty
|
|
[ ! -t 0 ] && echo "Not a TTY! Exiting" && exit 1
|
|
|
|
/venv/bin/certbot certonly --nginx
|
|
exit $?
|
|
fi
|
|
|
|
/usr/sbin/nginx -c /etc/nginx/nginx.conf &
|
|
ngpid=$!
|
|
waitpid=""
|
|
|
|
ctrlc () {
|
|
kill -QUIT "$ngpid"
|
|
[ -n "$waitpid" ] && kill -INT "$waitpid"
|
|
}
|
|
|
|
trap ctrlc INT
|
|
trap ctrlc TERM
|
|
|
|
while true
|
|
do
|
|
/venv/bin/certbot renew --post-hook "kill -HUP $ngpid"
|
|
sleep 12h &
|
|
waitpid=$!
|
|
wait
|
|
done
|