]> 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 9dfbad65ed8c62de510f71c0c6ca5d43e6e76046..b8d46324193c31f9f75e7cb2ad19316f42fe685e 100644 (file)
@@ -124,10 +124,31 @@ case "${1}" in
                        echo -n "${DNS2}" > /var/ipfire/red/dns2
                        touch /var/ipfire/red/active
                        
+                       # Create route to default gateway
+                       ip route add ${GATEWAY} dev ${DEVICE}
+
                        boot_mesg "Setting up default gateway ${GATEWAY}..."
                        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
@@ -454,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
@@ -518,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