1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-29 21:47:30 +03:00
Martin Schwenke 04c31bf50d eventscripts: Don't update static routes on "recovered" event
Routes only need to be updated when IPs have moved.  IP takeover runs
will generate "ipreallocated", which is enough.  "recovered" always
follows "ipreallocated" anyway, so avoid the redundancy.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 1152215fc69217e4292762e28d193b7ea0e06ee3)
2013-10-22 14:34:05 +11:00

48 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# script to add entries to the routing table after we have performed a
# take ip event
# (when we do a "releaseip" event and remove an ip address from an interface
# the kernel might automatically remove associated entries from
# the routing table. This is where we add them back)
#
# Routes to add are defined in /etc/ctdb/static-routes.
# Syntax is :
# IFACE NET/MASK GATEWAY
#
# Example
# bond1 10.3.3.0/24 10.0.0.1
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
. $CTDB_BASE/functions
loadconfig
[ -f $CTDB_BASE/static-routes ] || {
exit 0
}
case "$1" in
ipreallocated)
while read iface dest gw; do
ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
done <"${CTDB_BASE}/static-routes"
;;
updateip)
oiface=$2
niface=$3
while read iface dest gw; do
if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then
ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
fi
done <"${CTDB_BASE}/static-routes"
;;
*)
ctdb_standard_event_handler "$@"
;;
esac
exit 0