From 3d465082a56282d471f5e2f3fe19782f730705a9 Mon Sep 17 00:00:00 2001 From: Djeex Date: Sat, 31 May 2025 17:02:27 +0000 Subject: [PATCH] Fixed cron issues with cronie --- Dockerfile | 4 ++-- README.md | 2 +- docker-compose.yml | 2 +- entrypoint.sh | 14 +++----------- update-blocklist.sh | 2 +- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 912fa7b..05db38b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM alpine:latest -RUN apk add --no-cache curl bash dcron tzdata +RUN apk add --no-cache curl bash busybox tzdata COPY update-blocklist.sh /usr/local/bin/update-blocklist.sh COPY entrypoint.sh /entrypoint.sh RUN chmod +x /usr/local/bin/update-blocklist.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 198e3c7..6d2e943 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ | `TZ` | Your Time Zone | (required) | | `BLOCK_COUNTRIES` | Comma-separated country codes to block (e.g., `CN,RU,IR`) | (required) | | `BLOCKLIST_CRON` | Cron expression for update frequency (e.g., `0 6 * * *`) | `0 6 * * *` (at 6:00 everydays) | -| `DOCKER_API_URL` | URL of Docker socket proxy to restart AdGuard container | `tcp://socket-proxy-adguard:2375` | +| `DOCKER_API_URL` | URL of Docker socket proxy to restart AdGuard container | `http://socket-proxy-adguard:2375` | ## File Structure diff --git a/docker-compose.yml b/docker-compose.yml index dde3cd0..67643ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: - TZ=Europe/Paris # change to your timezone - BLOCK_COUNTRIES=CN,RU,IR # choose countries listed IP to block. Full lists here https://github.com/vulnebify/cidre/tree/main/output/cidr/ipv4 - BLOCKLIST_CRON=0 6 * * * # at 6:00 every days - - DOCKER_API_URL=tcp://socket-proxy-adguard:2375 + - DOCKER_API_URL=http://socket-proxy-adguard:2375 volumes: - /path/to/adguard/confdir:/adguard diff --git a/entrypoint.sh b/entrypoint.sh index 1918d3a..a4a93fa 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,22 +1,14 @@ #!/bin/sh - set -e if [ -n "$TZ" ]; then if [ -f "/usr/share/zoneinfo/$TZ" ]; then cp "/usr/share/zoneinfo/$TZ" /etc/localtime echo "$TZ" > /etc/timezone - else - echo "Warning: Timezone file /usr/share/zoneinfo/$TZ not found, skipping timezone setup." fi fi -CRON_EXPR="${BLOCKLIST_CRON:-"0 6 * * *"}" # default: every day at 6:00 am -SCRIPT_PATH="/usr/local/bin/update-blocklist.sh" +CRON_EXPR="${BLOCKLIST_CRON:-"0 6 * * *"}" +echo "$CRON_EXPR /usr/local/bin/update-blocklist.sh" > /etc/crontabs/root -echo "Installing cron job with expression: $CRON_EXPR" - -echo "$CRON_EXPR root $SCRIPT_PATH" > /etc/crontabs/root - -echo "Starting cron..." -exec crond -f -L /dev/stdout +exec crond -f -c /etc/crontabs \ No newline at end of file diff --git a/update-blocklist.sh b/update-blocklist.sh index 0dc4c4b..7c06ad5 100644 --- a/update-blocklist.sh +++ b/update-blocklist.sh @@ -7,7 +7,7 @@ TMP_YAML="/tmp/AdGuardHome.yaml" MANUAL_IPS_FILE="/adguard/manually_blocked_ips.conf" CIDR_BASE_URL="https://raw.githubusercontent.com/vulnebify/cidre/main/output/cidr/ipv4" COUNTRIES=${BLOCK_COUNTRIES:-""} -DOCKER_API_URL=${DOCKER_API_URL:-"tcp://socket-proxy-adguard:2375"} +DOCKER_API_URL=${DOCKER_API_URL:-"http://socket-proxy-adguard:2375"} if [ -z "$COUNTRIES" ]; then echo "No countries specified in BLOCK_COUNTRIES."