Report missing hw-info data

* Show UNKNOWN for missing DMI variables
* Suppress errors for systems w/out sound cards
* Suppress errors for glxinfo
* Keep revision numbers for network devices
This commit is contained in:
2Shirt 2018-05-21 20:18:13 -06:00
parent 25d34e5ace
commit e6b7cc602b

View file

@ -15,26 +15,36 @@ function print_in_columns() {
printf ' %-18s%s\n' "$label" "$value" printf ' %-18s%s\n' "$label" "$value"
} }
function print_dmi_value() {
name="$1"
file="/sys/devices/virtual/dmi/id/$2"
value="UNKNOWN"
if [[ -e "$file" ]]; then
value="$(cat "$file")"
fi
print_in_columns "$name: $value"
}
# System # System
echo -e "${BLUE}System Information${CLEAR}" echo -e "${BLUE}System Information${CLEAR}"
echo " Vendor: $(cat /sys/devices/virtual/dmi/id/sys_vendor)" print_dmi_value "Vendor" "sys_vendor"
echo " Name: $(cat /sys/devices/virtual/dmi/id/product_name)" print_dmi_value "Name" "product_name"
echo " Serial: $(cat /sys/devices/virtual/dmi/id/product_serial)" print_dmi_value "Serial" "product_serial"
echo "" echo ""
# Motherboard # Motherboard
echo -e "${BLUE}Motherboard${CLEAR}" echo -e "${BLUE}Motherboard${CLEAR}"
echo " Vendor: $(cat /sys/devices/virtual/dmi/id/board_vendor)" print_dmi_value "Vendor" "board_vendor"
echo " Name: $(cat /sys/devices/virtual/dmi/id/board_name)" print_dmi_value "Name" "board_name"
echo " Version: $(cat /sys/devices/virtual/dmi/id/board_version)" print_dmi_value "Version" "board_version"
echo " Serial: $(cat /sys/devices/virtual/dmi/id/board_serial)" print_dmi_value "Serial" "board_serial"
echo "" echo ""
# BIOS # BIOS
echo -e "${BLUE}BIOS${CLEAR}" echo -e "${BLUE}BIOS${CLEAR}"
echo " Vendor: $(cat /sys/devices/virtual/dmi/id/bios_vendor)" print_dmi_value "Vendor" "bios_vendor"
echo " Version: $(cat /sys/devices/virtual/dmi/id/bios_version)" print_dmi_value "Version" "bios_version"
echo " Release Date: $(cat /sys/devices/virtual/dmi/id/bios_date)" print_dmi_value "Release Date" "bios_date"
echo "" echo ""
# Processor # Processor
@ -69,21 +79,25 @@ lspci | grep 'VGA' | sed -r 's/^.*:/ Device: /' \
| sed 's/Intel Corporation/Intel/' \ | sed 's/Intel Corporation/Intel/' \
| sed 's/Generation Core Processor Family/Gen/' \ | sed 's/Generation Core Processor Family/Gen/' \
| sed 's/Integrated Graphics Controller.*/iGPU/' | sed 's/Integrated Graphics Controller.*/iGPU/'
glxinfo | grep 'OpenGL renderer' | sed -r 's/^.*:/ OpenGL Renderer: /' \ glxinfo 2>/dev/null | grep 'OpenGL renderer' | sed -r 's/^.*:/ OpenGL Renderer: /' \
| sed 's/Mesa DRI //' | sed 's/Mesa DRI //'
echo "" echo ""
# Audio # Audio
echo -e "${BLUE}Audio${CLEAR}" echo -e "${BLUE}Audio${CLEAR}"
while read -r line; do while read -r line; do
print_in_columns "$line" if [[ "$line" =~ .*no.soundcards.found.* ]]; then
done <<< $(aplay -l | grep '^card' | sed -r 's/.*\[(.*)\].*\[(.*)\].*/\1: \2/') echo " No soundcards found"
else
print_in_columns "$line"
fi
done <<< $(aplay -l 2>&1 | grep -Ei '(^card|no soundcards found)' | sed -r 's/.*\[(.*)\].*\[(.*)\].*/\1: \2/')
echo "" echo ""
# Network # Network
echo -e "${BLUE}Network${CLEAR}" echo -e "${BLUE}Network${CLEAR}"
lspci | grep -Ei '(ethernet|network|wireless|wifi)' \ lspci | grep -Ei '(ethernet|network|wireless|wifi)' \
| sed -r 's/.*: (.*) \(.*$/ \1/' | sed -r 's/.*: (.*)$/ \1/'
echo "" echo ""
# Drives # Drives