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