cleaner version of the udhcp script
[openwrt.git] / package / base-files / files / lib / network / config.sh
index 8a59687..c5334cb 100755 (executable)
@@ -24,6 +24,7 @@ find_config() {
 }
 
 scan_interfaces() {
+       local cfgfile="$1"
        local mode iftype iface ifname device
        interfaces=
        config_cb() {
@@ -50,7 +51,7 @@ scan_interfaces() {
                        ;;
                esac
        }
-       config_load network
+       config_load "${cfgfile:-network}"
 }
 
 add_vlan() {
@@ -74,6 +75,8 @@ prepare_interface() {
        # to create any interfaces here. The scripts have already done that, otherwise
        # the bridge interface wouldn't exist.
        [ "$iface" = "br-$config" ] && return 0;
+
+       [ -f "$iface" ] && return 0;
        
        ifconfig "$iface" 2>/dev/null >/dev/null && {
                # make sure the interface is removed from any existing bridge and brought down
@@ -83,6 +86,7 @@ prepare_interface() {
 
        # Setup VLAN interfaces
        add_vlan "$iface"
+       ifconfig "$iface" 2>/dev/null >/dev/null || return 0
 
        # Setup bridging
        config_get iftype "$config" type
@@ -148,7 +152,7 @@ setup_interface() {
                        config_get bcast "$config" broadcast
                        
                        [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
-                       [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" inet6 add "$ip6addr" 
+                       [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
                        [ -z "$gateway" ] || $DEBUG route add default gw "$gateway"
                        [ -z "$bcast" ] || $DEBUG ifconfig "$iface" broadcast "$bcast"
                        [ -z "$dns" -o -f /tmp/resolv.conf.auto ] || {
This page took 0.026907 seconds and 4 git commands to generate.