1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00
Stefan Metzmacher ab6beb6b7f events.d/11.routing: handle "updateip" event
metze

(This used to be ctdb commit 034635418c7e5274d6bdf4cccc7a10e3b631e2d4)
2010-10-21 11:09:46 +11:00

47 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
. $CTDB_BASE/functions
loadconfig
[ -f $CTDB_BASE/static-routes ] || {
exit 0
}
case "$1" in
takeip|releaseip)
iface=$2
cat $CTDB_BASE/static-routes | egrep "^$iface " | while read IFACE DEST GW; do
ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
done
;;
updateip)
oiface=$2
niface=$3
cat $CTDB_BASE/static-routes | egrep "^$niface " | while read IFACE DEST GW; do
ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
done
cat $CTDB_BASE/static-routes | egrep "^$oiface " | while read IFACE DEST GW; do
ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
done
;;
*)
ctdb_standard_event_handler "$@"
;;
esac
exit 0