Merge branch 'master' of ssh://git.samba.org/data/git/ctdb
[nivanova/samba-autobuild/.git] / ctdb / config / events.d / 11.routing
1 #!/bin/sh
2 # script to add entries to the routing table after we have performed a
3 # take ip event
4 # (when we do a "releaseip" event and remove an ip address from an interface
5 #  the kernel might automatically remove associated entries from
6 #  the routing table. This is where we add them back)
7 #
8 # Routes to add are defined in /etc/ctdb/static-routes.
9 # Syntax is :
10 # IFACE NET/MASK GATEWAY
11 #
12 # Example
13 # bond1 10.3.3.0/24 10.0.0.1
14
15 . $CTDB_BASE/functions
16 loadconfig
17
18 [ -f $CTDB_BASE/static-routes ] || {
19     exit 0
20 }
21
22 case "$1" in
23     recovered|ipreallocated)
24         cat $CTDB_BASE/static-routes | while read IFACE DEST GW; do
25             ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
26         done
27         ;;
28
29     updateip)
30         oiface=$2
31         niface=$3
32         cat $CTDB_BASE/static-routes | egrep "^$niface " | while read IFACE DEST GW; do
33             ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
34         done
35         cat $CTDB_BASE/static-routes | egrep "^$oiface " | while read IFACE DEST GW; do
36             ip route add $DEST via $GW dev $IFACE >/dev/null 2>/dev/null
37         done
38         ;;
39
40     *)
41         ctdb_standard_event_handler "$@"
42         ;;
43 esac
44
45 exit 0