base-files: add board.d support for bridge device
[openwrt/staging/rmilecki.git] / package / base-files / files / lib / functions / uci-defaults.sh
index 7fa328ac20aaf82fb92a9fde131c6c70c681e92c..39bbeda24c17e4703863f993b1f355981a8a50c5 100755 (executable)
@@ -68,6 +68,12 @@ ucidef_set_model_name() {
        json_select ..
 }
 
+ucidef_set_compat_version() {
+       json_select_object system
+       json_add_string compat_version "${1:-1.0}"
+       json_select ..
+}
+
 ucidef_set_interface_lan() {
        ucidef_set_interface "lan" ifname "$1" protocol "${2:-static}"
 }
@@ -84,6 +90,10 @@ ucidef_set_interfaces_lan_wan() {
        ucidef_set_interface_wan "$wan_if"
 }
 
+ucidef_set_bridge_device() {
+       json_add_string bridge "${1:switch0}"
+}
+
 _ucidef_add_switch_port() {
        # inherited: $num $device $need_tag $want_untag $role $index $prev_role
        # inherited: $n_cpu $n_ports $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5
@@ -182,6 +192,19 @@ _ucidef_finish_switch_roles() {
        done
 }
 
+ucidef_set_ar8xxx_switch_mib() {
+       local name="$1"
+       local type="$2"
+       local interval="$3"
+
+       json_select_object switch
+               json_select_object "$name"
+                       json_add_int ar8xxx_mib_type $type
+                       json_add_int ar8xxx_mib_poll_interval $interval
+               json_select ..
+       json_select ..
+}
+
 ucidef_add_switch() {
        local name="$1"; shift
        local port num role device index need_tag prev_role
@@ -294,6 +317,14 @@ ucidef_set_interface_macaddr() {
        ucidef_set_interface "$network" macaddr "$macaddr"
 }
 
+ucidef_set_label_macaddr() {
+       local macaddr="$1"
+
+       json_select_object system
+               json_add_string label_macaddr "$macaddr"
+       json_select ..
+}
+
 ucidef_add_atm_bridge() {
        local vpi="$1"
        local vci="$2"
@@ -383,7 +414,7 @@ ucidef_set_led_gpio() {
 }
 
 ucidef_set_led_ide() {
-       _ucidef_set_led_trigger "$1" "$2" "$3" ide-disk
+       _ucidef_set_led_trigger "$1" "$2" "$3" disk-activity
 }
 
 ucidef_set_led_netdev() {
@@ -442,11 +473,13 @@ ucidef_set_led_switch() {
        local trigger_name="$4"
        local port_mask="$5"
        local speed_mask="$6"
+       local mode="$7"
 
        _ucidef_set_led_common "$1" "$2" "$3"
 
        json_add_string trigger "$trigger_name"
        json_add_string type switch
+       json_add_string mode "$mode"
        json_add_string port_mask "$port_mask"
        json_add_string speed_mask "$speed_mask"
        json_select ..
@@ -461,6 +494,7 @@ _ucidef_set_led_timer() {
 
        _ucidef_set_led_common "$1" "$2" "$3"
 
+       json_add_string type "$trigger_name"
        json_add_string trigger "$trigger_name"
        json_add_int delayon "$delayon"
        json_add_int delayoff "$delayoff"
@@ -549,7 +583,7 @@ ucidef_add_gpio_switch() {
        json_select_object gpioswitch
                json_select_object "$cfg"
                        json_add_string name "$name"
-                       json_add_int pin "$pin"
+                       json_add_string pin "$pin"
                        json_add_int default "$default"
                json_select ..
        json_select ..
@@ -591,6 +625,5 @@ board_config_update() {
 }
 
 board_config_flush() {
-       json_dump -i > /tmp/.board.json
-       mv /tmp/.board.json ${CFG}
+       json_dump -i -o ${CFG}
 }