ignore the bridge option if brctl is not available
[openwrt.git] / package / base-files / files / lib / network / config.sh
index 845b33e..e68223e 100755 (executable)
@@ -88,15 +88,23 @@ setup_interface() {
        # Setup bridging
        case "$iftype" in
                bridge)
-                       ifconfig "$iface" up 2>/dev/null >/dev/null
-                       ifconfig "br-$config" 2>/dev/null >/dev/null && {
-                               $DEBUG brctl addif "br-$config" "$iface"
-                               return 0
-                       } || {
-                               $DEBUG brctl addbr "br-$config"
-                               $DEBUG brctl setfd "br-$config" 0
-                               $DEBUG brctl addif "br-$config" "$iface"
-                               iface="br-$config"
+                       [ -x /usr/sbin/brctl ] && {
+                               ifconfig "$iface" up 2>/dev/null >/dev/null
+                               ifconfig "br-$config" 2>/dev/null >/dev/null && {
+                                       $DEBUG brctl addif "br-$config" "$iface"
+                                       return 0
+                               } || {
+                                       $DEBUG brctl addbr "br-$config"
+                                       $DEBUG brctl setfd "br-$config" 0
+                                       $DEBUG brctl addif "br-$config" "$iface"
+                                       iface="br-$config"
+                               
+                                       # need to bring up the bridge and wait a second for 
+                                       # it to switch to the 'forwarding' state, otherwise
+                                       # it will lose its routes...
+                                       ifconfig "$iface" up
+                                       sleep 1
+                               }
                        }
                ;;
        esac
@@ -117,12 +125,12 @@ setup_interface() {
                        config_get gateway "$config" gateway
                        config_get dns "$config" dns
                        
-                       $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
-                       $DEBUG ifconfig "$iface" inet6 add "$ip6addr" 
+                       [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
+                       [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" inet6 add "$ip6addr" 
                        [ -z "$gateway" ] || route add default gw "$gateway"
-                       [ -z "$dns" -o -f /tmp/resolv.conf ] || {
+                       [ -z "$dns" -o -f /tmp/resolv.conf.auto ] || {
                                for ns in $dns; do
-                                       echo "nameserver $ns" >> /tmp/resolv.conf
+                                       echo "nameserver $ns" >> /tmp/resolv.conf.auto
                                done
                        }
 
This page took 0.022434 seconds and 4 git commands to generate.