2025-02-18 22:57:34 +04:00
|
|
|
#!/bin/ash
|
|
|
|
|
2025-02-19 14:12:07 +04:00
|
|
|
if [ ! -e /etc/letsencrypt/live ]
|
2025-02-18 22:57:34 +04:00
|
|
|
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
|
|
|
|
|
2025-02-19 14:10:57 +04:00
|
|
|
echo "Choose installation method:"
|
|
|
|
echo " 1. get certs for hosts specified in nginx.conf"
|
|
|
|
echo " and automatically edit the config (default)"
|
|
|
|
echo " 2. get certs for hosts, do not edit the config"
|
|
|
|
echo " 3. just launch shell, i'll do it myself"
|
2025-02-19 14:14:02 +04:00
|
|
|
read -p '>> ' n
|
2025-02-19 14:10:57 +04:00
|
|
|
|
|
|
|
if [ "$n" = 3 ]
|
|
|
|
then
|
|
|
|
/bin/ash -i
|
|
|
|
elif [ "$n" = 2 ]
|
|
|
|
then
|
|
|
|
/venv/bin/certbot certonly --nginx
|
|
|
|
else
|
|
|
|
/venv/bin/certbot --nginx
|
|
|
|
fi
|
|
|
|
|
2025-02-18 22:57:34 +04:00
|
|
|
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
|