mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
(Change Version)
Added fall through /etc/lsb-release test to update distro data tests. This adds one more failsafe test to future proof the stuff against id failures. I tried to also use the standard lsb_release function but for some reason when it's run inside inxi and sent to awk it gets incredibly slowed down. This is odd, since that command usually runs quite fast in shell. But it's too slow as is for now to use, it makes everything hang. Maybe later I'll add an option to trigger it or something.
This commit is contained in:
parent
c8464427bd
commit
f298a77680
47
inxi
47
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.5.2
|
#### version: 0.5.3
|
||||||
#### Date: November 10 2008
|
#### Date: November 10 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||||
|
@ -1004,6 +1004,8 @@ get_distro_data()
|
||||||
{
|
{
|
||||||
local i='' distro='' distro_file='' a_distro_glob=''
|
local i='' distro='' distro_file='' a_distro_glob=''
|
||||||
|
|
||||||
|
|
||||||
|
# please reference this python thread: http://bugs.python.org/issue1322
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
cd /etc
|
cd /etc
|
||||||
a_distro_glob=(*[-_]{release,version})
|
a_distro_glob=(*[-_]{release,version})
|
||||||
|
@ -1044,11 +1046,51 @@ get_distro_data()
|
||||||
print
|
print
|
||||||
}' "/etc/${distro_file}" )
|
}' "/etc/${distro_file}" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#distro} -gt 80 && $B_HANDLE_CORRUPT_DATA != 'true' ]];then
|
if [[ ${#distro} -gt 80 && $B_HANDLE_CORRUPT_DATA != 'true' ]];then
|
||||||
distro="${RED}/etc/${distro_file} corrupted, use -C to override${NORMAL}"
|
distro="${RED}/etc/${distro_file} corrupted, use -% to override${NORMAL}"
|
||||||
fi
|
fi
|
||||||
## note: would like to actually understand the method even if it's not used
|
## note: would like to actually understand the method even if it's not used
|
||||||
# : ${distro:=Unknown distro o_O}
|
# : ${distro:=Unknown distro o_O}
|
||||||
|
## test for /etc/lsb-release as a backup in case of failure
|
||||||
|
if [[ -f /etc/lsb-release && -z $distro ]];then
|
||||||
|
distro=$( gawk -F '=' '
|
||||||
|
{ IGNORECASE=1 }
|
||||||
|
/^DISTRIB_ID/ {
|
||||||
|
gsub(/^ +| +$/, "", $NF)
|
||||||
|
distroId = $NF
|
||||||
|
}
|
||||||
|
/^DISTRIB_RELEASE/ {
|
||||||
|
gsub(/^ +| +$/, "", $NF)
|
||||||
|
distroRelease = $NF
|
||||||
|
}
|
||||||
|
/^DISTRIB_CODENAME/ {
|
||||||
|
gsub(/^ +| +$/, "", $NF)
|
||||||
|
distroCodename = $NF
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
print distroId " " distroRelease " (" distroCodename ")"
|
||||||
|
}' /etc/lsb-release )
|
||||||
|
# this is HORRIBLY slow, but I don't know why, it runs fast in shell
|
||||||
|
# elif [[ -n $( which lsb_release ) ]];then
|
||||||
|
# distro=$( echo "$( lsb_release -irc )" | gawk '
|
||||||
|
# { IGNORECASE=1 }
|
||||||
|
# /^Distributor ID/ {
|
||||||
|
# gsub(/^ +| +$/, "", $NF)
|
||||||
|
# distroId = $NF
|
||||||
|
# }
|
||||||
|
# /^Release/ {
|
||||||
|
# gsub(/^ +| +$/, "", $NF)
|
||||||
|
# distroRelease = $NF
|
||||||
|
# }
|
||||||
|
# /^Codename/ {
|
||||||
|
# gsub(/^ +| +$/, "", $NF)
|
||||||
|
# distroCodename = $NF
|
||||||
|
# }
|
||||||
|
# END {
|
||||||
|
# print distroId " " distroRelease " (" distroCodename ")"
|
||||||
|
# }' )
|
||||||
|
fi
|
||||||
if [[ -z $distro ]];then
|
if [[ -z $distro ]];then
|
||||||
distro='Unknown distro o_O'
|
distro='Unknown distro o_O'
|
||||||
fi
|
fi
|
||||||
|
@ -1057,6 +1099,7 @@ get_distro_data()
|
||||||
if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then
|
if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then
|
||||||
distro='Arch Linux'
|
distro='Arch Linux'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$distro"
|
echo "$distro"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue