From 4db9367b971a57bf09c45fbe223054f0707c049e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 11 Sep 2016 14:34:22 +0200 Subject: sbin/detect-board: improve machine name detection Some kernels emit "Machine model:" instead of "Machine:". Also when the device tree is readable from /sys, use this instead of kernel messages. --- sbin/detect-board | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sbin/detect-board b/sbin/detect-board index c51a807..bb333b7 100755 --- a/sbin/detect-board +++ b/sbin/detect-board @@ -5,8 +5,10 @@ hw=$(grep '^Hardware' /proc/cpuinfo | cut -f2- -d: | tr 'A-Z' 'a-z') if [ -z "${hw##*device tree*}" ]; then if [ -e /proc/device-tree/model ]; then hw=$(tr 'A-Z' 'a-z' < /proc/device-tree/model) + elif [ -e /sys/firmware/devicetree/base/compatible ]; then + hw=$(tr '\000A-Z' '\012a-z' < /sys/firmware/devicetree/base/compatible | head -n 1) else - hw=$(dmesg|grep '^\([[][^]]*[]] \)\?Machine:' | cut -f3- -d: | tr 'A-Z' 'a-z') + hw=$(dmesg|grep '^\([[][^]]*[]] \)\?Machine\( model\)\?:' | cut -f3- -d: | tr 'A-Z' 'a-z') fi fi [ -n "$hw" ] || hw=$(grep -o '\' /proc/cmdline | cut -f2 -d= | tr 'A-Z' 'a-z') -- 1.7.12.1