allow for a 30s delay before eth0 comes up
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Sun, 8 Mar 2015 20:16:27 +0000 (21:16 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Sun, 8 Mar 2015 20:16:27 +0000 (21:16 +0100)
initscripts/pl_netinit

index 8dd8714..6fac990 100755 (executable)
@@ -283,9 +283,28 @@ if [[ -z "$ETH_DEVICE" ]]; then
     net_init_failed
 fi
 
     net_init_failed
 fi
 
+# within a systemd-driven startup, we often see this stage
+# triggered before the network is actually up
+# although of course we have network-online.target
+# as a requirement; go figure what systemd actually does..
+
+# in any case, let us try to work around that by allowing some delay
+# here
+
+TIMEOUT=30
+while true; do
+    /sbin/ifconfig $ETH_DEVICE >& /dev/null && continue
+    TIMEOUT=$(($TIMEOUT-1))
+    [ $TIMEOUT -le 0 ] && net_init_failed
+    sleep 1
+    echo $(date "+%H:%M:%S") " pl_netinit: waiting for device $ETH_DEVICE, ${TIMEOUT}s remaining "
+done
+
 
 # actually check to make sure ifconfig <device> succeeds
 
 # actually check to make sure ifconfig <device> succeeds
+
 /sbin/ifconfig $ETH_DEVICE up 2>&1 > /dev/null
 /sbin/ifconfig $ETH_DEVICE up 2>&1 > /dev/null
+
 if [[ $? -ne 0 ]]; then
     echo $(date "+%H:%M:%S") " pl_netinit: device $ETH_DEVICE does not exist, most likely"
     echo $(date "+%H:%M:%S") " pl_netinit: this CD does not have hardware support for your"
 if [[ $? -ne 0 ]]; then
     echo $(date "+%H:%M:%S") " pl_netinit: device $ETH_DEVICE does not exist, most likely"
     echo $(date "+%H:%M:%S") " pl_netinit: this CD does not have hardware support for your"