From 6b315e08ad4fdb7529d379ca71a58465a1f1a23b Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 9 Nov 2024 21:16:12 +0100 Subject: [PATCH] arc-functions: rework sysinfo Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 124 +++++++++++++------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 2b9a9aab..1d6c2c95 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1089,67 +1089,69 @@ function sysinfo() { TEXT+="\n Ports with color \Z1\Zbred\Zn as DUMMY, color \Z2\Zbgreen\Zn has a Disk connected.\n" done fi - if [ $(lspci -d ::107 | wc -l) -gt 0 ]; then - TEXT+="\n SAS Controller:\n" - for PCI in $(lspci -d ::107 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done - fi - if [ $(lspci -d ::104 | wc -l) -gt 0 ]; then - TEXT+="\n Raid Controller:\n" - for PCI in $(lspci -d ::104 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done - fi - if [ $(lspci -d ::100 | wc -l) -gt 0 ]; then - TEXT+="\n SCSI Controller:\n" - for PCI in $(lspci -d ::100 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done - fi - if [[ -d "/sys/class/scsi_host" && $(ls -l /sys/class/scsi_host | grep usb | wc -l) -gt 0 ]]; then - TEXT+="\n USB Controller:\n" - for PCI in $(lspci -d ::c03 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - [ ${PORTNUM} -eq 0 ] && continue - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done - fi - if [[ -d "/sys/class/mmc_host" && $(ls -l /sys/class/mmc_host | grep mmc_host | wc -l) -gt 0 ]]; then - TEXT+="\n MMC Controller:\n" - for PCI in $(lspci -d ::805 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORTNUM=$(ls -l /sys/class/mmc_host | grep "${PCI}" | wc -l) - PORTNUM=$(ls -l /sys/block/mmc* | grep "${PCI}" | wc -l) - [ ${PORTNUM} -eq 0 ] && continue - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done - fi - if [ $(lspci -d ::108 | wc -l) -gt 0 ]; then - TEXT+="\n NVMe Controller:\n" - for PCI in $(lspci -d ::108 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://" | awk '{$1=""}1' | awk '{$1=$1};1') - PORT=$(ls -l /sys/class/nvme | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/nvme//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[N:${PORT}:" | wc -l) - TEXT+="\Zb ${NAME}\Zn\n Disks: ${PORTNUM}\n" - NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) - done + [ $(lspci -d ::104 2>/dev/null | wc -l) -gt 0 ] && TEXT+="\n RAID Controller:\n" + for PCI in $(lspci -d ::104 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORT=$(ls -l /sys/class/scsi_host 2>/dev/null | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) + PORTNUM=$(lsscsi -b 2>/dev/null | grep -v - | grep "\[${PORT}:" | wc -l) + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(lspci -d ::107 2>/dev/null | wc -l) -gt 0 ] && TEXT+="\nHBA Controller:\n" + for PCI in $(lspci -d ::107 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORT=$(ls -l /sys/class/scsi_host 2>/dev/null | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) + PORTNUM=$(lsscsi -b 2>/dev/null | grep -v - | grep "\[${PORT}:" | wc -l) + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(lspci -d ::100 2>/dev/null | wc -l) -gt 0 ] && TEXT+="\n SCSI Controller:\n" + for PCI in $(lspci -d ::100 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORTNUM=$(ls -l /sys/block/* 2>/dev/null | grep "${PCI}" | wc -l) + [ ${PORTNUM} -eq 0 ] && continue + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(lspci -d ::101 2>/dev/null | wc -l) -gt 0 ] && TEXT+="\n IDE Controller:\n" + for PCI in $(lspci -d ::101 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORTNUM=$(ls -l /sys/block/* 2>/dev/null | grep "${PCI}" | wc -l) + [ ${PORTNUM} -eq 0 ] && continue + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(ls -l /sys/class/scsi_host 2>/dev/null | grep usb | wc -l) -gt 0 ] && TEXT+="\n USB Controller:\n" + for PCI in $(lspci -d ::c03 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORT=$(ls -l /sys/class/scsi_host 2>/dev/null | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) + PORTNUM=$(lsscsi -b 2>/dev/null | grep -v - | grep "\[${PORT}:" | wc -l) + [ ${PORTNUM} -eq 0 ] && continue + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(ls -l /sys/class/mmc_host 2>/dev/null | grep mmc_host | wc -l) -gt 0 ] && TEXT+="\n MMC Controller:\n" + for PCI in $(lspci -d ::805 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORTNUM=$(ls -l /sys/block/mmc* 2>/dev/null | grep "${PCI}" | wc -l) + [ ${PORTNUM} -eq 0 ] && continue + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + [ $(lspci -d ::108 2>/dev/null | wc -l) -gt 0 ] && TEXT+="\n NVME Controller:\n" + for PCI in $(lspci -d ::108 2>/dev/null | awk '{print $1}'); do + NAME=$(lspci -s "${PCI}" 2>/dev/null | sed "s/\ .*://") + PORT=$(ls -l /sys/class/nvme 2>/dev/null | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/nvme//' | sort -n) + PORTNUM=$(lsscsi -b 2>/dev/null | grep -v - | grep "\[N:${PORT}:" | wc -l) + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) + done + if [ $(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep 'vmbus:acpi' | wc -l) -gt 0 ]; then + TEXT+="\n VMBUS Controller:\n" + NAME="vmbus:acpi" + PORTNUM=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep 'vmbus:acpi' | wc -l) + TEXT+="\Zb ${NAME}\Zn\nNumber: ${PORTNUM}\n" + NUMPORTS=$((${NUMPORTS} + ${PORTNUM})) fi TEXT+="\n Total Disks: \Zb${NUMPORTS}\Zn" [ -f "${TMP_PATH}/diag" ] && rm -f "${TMP_PATH}/diag" >/dev/null