ctdb-scripts: Drop use of ctdb_standard_event_handler()
[Samba.git] / ctdb / config / events.d / 11.routing
blob941a7a8f1311908747ff793893ea2ed97bcaed32
1 #!/bin/sh
3 # Attempt to add a set of static routes.
5 # Do this in "ipreallocated" rather than just "startup" because some
6 # of the routes might be missing because the corresponding interface
7 # has not previously had any IPs assigned or IPs were previously
8 # released and corresponding routes were dropped.
10 # Addition of some routes might fail, errors go to /dev/null.
12 # Routes to add are defined in $CTDB_BASE/static-routes. Syntax is:
14 # IFACE NET/MASK GATEWAY
16 # Example:
18 # bond1 10.3.3.0/24 10.0.0.1
20 [ -n "$CTDB_BASE" ] || \
21 CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
23 . "${CTDB_BASE}/functions"
25 loadconfig
27 [ -f "${CTDB_BASE}/static-routes" ] || {
28 exit 0
31 case "$1" in
32 ipreallocated)
33 while read iface dest gw; do
34 ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
35 done <"${CTDB_BASE}/static-routes"
38 updateip)
39 oiface=$2
40 niface=$3
41 while read iface dest gw; do
42 if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then
43 ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1
45 done <"${CTDB_BASE}/static-routes"
47 esac
49 exit 0