]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/initscripts/networking/red
networking red: add delay to wait for carrier
[ipfire-2.x.git] / src / initscripts / networking / red
index 00e739cab14aedff772b88fc6fe9bc003897e29a..b8d46324193c31f9f75e7cb2ad19316f42fe685e 100644 (file)
@@ -131,6 +131,24 @@ case "${1}" in
                        ip route add default via ${GATEWAY} dev ${DEVICE}
                        evaluate_retval
                        
+                       # has carrier ?
+                       if [ ! "$(</sys/class/net/${DEVICE}/carrier)" = "1" ]; then
+                               boot_mesg -n "Wait for carrier on ${DEVICE} "
+                               for (( i=30; i>1; i-- )) do
+                                       if [ "$(</sys/class/net/${DEVICE}/carrier)" = "1" ]; then
+                                               break;
+                                       fi
+                                       boot_mesg -n "."
+                                       sleep 2
+                               done
+                               boot_mesg ""
+                               if [ ! "$(</sys/class/net/${DEVICE}/carrier)" = "1" ]; then
+                                       echo_failure
+                               else
+                                       echo_ok
+                               fi
+                       fi
+
                        run_subdir ${rc_base}/init.d/networking/red.up/
 
                        # Configure aliases only if red static
@@ -457,6 +475,8 @@ case "${1}" in
                ;;
 
        stop)
+               rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
+
                if [ "$TYPE" == "STATIC" ]; then
                        boot_mesg "Stopping default gateway ${GATEWAY}..."
                        ip route del default via ${GATEWAY} >/dev/null 2>&1
@@ -521,7 +541,6 @@ case "${1}" in
                ## Disable vnstat collection
                /usr/bin/vnstat -u -i ${DEVICE} -r --disable > /dev/null 2>&1
 
-               rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
                exit 0;
                ;;
 esac