brcm47xx: rework model detection
[openwrt/openwrt.git] / target / linux / brcm47xx / base-files / lib / preinit / 01_sysinfo
1 #!/bin/sh
2
3 do_sysinfo_brcm47xx() {
4 local boardtype="$(nvram get boardtype)"
5 local boardnum="$(nvram get boardnum)"
6 local model="$(sed -ne 's/^machine[ \t]*: //p' /proc/cpuinfo)"
7
8 [ -z "$model" ] && model="unknown"
9 [ -z "$boardtype" ] && boardtype="unknown"
10
11 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
12 echo "$boardtype${boardnum:+:$boardnum}" > /tmp/sysinfo/board_name
13 echo "$model" > /tmp/sysinfo/model
14 }
15
16 boot_hook_add preinit_main do_sysinfo_brcm47xx