1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

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)
This commit is contained in:
Martin Schwenke 2011-08-08 15:44:30 +10:00
parent b30143eb78
commit eec654314a

View File

@ -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