2008-10-07 11:03:30 +11:00
#!/bin/sh
2014-01-15 14:16:52 +11:00
# Attempt to add a set of static routes.
#
# Do this in "ipreallocated" rather than just "startup" because some
# of the routes might be missing because the corresponding interface
# has not previously had any IPs assigned or IPs were previously
# released and corresponding routes were dropped.
#
# Addition of some routes might fail, errors go to /dev/null.
#
# Routes to add are defined in $CTDB_BASE/static-routes. Syntax is:
2008-10-07 11:03:30 +11:00
#
# IFACE NET/MASK GATEWAY
#
2014-01-15 14:16:52 +11:00
# Example:
#
2008-10-07 11:03:30 +11:00
# bond1 10.3.3.0/24 10.0.0.1
2013-01-03 15:26:12 +11:00
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
2008-10-07 11:03:30 +11:00
. $CTDB_BASE/functions
2009-11-19 15:00:17 +11:00
loadconfig
2008-10-07 11:03:30 +11:00
[ -f $CTDB_BASE/static-routes ] || {
exit 0
}
2011-05-12 10:24:46 +10:00
case "$1" in
2013-10-17 16:20:18 +11:00
ipreallocated)
2012-07-17 20:13:45 +10:00
while read iface dest gw; do
ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
done <"${CTDB_BASE}/static-routes"
2011-05-12 10:24:46 +10:00
;;
2008-10-07 11:03:30 +11:00
2010-10-19 19:21:23 +02:00
updateip)
oiface=$2
niface=$3
2012-07-17 20:13:45 +10:00
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"
2010-10-19 19:21:23 +02:00
;;
2009-12-01 17:43:47 +11:00
*)
ctdb_standard_event_handler "$@"
;;
2008-10-07 11:03:30 +11:00
esac
exit 0