#! /bin/bash ### BEGIN INIT INFO # Provides: armhwinfo # Required-Start: # Required-Stop: glibc # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Get some info about hardware for some ARM single board computers and set some basic things ### END INIT INFO # Immediately exit if not called from init system at startup if [ "X$1" != "Xstart" ]; then exit 1 fi TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX) trap "rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15 dmesg >"${TMPFILE}" SERVER_IP=$(hostname -I) CORES=$(grep -c ^processor /proc/cpuinfo) MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' /sys/block/$i/queue/scheduler; echo -e "[\e[0;32m ok \x1B[0m] Setting cfg I/O scheduler for $i" # solid state drives elif [ "$ROTATE" = 0 ]; then echo noop > /sys/block/$i/queue/scheduler; echo -e "[\e[0;32m ok \x1B[0m] Setting noop I/O scheduler for $i" fi done if [ "$ARCH" = "armv7l" ]; then if [ $HARDWARE = "ODROID-XU3" ]; then ID="Odroid XU4" fi if [ $HARDWARE = "Marvell" ]; then ID="Clearfog" fi if [ $HARDWARE = "gs705a" ]; then ID="Guitar" fi if [ $HARDWARE = "sun4i" ] || [ $HARDWARE = "Allwinner" ]; then ID="Cubieboard" fi if [ $HARDWARE = "sun7i" ] || [ $HARDWARE = "Allwinner" ]; then # redistribute irq to dedicated core if [ "$INTERUPT" != "" ] && [ "$CORES" -gt 1 ]; then echo 2 >/proc/irq/$(awk -F":" '/eth0/ {print $1}' /sys/class/leds/green_led/trigger echo 200 >/sys/class/leds/green_led/delay_off echo 200 >/sys/class/leds/green_led/delay_on [ -f "/root/.not_logged_in_yet" ] && BlinkTime=30 || BlinkTime=3 (sleep ${BlinkTime} && echo none >/sys/class/leds/green_led/trigger) & fi # redistribute USB irqs to dedicated cores echo 2 >/proc/irq/$(awk -F":" "/${USB1}/ {print \$1}" /proc/irq/$(awk -F":" "/${USB2}/ {print \$1}" /dev/null # OPi One if [ "$TERMINUS" != "" ]; then # Ethernet irqs on cpu3 echo 8 >/proc/irq/$(awk -F":" "/${GbE}/ {print \$1}" /proc/irq/$(awk -F":" "/${WiFi}/ {print \$1}" /proc/irq/$(awk -F":" "/${USB3}/ {print \$1}" /var/run/machine.id export HARDWARE DISTROID DISTROCODE ARCH KERNELID MACHINE ID