#!/bin/ash if [ ! -e /etc/letsencrypt/live ] 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 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" read n if [ "$n" = 3 ] then /bin/ash -i elif [ "$n" = 2 ] then /venv/bin/certbot certonly --nginx else /venv/bin/certbot --nginx fi 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