diff options
author | Vittorio Gambaletta (VittGam) <openwrt@vittgam.net> | 2016-05-06 05:23:43 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2016-05-11 17:06:54 +0200 |
commit | 40f933d7ffd2256ea44e3fa5a3202a0437426438 (patch) | |
tree | c63e743bbc68bf1b266a9f0e0eb646b16e134f9b /package/base-files/files | |
parent | a3531f1986d33eeff12175c804ebf7f62a9a8675 (diff) | |
download | upstream-40f933d7ffd2256ea44e3fa5a3202a0437426438.tar.gz upstream-40f933d7ffd2256ea44e3fa5a3202a0437426438.tar.bz2 upstream-40f933d7ffd2256ea44e3fa5a3202a0437426438.zip |
base-files: Fix config_generate when there are no switch VLANs or ports configured in board.json.
The json_select call fails when there are no roles or ports objects in board.json. "json_select .." must not be executed after failing.
This fixes for example LEDs not being set up in /etc/config/system.
Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
Diffstat (limited to 'package/base-files/files')
-rwxr-xr-x | package/base-files/files/bin/config_generate | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 03d1a36259..345393ca9c 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -143,55 +143,59 @@ generate_switch_vlans_ports() { # autogenerate vlans # - json_get_keys roles roles - json_select roles + if json_is_a roles array; then + json_get_keys roles roles + json_select roles - for role in $roles; do - json_select "$role" - json_get_vars ports - json_select .. + for role in $roles; do + json_select "$role" + json_get_vars ports + json_select .. - uci -q batch <<-EOF - add network switch_vlan - set network.@switch_vlan[-1].device='$switch' - set network.@switch_vlan[-1].vlan='$role' - set network.@switch_vlan[-1].ports='$ports' - EOF - done + uci -q batch <<-EOF + add network switch_vlan + set network.@switch_vlan[-1].device='$switch' + set network.@switch_vlan[-1].vlan='$role' + set network.@switch_vlan[-1].ports='$ports' + EOF + done - json_select .. + json_select .. + fi # # write port specific settings # - json_get_keys ports ports - json_select ports + if json_is_a ports array; then + json_get_keys ports ports + json_select ports + + for port in $ports; do + json_select "$port" + json_get_vars num + + if json_is_a attr object; then + json_get_keys attr attr + json_select attr + uci -q batch <<-EOF + add network switch_port + set network.@switch_port[-1].device='$switch' + set network.@switch_port[-1].port=$num + EOF + + for attr in $attr; do + json_get_var val "$attr" + uci -q set network.@switch_port[-1].$attr="$val" + done + json_select .. + fi + json_select .. + done - for port in $ports; do - json_select "$port" - json_get_vars num - - if json_is_a attr object; then - json_get_keys attr attr - json_select attr - uci -q batch <<-EOF - add network switch_port - set network.@switch_port[-1].device='$switch' - set network.@switch_port[-1].port=$num - EOF - - for attr in $attr; do - json_get_var val "$attr" - uci -q set network.@switch_port[-1].$attr="$val" - done - json_select .. - fi json_select .. - done - - json_select .. + fi } generate_switch() { |