Commit e603a488 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: add --resolve option to re-resolve DNS without hash check

Skips the file hash check but keeps the resolved IP diff, so routes are only reloaded when DNS actually returns different IPs. Useful for cron: `*/15 * * * * ./route-update.sh --resolve` Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 38a0e591
......@@ -78,7 +78,10 @@ IP-адрес шлюза, одна строка — обычный маршру
# Основной запуск (пропускает неизменённые группы)
./route-update.sh
# Принудительная перезагрузка всех маршрутов
# Перерезолвить DNS (маршруты обновятся только если IP изменились)
./route-update.sh --resolve
# Принудительная перезагрузка всех маршрутов (без проверок)
./route-update.sh --force
# Показать что будет сделано, ничего не менять
......
......@@ -2,7 +2,7 @@
# Unified route updater: reads directory-based config from routes.d/ and routes6.d/
# Each subdirectory = route group with gateway/table files and .list symlinks
#
# Usage: route-update.sh [--force] [--show] [--set-rules]
# Usage: route-update.sh [--force] [--resolve] [--show] [--set-rules]
# route-update.sh --add IP|DOMAIN GROUP
# route-update.sh --del IP|DOMAIN GROUP
# route-update.sh --flush GROUP
......@@ -16,6 +16,7 @@ ROUTES6_DIR=routes6.d
STATE_DIR=.state
FORCE=
RESOLVE=
SHOW=
SET_RULES=
......@@ -28,6 +29,7 @@ FLUSH_GROUP=
while [ -n "$1" ] ; do
case "$1" in
--force) FORCE=1 ;;
--resolve) RESOLVE=1 ;;
--show) SHOW=1 ;;
--set-rules) SET_RULES=1 ;;
--flush) FLUSH_GROUP="$2" ; shift ;;
......@@ -191,7 +193,7 @@ process_routes()
# Compute hash of all list contents + gateway + table
local current_hash=$(md5_lists "$gwdir/gateway" "$gwdir/table" $lists)
if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/hash" ] ; then
if [ -z "$FORCE" ] && [ -z "$RESOLVE" ] && [ -f "$STATE_DIR/$state/hash" ] ; then
local saved_hash
read -r saved_hash < "$STATE_DIR/$state/hash"
if [ "$current_hash" = "$saved_hash" ] ; then
......@@ -200,7 +202,11 @@ process_routes()
fi
fi
if [ -n "$RESOLVE" ] ; then
log "[$name]$label Re-resolving..."
else
log "[$name]$label Changes detected, resolving..."
fi
# Split: pure IP files go through cat, domain files through resolve
local resolved_new="$STATE_DIR/$state/resolved.new"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment