diff options
author | Martin Schwenke <martin@meltin.net> | 2011-08-08 15:44:30 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2011-08-08 15:44:30 +1000 |
commit | eec654314aaa590e2a4b7d94e01a4e009a2d4683 (patch) | |
tree | dc648d4df8249c1129ff1920618fbe2f783e11d3 | |
parent | b30143eb78c5e5652f0a33b52dd40adec592f768 (diff) | |
download | samba-eec654314aaa590e2a4b7d94e01a4e009a2d4683.tar.gz samba-eec654314aaa590e2a4b7d94e01a4e009a2d4683.tar.xz samba-eec654314aaa590e2a4b7d94e01a4e009a2d4683.zip |
Eventscripts - Remove local variable usage in 10.interfaces.
POSIX sh doesn't have local variables. Debian's dash doesn't behave
the same way as bash on this contruct:
local var=`command that produces multiple words`
It only assigns the 1st word and may print an error.
Just remove the use of the "local" keyword in monitor_interfaces() to
solve this. It isn't actually limiting the scope of any variables
that are used outside the function.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 95d9a1e19655461288a2c7e52abf9d01ab23e05a)
-rwxr-xr-x | ctdb/config/events.d/10.interface | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 7f79a08949..b912ab3dc8 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -18,7 +18,7 @@ loadconfig monitor_interfaces() { - local INTERFACES=`cat $CTDB_PUBLIC_ADDRESSES | + INTERFACES=`cat $CTDB_PUBLIC_ADDRESSES | sed -e "s/^[^\t ]*[\t ]*//" -e "s/,/ /g" -e "s/[\t ]*$//"` [ "$CTDB_PUBLIC_INTERFACE" ] && INTERFACES="$CTDB_PUBLIC_INTERFACE $INTERFACES" @@ -27,14 +27,12 @@ monitor_interfaces() # For all but the 1st line, get the 2nd last field with commas # changes to spaces. - local IFACES=`ctdb -Y ip -v | sed -e '1d' -e 's/:[^:]*:$//' -e 's/^.*://' -e 's/,/ /g'` - - local IFACE + IFACES=`ctdb -Y ip -v | sed -e '1d' -e 's/:[^:]*:$//' -e 's/^.*://' -e 's/,/ /g'` INTERFACES=`for IFACE in $INTERFACES $IFACES ; do echo $IFACE ; done | sort | uniq` - local fail=0 - local ok=0 + fail=0 + ok=0 for IFACE in $INTERFACES ; do ip addr show $IFACE 2>/dev/null >/dev/null || { @@ -45,7 +43,7 @@ monitor_interfaces() # These interfaces are sometimes bond devices # 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/\..*$//'` + REALIFACE=`echo $IFACE |sed -e 's/\..*$//'` bi=$(get_proc "net/bonding/$REALIFACE") 2>/dev/null && { echo "$bi" | grep -q 'Currently Active Slave: None' && { echo "ERROR: No active slaves for bond device $REALIFACE" @@ -91,7 +89,7 @@ monitor_interfaces() # cable is plugged but the interface has not been # brought up previously. Bring the interface up and # try again... - /sbin/ip link set $IFACE up + ip link set $IFACE up ethtool $IFACE | grep -q 'Link detected: yes' || { echo "ERROR: No link on the public network interface $IFACE" fail=1 |