heads/initrd/bin/oem-system-info-xx30
gaspar-ilom e647e20b4a
refactor printing of battery state to confuse less users
only print the battery manufacturer in case there is more than one battery, otherwise omit it

make the code more readable for non-bash developers

extract common functions

Signed-off-by: gaspar-ilom <gasparilom@riseup.net>
2025-02-26 23:42:02 +01:00

55 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# System Info
BOARD_NAME=${CONFIG_BOARD_NAME:-${CONFIG_BOARD}}
MAIN_MENU_TITLE="${BOARD_NAME} | Extended System Information"
export BG_COLOR_MAIN_MENU="normal"
. /etc/functions
. /etc/gui_functions
. /etc/luks-functions
. /tmp/config
TRACE_FUNC
battery_status="$(print_battery_state)"
usb="$(lsusb)"
pci="$(lspci)"
camera="None|Unknown"
if echo "$usb" | grep -s "04f2:b2db"; then camera="Yes"; fi # t430
if echo "$usb" | grep -s "04f2:b2ea"; then camera="Yes"; fi # x230
if echo "$usb" | grep -s "5986:02d2"; then camera="Yes"; fi # x230
bluetooth="None|Unknown"
if echo "$usb" | grep -s "0a5c:21e6"; then bluetooth="BCM20702 Bluetooth 4.0"; fi
wifi="None|Unknown"
if echo "$pci" | grep -s "8086:0085"; then wifi="Intel Centrino Advanced-N 6205"; fi
if echo "$pci" | grep -s "168c:0034"; then wifi="Qualcomm Atheros AR9462"; fi
if echo "$pci" | grep -s "168c:0030"; then wifi="Qualcomm Atheros AR93xx"; fi
mouse="None|Unknown"
if grep -s "TouchPad" /sys/class/input/mouse*/device/name; then mouse="Synaptic TouchPad"; fi
known_devices="$(echo -e "Camera: ${camera}\nBluetooth: ${bluetooth}\nWifi: ${wifi}\nMouse: ${mouse}")"
echo -e "PCI USB" >/tmp/devices_usb_pci
for l in $(seq 16); do
row1="$(echo "$pci" | sed -n ${l}p | cut -d " " -f 5)"
row2="$(echo "$usb" | sed -n ${l}p | cut -d " " -f 6)"
row3="$(echo "$known_devices" | sed -n ${l}p)"
echo "${row1} | ${row2} ${row3}" >>/tmp/devices_usb_pci
done
memtotal=$(cat /proc/meminfo | grep 'MemTotal' | tr -s ' ' | cut -f2 -d ' ')
memtotal=$((${memtotal} / 1024 / 1024 + 1))
cpustr=$(cat /proc/cpuinfo | grep 'model name' | uniq | sed -r 's/\(R\)//;s/\(TM\)//;s/CPU //;s/model name.*: //')
kernel=$(uname -s -r)
FB_OPTIONS=""
if whiptail --version | grep "fbwhiptail"; then FB_OPTIONS="--text-size 12"; fi
whiptail_type $BG_COLOR_MAIN_MENU $FB_OPTIONS --title 'System Info' \
--msgbox "${BOARD_NAME}\nFW_VER: ${FW_VER}\nKernel: ${kernel}\nCPU: ${cpustr} RAM: ${memtotal} GB $battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')\n\n$(cat /tmp/devices_usb_pci)" 0 80