From 24752ff05ffdd2786b9aecbc1f6c6bf39b627a02 Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Sat, 19 Jul 2025 17:50:36 +0500 Subject: [PATCH] modified: certbot/Dockerfile new file: certbot/scripts/crontab.txt modified: certbot/scripts/init-certbot.sh Add crontab task file, add into build cront install command --- certbot/Dockerfile | 4 ++++ certbot/scripts/crontab.txt | 1 + certbot/scripts/init-certbot.sh | 20 +++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 certbot/scripts/crontab.txt diff --git a/certbot/Dockerfile b/certbot/Dockerfile index e8e882d..ee6bb54 100644 --- a/certbot/Dockerfile +++ b/certbot/Dockerfile @@ -1,5 +1,9 @@ FROM certbot/certbot +# Обновляем репозитории и устанавливаем cron +RUN apt-get update && \ + apt-get install -y cron + # Создаем директории для конфигов RUN mkdir -p /etc/letsencrypt/config diff --git a/certbot/scripts/crontab.txt b/certbot/scripts/crontab.txt new file mode 100644 index 0000000..3e124f2 --- /dev/null +++ b/certbot/scripts/crontab.txt @@ -0,0 +1 @@ +0 0 * * * root /opt/checkRenewCerts.sh > /proc/1/fd/1 2>&1 \ No newline at end of file diff --git a/certbot/scripts/init-certbot.sh b/certbot/scripts/init-certbot.sh index 511f43c..f61dcf4 100644 --- a/certbot/scripts/init-certbot.sh +++ b/certbot/scripts/init-certbot.sh @@ -25,4 +25,22 @@ if [ ! -d "/etc/letsencrypt/live/${DOMAINS_easysite102}" ]; then --config /etc/letsencrypt/config/certbot.ini \ -w /var/www/certbot \ -d ${DOMAINS_easysite102} -fi \ No newline at end of file +fi + +set -e # Завершаем работу, если любая команда вернёт ошибку + +# Установка Cron (если ещё не установлен) +if ! command -v cron &>/dev/null; then + echo "Cron not found, installing..." + apt-get update && apt-get install -y cron || true +fi + +# Активируем сервис cron +service cron start + +# Копируем нашу собственную crontab таблицу +cp /opt/crontab.txt /etc/crontabs/root + +# Оставляем контейнер открытым +tail -f /dev/null +