fixed for older systems, -M with dmidecode can be empty, so error messages should also show that.

This commit is contained in:
inxi-svn 2012-03-26 22:17:27 +00:00
parent e64687d88f
commit ef8f431ec4

67
inxi
View file

@ -4316,34 +4316,39 @@ get_machine_data()
separator=','
done
else
if [[ -n $( type -p dmidecode 2>/dev/null ) ]];then
if [[ -n $( type -p dmidecode 2>/dev/null ) && -n $( dmidecode 2>/dev/null ) ]];then
if [[ $B_ROOT == 'true' ]];then
for dmi_name in $dmi_names
do
# echo "$dmi_name" >&2
dmi_data=''
dmi_data=$( dmidecode -s $dmi_name | gawk '
BEGIN {
IGNORECASE=1
}
{
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
gsub(/,/, " ", $0)
# yes, there is a typo in a user data set, unknow
# Base Board Version|Base Board Serial Number
# Chassis Manufacturer|Chassis Version|Chassis Serial Number
# System manufacturer|System Product Name|System Version
# To Be Filled By O.E.M.
sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*/, "", $0)
gsub(/bios|acpi/, "", $0)
sub(/http:\/\/www.abit.com.tw\//, "Abit", $0)
gsub(/^ +| +$/, "", $0)
gsub(/ [ \t]+/, " ", $0)
print $0
}' )
array_string="$array_string$separator$dmi_data"
separator=','
done
# this handles very old systems, like Lenny 2.6.26, with dmidecode, but no data
if [[ -z $( dmidecode 2>/dev/null | grep -i 'no smbios or dmi' ) ]];then
array_string='dmidecode-no-smbios-dmi-data'
else
for dmi_name in $dmi_names
do
# echo "$dmi_name" >&2
dmi_data=''
dmi_data=$( dmidecode -s $dmi_name | gawk '
BEGIN {
IGNORECASE=1
}
{
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
gsub(/,/, " ", $0)
# yes, there is a typo in a user data set, unknow
# Base Board Version|Base Board Serial Number
# Chassis Manufacturer|Chassis Version|Chassis Serial Number
# System manufacturer|System Product Name|System Version
# To Be Filled By O.E.M.
sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*/, "", $0)
gsub(/bios|acpi/, "", $0)
sub(/http:\/\/www.abit.com.tw\//, "Abit", $0)
gsub(/^ +| +$/, "", $0)
gsub(/ [ \t]+/, " ", $0)
print $0
}' )
array_string="$array_string$separator$dmi_data"
separator=','
done
fi
else
array_string='dmidecode-non-root-user'
fi
@ -6935,8 +6940,12 @@ print_machine_data()
system_line="${C2}No /sys machine data. Try newer kernel, or install dmidecode.${CN}"
fi
# patch to dump all of above if dmidecode was data source and non root user
if [[ ${A_MACHINE_DATA[0]} == 'dmidecode-non-root-user' ]];then
system_line="${C2}You must be root to use dmidecode. Fallback mode from non-present /sys data.${CN}"
if [[ ${A_MACHINE_DATA[0]} == 'dmidecode-non-root-user' || ${A_MACHINE_DATA[0]} == 'dmidecode-no-smbios-dmi-data' ]];then
if [[ ${A_MACHINE_DATA[0]} == 'dmidecode-non-root-user' ]];then
system_line="${C2}You must be root to use dmidecode. Fallback mode from non-present /sys data.${CN}"
elif [[ ${A_MACHINE_DATA[0]} == 'dmidecode-no-smbios-dmi-data' ]];then
system_line="${C2}No dmidecode data available for system. Fallback mode from non-present /sys data.${CN}"
fi
mobo_line=''
bios_line=''
chassis_line=''