Improve the monitor event test for ethernet interfaces (link detection).
authorMichael Adam <obnox@samba.org>
Wed, 10 Dec 2008 21:27:36 +0000 (22:27 +0100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 11 Dec 2008 22:19:23 +0000 (09:19 +1100)
On some systems, the ethtool link detection is not successful when a
cable is plugged but the interface has not been brought up previously.
This improves the test by bringing the interface up (without checking
for success here) and trying the ethtool test again afterwards.

Michael

config/events.d/10.interface

index 01302ba67e0c2d7255f253be539e973ca29247b0..298f3e85c853c3dafe3915e986ede9dbfd58fc91 100755 (executable)
@@ -158,8 +158,15 @@ case $cmd in
            *)
                [ -z "$IFACE" ] || {
                    /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
-                       echo "ERROR: No link on the public network interface $IFACE"
-                       exit 1
+                       # 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...
+                       /sbin/ip link set $IFACE up
+                       /usr/sbin/ethtool $IFACE | grep -q 'Link detected: yes' || {
+                           echo "ERROR: No link on the public network interface $IFACE"
+                           exit 1
+                       }
                    }
                }
                ;;