diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-03-03 12:47:02 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2013-03-03 12:47:02 +0000 |
commit | 80e2673444706596c4a8d207720fc9c01a0c9f30 (patch) | |
tree | 21cddf13501fcb2eb8357894879e5d780bc77a40 /target | |
parent | 2d8df9648d9ec96c5869b3e1bfdda6a1acb560c2 (diff) | |
download | master-187ad058-80e2673444706596c4a8d207720fc9c01a0c9f30.tar.gz master-187ad058-80e2673444706596c4a8d207720fc9c01a0c9f30.tar.bz2 master-187ad058-80e2673444706596c4a8d207720fc9c01a0c9f30.zip |
ramips: enhance user-space board detection
Similar to ar71xx, detect only once and cache the strings in
/tmp/sysinfo/model and /tmp/sysinfo/boardname.
Signed-off-by: Daniel Golle <dgolle@allnet.de>
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35850 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh | 2 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/lib/ramips.sh | 25 |
2 files changed, 24 insertions, 3 deletions
diff --git a/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh b/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh index e76418dad0..31ef5f8146 100644 --- a/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh +++ b/target/linux/ramips/base-files/lib/preinit/03_preinit_do_ramips.sh @@ -2,6 +2,8 @@ do_ramips() { . /lib/ramips.sh + + ramips_board_detect } boot_hook_add preinit_main do_ramips diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index 8ca3bfbc58..4687856e6f 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -1,9 +1,13 @@ #!/bin/sh # -# Copyright (C) 2010 OpenWrt.org +# Copyright (C) 2010-2013 OpenWrt.org # -ramips_board_name() { +RAMIPS_BOARD_NAME= +RAMIPS_MODEL= + + +ramips_board_detect() { local machine local name @@ -189,5 +193,20 @@ ramips_board_name() { ;; esac - echo $name + [ -z "$RAMIPS_BOARD_NAME" ] && RAMIPS_BOARD_NAME="$name" + [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="$machine" + + [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" + + echo "$RAMIPS_BOARD_NAME" > /tmp/sysinfo/board_name + echo "$RAMIPS_MODEL" > /tmp/sysinfo/model +} + +ramips_board_name() { + local name + + [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name) + [ -z "$name" ] && name="unknown" + + echo "$name" } |