- uci -q batch <<EOF
-add network switch
-set network.@switch[-1].name='$key'
-set network.@switch[-1].reset='$reset'
-set network.@switch[-1].enable_vlan='$enable'
-set network.@switch[-1].blinkrate='$blinkrate'
-EOF
-
- if [ -n "$cpu_port" ]; then
- json_get_keys vlans vlans
- for vlan in $vlans; do generate_switch_vlan $1 $vlan $cpu_port; done
- elif json_is_a ports array; then
- calculate_switch_vlans $1
+ uci -q batch <<-EOF
+ add network switch
+ set network.@switch[-1].name='$key'
+ set network.@switch[-1].reset='$reset'
+ set network.@switch[-1].enable_vlan='$enable'
+ set network.@switch[-1].blinkrate='$blinkrate'
+ EOF
+
+ generate_switch_vlans_ports "$1"
+
+ json_select ..
+ json_select ..
+}
+
+
+generate_static_system() {
+ uci -q batch <<-EOF
+ delete system.@system[0]
+ add system system
+ set system.@system[-1].hostname='OpenWrt'
+ set system.@system[-1].timezone='UTC'
+ set system.@system[-1].ttylogin='0'
+ set system.@system[-1].log_size='64'
+ set system.@system[-1].urandom_seed='0'
+
+ delete system.ntp
+ set system.ntp='timeserver'
+ set system.ntp.enabled='1'
+ set system.ntp.enable_server='0'
+ add_list system.ntp.server='0.openwrt.pool.ntp.org'
+ add_list system.ntp.server='1.openwrt.pool.ntp.org'
+ add_list system.ntp.server='2.openwrt.pool.ntp.org'
+ add_list system.ntp.server='3.openwrt.pool.ntp.org'
+ EOF
+
+ if json_is_a system object; then
+ json_select system
+ local hostname
+ if json_get_var hostname hostname; then
+ uci -q set "system.@system[-1].hostname=$hostname"
+ fi
+
+ if json_is_a ntpserver array; then
+ local keys key
+ json_get_keys keys ntpserver
+ json_select ntpserver
+ uci -q delete "system.ntp.server"
+
+ for key in $keys; do
+ local server
+ if json_get_var server "$key"; then
+ uci -q add_list "system.ntp.server=$server"
+ fi
+ done
+ json_select ..
+ fi
+ json_select ..