build/scripts/armhwinfo

64 lines
2.1 KiB
Text
Raw Normal View History

2014-10-08 07:39:24 +02:00
#! /bin/sh
### BEGIN INIT INFO
# Provides: armhwinfo
# Required-Start:
2014-10-12 09:20:35 +02:00
# Required-Stop: glibc
2014-10-12 07:27:38 +02:00
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2014-10-08 07:39:24 +02:00
# Short-Description: Get some info about hardware for some ARM boards
### END INIT INFO
CORES=$(grep -c ^processor /proc/cpuinfo)
MEMTOTAL=$(awk 'BEGIN { printf "%.0f\n", '$(grep MemTotal /proc/meminfo | awk '{print $2}')'/1024/1024 }')
ARCH=$(lscpu | grep Architecture | awk '{print $2}')
RTC=$(dmesg | grep rtc0 | awk '{print $(NF)}')
HB_PCI=$(dmesg | grep '16c3:abcd')
HARDWARE=$(cat /proc/cpuinfo | grep Hardware | awk '{print $3}')
GMAC=$(dmesg | grep "sunxi_gmac-0:00")
2014-10-12 07:27:38 +02:00
case "$1" in
start)
2014-10-08 07:39:24 +02:00
# ARM
if [ "$ARCH" = "armv7l" ]; then
if [ "$HARDWARE" = "sun7i" ]; then
ID="Allwinner"
if [ "$MEMTOTAL" = 2 ]; then
ID="Cubietruck"
else
if [ -n "$GMAC" ]; then
ID="Banana PI"
else
ID="Cubieboard"
fi
fi
fi
if [ "$HARDWARE" = "Freescale" ]; then
ID="Freescale"
if [ "$MEMTOTAL" = 2 ]; then
ID="Cubox i4"
else
if [ "$HB_PCI" != "" ]; then
ID="HB i2eX"
else
if [ "$RTC" = "rtc0" ]; then
ID="Cubox i2eX"
else
ID="HB i2"
if [ "$CORES" = 1 ]; then ID="HB i1"; fi
fi
fi
fi
fi
fi
echo "" > /var/run/motd.dynamic
toilet -f standard -F metal "$ID" >> /var/run/motd.dynamic
2014-10-12 07:27:38 +02:00
echo "" >> /var/run/motd.dynamic
;;
*)
## If no parameters are given, print which are avaiable.
echo "Usage: $0 {start}"
exit 1
;;
esac