#!/bin/ash /usr/sbin/nginx -c /etc/nginx/nginx.conf & ngpid=$! waitpid="" stopflag=0 ctrlc () { stopflag=1 kill -QUIT "$ngpid" [ -n "$waitpid" ] && kill -INT "$waitpid" } trap ctrlc INT trap ctrlc TERM 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" echo echo "1. Login to shell" echo " > docker compose exec -it nginx ash" echo "2. Either let certbot retrieve certs and automatically edit nginx config" echo " # certbot --nginx" echo " OR just get certs for hosts in your nginx config, edit manually later" echo " # certbot certonly --nginx" echo "3. Restart:" echo " # exit" echo " > docker compose down && docker compose up -d" while [ $stopflag = 0 ] do sleep 5m & waitpid=$! wait done fi while [ $stopflag = 0 ] do /venv/bin/certbot renew --post-hook "kill -HUP $ngpid" & sleep 12h & waitpid=$! wait done