cleaner version of the udhcp script
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 14 May 2007 08:37:57 +0000 (08:37 +0000)
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 14 May 2007 08:37:57 +0000 (08:37 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7222 3c298f89-4303-0410-b956-a3cf2f4a3e73

package/base-files/files/usr/share/udhcpc/default.script

index f209920..76ba746 100755 (executable)
@@ -28,15 +28,17 @@ case "$1" in
                netmask ${subnet:-255.255.255.0} \
                broadcast ${broadcast:-+}
 
                netmask ${subnet:-255.255.255.0} \
                broadcast ${broadcast:-+}
 
-               if [ "$router" != "$(route -n | grep '^0.0.0.0' | grep $interface | awk '{ print $2 }')" ] ; then
-                       echo "deleting routers"
-                       while route del default gw 0.0.0.0 dev $interface >&- 2>&- ; do :; done
-                                       
+               [ "$router"] && {
                        for i in $router ; do
                                echo "adding router $i"
                                route add default gw $i dev $interface
                        for i in $router ; do
                                echo "adding router $i"
                                route add default gw $i dev $interface
+                               valid="$valid|$i"
+
                        done
                        done
-               fi
+
+                       echo "deleting old routes"
+                       $(route -n | awk '/^0.0.0.0\W{9}('$valid')\W/ {next} /^0.0.0.0/ {print "route del -net "$1" gw "$2";"}')
+               }
                
                [ -n "$dns" ] && {
                        echo -n > $RESOLV_CONF
                
                [ -n "$dns" ] && {
                        echo -n > $RESOLV_CONF
This page took 0.026192 seconds and 4 git commands to generate.