base-files: board.d: auto-set model id and name if /tmp/sysinfo is available
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 4 Dec 2015 11:06:57 +0000 (11:06 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 4 Dec 2015 11:06:57 +0000 (11:06 +0000)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 47752

package/base-files/files/lib/functions/uci-defaults-new.sh

index b9703830498b91826121145f5fec6e7b34a9e544..61aa6e168e2e46b5bf7e7067144b4b053acfd311 100755 (executable)
@@ -543,6 +543,16 @@ ucidef_set_rssimon() {
 board_config_update() {
        json_init
        [ -f ${CFG} ] && json_load "$(cat ${CFG})"
+
+       # auto-initialize model id and name if applicable
+       if ! json_is_a model object; then
+               json_select_object model
+                       [ -f "/tmp/sysinfo/board_name" ] && \
+                               json_add_string id "$(cat /tmp/sysinfo/board_name)"
+                       [ -f "/tmp/sysinfo/model" ] && \
+                               json_add_string name "$(cat /tmp/sysinfo/model)"
+               json_select ..
+       fi
 }
 
 board_config_flush() {