3 #################################
4 # interface event script for ctdb
5 # this adds/removes IPs from your
14 [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
15 CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
18 [ ! -f "$CTDB_PUBLIC_ADDRESSES" ] && {
19 echo "No public addresses file found. Nothing to do for 10.interfaces"
24 #############################
25 # called when ctdbd starts up
27 # make sure that we only respond to ARP messages from the NIC where
28 # a particular ip address is associated.
29 echo 1 > /proc/sys/ipv4/conf/all/arp_filter
33 ################################################
34 # called when ctdbd wants to claim an IP address
37 echo "must supply interface, IP and maskbits"
44 # we make sure the interface is up first
45 /sbin/ip link set $iface up || {
46 echo "`/bin/date` Failed to bringup interface $iface"
49 /sbin/ip addr del $ip/32 dev lo >/dev/null 2>/dev/null
50 /sbin/ip addr add $ip/$maskbits dev $iface || {
51 echo "`/bin/date` Failed to add $ip/$maskbits on dev $iface"
55 # flush our route cache
56 echo 1 > /proc/sys/net/ipv4/route/flush
60 ##################################################
61 # called when ctdbd wants to release an IP address
64 echo "`/bin/date` must supply interface, IP and maskbits"
70 /sbin/ip addr del $ip/$maskbits dev $iface || {
71 echo "`/bin/date` Failed to del $ip on dev $iface"
74 /sbin/ip addr add $ip/32 dev lo >/dev/null 2>/dev/null
76 # flush our route cache
77 echo 1 > /proc/sys/net/ipv4/route/flush
81 ###########################################
82 # called when ctdbd has finished a recovery
86 ####################################
87 # called when ctdbd is shutting down
92 [ -x /usr/sbin/ethtool ] && {
93 cat $CTDB_PUBLIC_ADDRESSES | sed -e "s/^[^\t ]*[\t ]*//" -e "s/[\t ]*$//" | sort | uniq | while read IFACE; do
94 /usr/sbin/ethtool $IFACE | grep 'Link detected: yes' > /dev/null || {
95 echo "`date` ERROR: No link on the public network interface $IFACE"