base-files: add generic preinit script to extract board/model info from device-tree
authorFelix Fietkau <nbd@openwrt.org>
Thu, 16 Apr 2015 20:09:21 +0000 (20:09 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 16 Apr 2015 20:09:21 +0000 (20:09 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 45462

package/base-files/files/lib/preinit/90_sysinfo [new file with mode: 0644]

diff --git a/package/base-files/files/lib/preinit/90_sysinfo b/package/base-files/files/lib/preinit/90_sysinfo
new file mode 100644 (file)
index 0000000..42fd5b6
--- /dev/null
@@ -0,0 +1,10 @@
+do_sysinfo_generic() {
+       [ -d /proc/device-tree ] || return
+       mkdir -p /tmp/sysinfo
+       [ -e /tmp/sysinfo/board_name ] || \
+               echo "$(strings /proc/device-tree/compatible | head -1)" > /tmp/sysinfo/board_name
+       [ -e /tmp/sysinfo/model ] || \
+               echo "$(cat /proc/device-tree/model)" > /tmp/sysinfo/model
+}
+
+boot_hook_add preinit_main do_sysinfo_generic