Commit f340b0e8 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: include gateway/table in hash, detect gateway changes

parent b0a2f9fe
......@@ -188,8 +188,8 @@ process_routes()
continue
fi
# Compute hash of all list contents
local current_hash=$(md5_lists $lists)
# 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
local saved_hash
......@@ -228,11 +228,15 @@ process_routes()
# Check if resolved IPs actually changed
if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then
if diff -q "$STATE_DIR/$state/resolved" "$resolved_new" >/dev/null 2>&1 ; then
# IPs same, but gateway may have changed
if [ -f "$STATE_DIR/$state/gateway" ] && diff -q "$STATE_DIR/$state/gateway" "$gwdir/gateway" >/dev/null 2>&1 ; then
log "[$name]$label Resolved IPs unchanged, updating hash only"
echo "$current_hash" > "$STATE_DIR/$state/hash"
rm -f "$resolved_new"
continue
fi
log "[$name]$label Gateway changed, reloading routes"
fi
fi
local count=$(wc -l < "$resolved_new")
......@@ -260,6 +264,7 @@ process_routes()
# Save state
echo "$current_hash" > "$STATE_DIR/$state/hash"
echo "$table" > "$STATE_DIR/$state/table"
cp "$gwdir/gateway" "$STATE_DIR/$state/gateway"
mv "$resolved_new" "$STATE_DIR/$state/resolved"
log "[$name]$label Done"
......
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