#!/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: Armbian gathering informations about hardware ### END INIT INFO export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin collect_informations() { ifconfig | grep -q eth0 || (ifconfig eth0 up ; sleep 1) 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 } # set_io_scheduler do_initialisation() { # parse /etc/armbian-boards.conf and adjust everything : } # do_initialisation detect_board() { 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=120 || BlinkTime=10 (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}" /proc/irq/$(awk -F":" "/${GbE}/ {print \$1}" /proc/irq/$(awk -F":" "/${WiFi}/ {print \$1}" /proc/irq/$(awk -F":" "/${USB3}/ {print \$1}" /proc/irq/$(awk -F":" "/${GbE}/ {print \$1}" "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}" if [ -f ${Log} ]; then echo -e "\n\n\n$(date) $HARDWARE $ARCH $KERNELID $MACHINE $ID" >>${Log} else echo "$(date) $HARDWARE $ARCH $KERNELID $MACHINE $ID" >>${Log} chmod 755 ${Log} fi echo "${VERSION}" >>${Log} echo -e "\n### dmesg:\n" >>${Log} cat "${TMPFILE}" >>${Log} echo -e "\n### lsusb:" >>${Log} [ -f /boot/.verbose ] && USBVERBOSE="-v" || echo "" >>${Log} lsusb ${USBVERBOSE} 2>/dev/null >>${Log} echo -e "\n### lscpu:\n" >>${Log} lscpu >>${Log} echo -e "\n### cpuinfo:\n" >>${Log} cat /proc/cpuinfo >>${Log} echo -e "\n### meminfo:\n" >>${Log} cat /proc/meminfo >>${Log} echo -e "\n### interrupts:\n" >>${Log} cat /proc/interrupts >>${Log} echo -e "\n### ifconfig:\n" >>${Log} ifconfig >>${Log} echo -e "\n### df:\n" >>${Log} df -h >>${Log} } # log_hardware_info show_motd_warning() { cat > /etc/update-motd.d/90-warning < /var/run/machine.id if [ $? -ne 0 ]; then # most probably readonly fs. We'll try to warn the user. show_motd_warning "It seems the rootfs is readonly at the moment. Please check your SD card for errors" fi log_hardware_info # crash detection, enable verbose logging and disable it at clean shutdown echo "$(date "+%s") $HARDWARE $ARCH $KERNELID $MACHINE $ID $VERSION" >/boot/.verbose sync ;; query) # armbianmonitor mode -- only interested in hardware info collect_informations >/dev/null detect_board >/dev/null export HARDWARE ARCH KERNELID MACHINE ID VERSION ;; *stop*) # remove /boot/.verbose only if /boot/.force-verbose doesn't exist. # If our users demand verbose messages they get them if [ -f /boot/.verbose -a ! -f /boot/.force-verbose ]; then rm /boot/.verbose fi ;; esac