Compare commits
	
		
			2 Commits
		
	
	
		
			d01fbeb68a
			...
			820020f23e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 820020f23e | |||
| 3d465082a5 | 
@@ -1,6 +1,6 @@
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,8 @@ 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 # docker socket proxy
 | 
			
		||||
      - ADGUARD_CONTAINER_NAME=adguardhome # adguard container name
 | 
			
		||||
    volumes:
 | 
			
		||||
      - /path/to/adguard/confdir:/adguard
 | 
			
		||||
 | 
			
		||||
@@ -17,6 +18,7 @@ services:
 | 
			
		||||
      - no-new-privileges:true
 | 
			
		||||
    environment:
 | 
			
		||||
      - CONTAINERS=1
 | 
			
		||||
      - ALLOW_RESTARTS=1
 | 
			
		||||
    volumes:
 | 
			
		||||
      - /var/run/docker.sock:/var/run/docker.sock:ro
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -7,7 +7,8 @@ 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"}
 | 
			
		||||
ADGUARD_CONTAINER_NAME=${ADGUARD_CONTAINER_NAME:-"adguardhome"}
 | 
			
		||||
 | 
			
		||||
if [ -z "$COUNTRIES" ]; then
 | 
			
		||||
  echo "No countries specified in BLOCK_COUNTRIES."
 | 
			
		||||
@@ -42,6 +43,6 @@ END { if (inside==1) print ips }
 | 
			
		||||
mv "$TMP_YAML" "$ADGUARD_YAML"
 | 
			
		||||
 | 
			
		||||
echo "Restarting adguard-home container..."
 | 
			
		||||
curl -s -X POST "$DOCKER_API_URL/containers/adguard-home/restart" -o /dev/null
 | 
			
		||||
curl -s -X POST "$DOCKER_API_URL/containers/$ADGUARD_CONTAINER_NAME/restart" -o /dev/null
 | 
			
		||||
 | 
			
		||||
echo "Done."
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user