base-files: implement ucidef_set_hostname(), ucidef_set_ntpserver()
authorJo-Philipp Wich <jo@mein.io>
Wed, 3 May 2017 11:32:33 +0000 (13:32 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 3 May 2017 11:47:57 +0000 (13:47 +0200)
Commit 2036ae4 (base-files: support hostname and ntp servers through board.d)
was supposed to implement these procedures but lacked the required changes
to uci-defaults.sh.

Add the missing procedures now to fix config generation on targets relying
on hostname or NTP server presetting.

Fixes FS#754.

Reported-by: Cristian Morales Vega <cristian@samknows.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
package/base-files/files/lib/functions/uci-defaults.sh

index 9fad1896ec93c2de40de52837aab7fc28688e059..f5e8ebefbd83cae545e007ce90b73c9512b1b13f 100755 (executable)
@@ -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})"