From 99dc81337d61258d906bea60fa89bb6762964126 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 9 Sep 2016 13:14:25 +0200 Subject: sbin/detect-board: detect the type of board The board name is useful to preset certain settings on embedded devices. This script tries to extract the same as found in the device tree or in the "machine" field of /proc/cpuinfo on older devices. It emits it on stdout, or nothing if nothing was found. --- .flxfiles | 1 + sbin/detect-board | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 sbin/detect-board diff --git a/.flxfiles b/.flxfiles index c31c451..876e541 100644 --- a/.flxfiles +++ b/.flxfiles @@ -28,6 +28,7 @@ sbin/initscript sbin/autoraid sbin/bootcmd sbin/bootmodules +sbin/detect-board sbin/fix-date sbin/listpart sbin/service diff --git a/sbin/detect-board b/sbin/detect-board new file mode 100755 index 0000000..c51a807 --- /dev/null +++ b/sbin/detect-board @@ -0,0 +1,16 @@ +#!/bin/sh + +# detect the board type +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) + else + hw=$(dmesg|grep '^\([[][^]]*[]] \)\?Machine:' | 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') +[ -n "$hw" ] || hw=$(grep '^machine' /proc/cpuinfo | cut -f2- -d: | tr 'A-Z' 'a-z') + +hw="${hw# }" +[ -z "$hw" ] || echo "$hw" -- 1.7.12.1