From be71a84565e9e7532a77c175732b764d1f42c1cd Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 27 Mar 2014 16:31:54 +1100 Subject: ctdb-eventscripts: Don't check if $iface is empty This is the loop variable. It can't be empty, especially given the way the list is built. This must have survived from an earlier version of the script. Given that there are whitespace changes associated with the above, clean-up the "virtio_net" avoidance check so that it reads less like line-noise. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/config/events.d/10.interface | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 32d841f610..979fa7b7e0 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -110,22 +110,24 @@ monitor_interfaces() mark_up $iface ;; *) - [ -z "$iface" ] || { - [ "$(basename $(readlink /sys/class/net/$iface/device/driver) 2>/dev/null)" = virtio_net ] || + # Ignore virtio_net devices, assume they're always up + _driver_path="/sys/class/net/$iface/device/driver" + _driver=$(basename $(readlink "$_driver_path") 2>/dev/null) + [ "$_driver" = "virtio_net" ] && continue + + ethtool $iface | grep -q 'Link detected: yes' || { + # On some systems, this is not successful when a + # cable is plugged but the interface has not been + # brought up previously. Bring the interface up + # and try again... + ip link set $iface up ethtool $iface | grep -q 'Link detected: yes' || { - # On some systems, this is not successful when a - # cable is plugged but the interface has not been - # brought up previously. Bring the interface up and - # try again... - ip link set $iface up - ethtool $iface | grep -q 'Link detected: yes' || { - echo "ERROR: No link on the public network interface $iface" - mark_down $iface - continue - } + echo "ERROR: No link on the public network interface $iface" + mark_down $iface + continue } - mark_up $iface } + mark_up $iface ;; esac -- cgit