base-files: always set proto passed to _ucidef_set_interface()
[openwrt/staging/dedeckeh.git] / package / base-files / files / lib / functions / uci-defaults.sh
index 3500d49baabd06bdd0dec568dea32c942118138a..7cc63ffc80ce8d6a3009b0f963ad4f0d3cec1762 100755 (executable)
@@ -35,7 +35,7 @@ _ucidef_set_interface() {
        json_select_object "$name"
        json_add_string ifname "$iface"
 
-       if ! json_is_a protocol string; then
+       if ! json_is_a protocol string || [ -n "$proto" ]; then
                case "$proto" in
                        static|dhcp|none|pppoe) : ;;
                        *)
@@ -619,6 +619,26 @@ ucidef_add_gpio_switch() {
        json_select ..
 }
 
+ucidef_set_hostname() {
+       local hostname="$1"
+
+       json_select_object system
+               json_add_string hostname "$hostname"
+       json_select ..
+}
+
+ucidef_set_ntpserver() {
+       local server
+
+       json_select_object system
+               json_select_array ntpserver
+                       for server in "$@"; do
+                               json_add_string "" "$server"
+                       done
+               json_select ..
+       json_select ..
+}
+
 board_config_update() {
        json_init
        [ -f ${CFG} ] && json_load "$(cat ${CFG})"