Eventscripts: update 10.interface to use set_proc() and get_proc().
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jun 2011 05:36:28 +0000 (15:36 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 3 Aug 2011 09:58:25 +0000 (19:58 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
config/events.d/10.interface

index ecaa323c5e63408c1d2c480eab699aa13f37eec4..4c022293940c13f3aec9e02e708189d5bb4c59cb 100755 (executable)
@@ -46,14 +46,14 @@ monitor_interfaces()
            # When we use VLANs for bond interfaces, there will only
            # be an entry in /proc for the underlying real interface
            local REALIFACE=`echo $IFACE |sed -e 's/\..*$//'`
-           [ -f /proc/net/bonding/$REALIFACE ] && {
-               grep -q 'Currently Active Slave: None' /proc/net/bonding/$REALIFACE && {
+           get_proc "net/bonding/$REALIFACE" >/dev/null 2>&1 && {
+               get_proc "net/bonding/$REALIFACE" | grep -q 'Currently Active Slave: None' && {
                        echo "ERROR: No active slaves for bond device $REALIFACE"
                        fail=1
                        ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
                        continue;
                }
-               grep -q '^MII Status: up' /proc/net/bonding/$REALIFACE || {
+               get_proc "net/bonding/$REALIFACE" | grep -q '^MII Status: up' || {
                        echo "ERROR: public network interface $REALIFACE is down"
                        fail=1
                        ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
@@ -124,8 +124,8 @@ case "$1" in
      init)
        # make sure that we only respond to ARP messages from the NIC where
        # a particular ip address is associated.
-       [ -f /proc/sys/net/ipv4/conf/all/arp_filter ] && {
-           echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
+       get_proc sys/net/ipv4/conf/all/arp_filter >/dev/null 2>&1 && {
+           set_proc sys/net/ipv4/conf/all/arp_filter 1
        }
        ;;
 
@@ -164,7 +164,7 @@ case "$1" in
        iptables -D INPUT -i $iface -d $ip -j DROP 2> /dev/null
 
        # flush our route cache
-       echo 1 > /proc/sys/net/ipv4/route/flush
+       set_proc sys/net/ipv4/route/flush 1
        ;;
 
 
@@ -204,7 +204,7 @@ case "$1" in
        iptables -D INPUT -i $iface -d $ip -j DROP 2> /dev/null
 
        # flush our route cache
-       echo 1 > /proc/sys/net/ipv4/route/flush
+       set_proc sys/net/ipv4/route/flush 1
        ;;
 
      ##################################################
@@ -248,7 +248,7 @@ case "$1" in
        iptables -D INPUT -i $oiface -d $ip -j DROP 2> /dev/null
 
        # flush our route cache
-       echo 1 > /proc/sys/net/ipv4/route/flush
+       set_proc sys/net/ipv4/route/flush 1
 
        # propagate the new mac address
        ctdb gratiousarp $ip $niface