base-files: config_generate did not handle setups with more than 1 switch properly
authorJohn Crispin <john@openwrt.org>
Mon, 27 Oct 2014 15:51:17 +0000 (15:51 +0000)
committerJohn Crispin <john@openwrt.org>
Mon, 27 Oct 2014 15:51:17 +0000 (15:51 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 43088

package/base-files/files/bin/config_generate

index 9a3b30065d8a2b36aa0be3f21d9b517fe6878a08..7bec566f3f7957ec915a8c77be4c110bc2aa9503 100755 (executable)
@@ -102,8 +102,6 @@ generate_switch() {
        json_select $key
        json_get_vars enable reset blinkrate cpu_port
 
-       [ -n "$cpu_port" ] || return
-
        uci -q batch <<EOF
 add network switch
 set network.@switch[-1].name='$key'
@@ -111,9 +109,10 @@ set network.@switch[-1].reset='$reset'
 set network.@switch[-1].enable_vlan='$enable'
 set network.@switch[-1].blinkrate='$blinkrate'
 EOF
-
-       json_get_keys vlans vlans
-       for vlan in $vlans; do generate_switch_vlan $1 $vlan $cpu_port; done
+       [ -n "$cpu_port" ] && {
+               json_get_keys vlans vlans
+               for vlan in $vlans; do generate_switch_vlan $1 $vlan $cpu_port; done
+       }
        json_select ..
        json_select ..
 }