Eventscripts: 10.interfaces clean-up - use more descriptive variable names.
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jun 2011 06:10:23 +0000 (16:10 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 12 Aug 2011 04:49:27 +0000 (14:49 +1000)
The name of variable $ok gives no clue to its meaning/use so this
changes that variable to be named $up_interfaces_found.

The return logic relating to $ok and $fail is difficult to read, so
these variables are given true/fale values, allowing the return logic
to be simplified.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/events.d/10.interface

index a82e4295dd103a1c4717fd09a7cf5f2bf2ffe589..207a9d38ca3420d35ccda83ffcbaab1fa75bc228 100755 (executable)
@@ -18,13 +18,13 @@ loadconfig
 
 mark_up ()
 {
-    ok=1
+    up_interfaces_found=true
     ctdb setifacelink $1 up >/dev/null 2>&1
 }
 
 mark_down ()
 {
-    fail=1
+    fail=true
     ctdb setifacelink $1 down >/dev/null 2>&1
 }
 
@@ -43,8 +43,8 @@ monitor_interfaces()
 
        INTERFACES=`for IFACE in $INTERFACES $IFACES ; do echo $IFACE ; done | sort | uniq`
 
-       fail=0
-       ok=0
+       fail=false
+       up_interfaces_found=false
        for IFACE in $INTERFACES ; do
 
            ip addr show $IFACE 2>/dev/null >/dev/null || {
@@ -109,15 +109,11 @@ monitor_interfaces()
 
        done
 
-       test x"$fail" = x"0" && {
-               return 0;
-       }
+       $fail || return 0
 
-       test x"$ok" = x"1" && {
-               return 2;
-       }
+       $up_interfaces_found && return 2
 
-       return 1;
+       return 1
 }
 
 case "$1" in