mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
Added option, with -x, to show, if available, kernel driver module version number.
Note, this is not often available data, so it will only show if you have it. This requires modinfo showing ^version: data, which only sometimes is there.
This commit is contained in:
parent
ad3947c121
commit
a07c2b19bc
101
inxi
101
inxi
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.6.1
|
#### version: 0.6.2
|
||||||
#### Date: November 21 2008
|
#### Date: November 22 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
|
||||||
#### As time permits functionality improvements and recoding will occur.
|
#### As time permits functionality improvements and recoding will occur.
|
||||||
|
@ -60,6 +60,11 @@
|
||||||
#### Booleans should start with b_ or B_ and state clearly what is being tested
|
#### Booleans should start with b_ or B_ and state clearly what is being tested
|
||||||
#### Arrays should start with a_ or A_
|
#### Arrays should start with a_ or A_
|
||||||
#### All functions should follow standard naming, ie, verb adjective noun, get_cpu_data
|
#### All functions should follow standard naming, ie, verb adjective noun, get_cpu_data
|
||||||
|
####
|
||||||
|
#### SPECIAL NOTES:
|
||||||
|
#### The color variable ${C2} must always be followed by a space unless you know what
|
||||||
|
#### character is going to be next for certain. Otherwise irc color codes can be accidentally
|
||||||
|
#### activated or altered.
|
||||||
########################################################################
|
########################################################################
|
||||||
#### TESTING FLAGS
|
#### TESTING FLAGS
|
||||||
#### inxi supports advanced testing triggers to do various things, using -! <arg>
|
#### inxi supports advanced testing triggers to do various things, using -! <arg>
|
||||||
|
@ -1052,6 +1057,9 @@ get_audio_data()
|
||||||
if (/driver in use/) {
|
if (/driver in use/) {
|
||||||
drivers[audioCard] = drivers[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
drivers[audioCard] = drivers[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
||||||
}
|
}
|
||||||
|
else if (/kernel modules:/) {
|
||||||
|
modules[audioCard] = modules[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
||||||
|
}
|
||||||
else if (/I\/O/) {
|
else if (/I\/O/) {
|
||||||
portsTemp = gensub(/\t*I\/O ports at (.*) \[.*\]/,"\\1","g",$0)
|
portsTemp = gensub(/\t*I\/O ports at (.*) \[.*\]/,"\\1","g",$0)
|
||||||
ports[audioCard] = ports[audioCard] portsTemp " "
|
ports[audioCard] = ports[audioCard] portsTemp " "
|
||||||
|
@ -1062,8 +1070,9 @@ get_audio_data()
|
||||||
END {
|
END {
|
||||||
j=0
|
j=0
|
||||||
for (i in cards) {
|
for (i in cards) {
|
||||||
usePorts=""
|
|
||||||
useDrivers=""
|
useDrivers=""
|
||||||
|
useModules=""
|
||||||
|
usePorts=""
|
||||||
if (cards[i]>1) {
|
if (cards[i]>1) {
|
||||||
a[j]=cards[i]"x "i
|
a[j]=cards[i]"x "i
|
||||||
if (drivers[i] != "") {
|
if (drivers[i] != "") {
|
||||||
|
@ -1072,6 +1081,9 @@ get_audio_data()
|
||||||
if (ports[i] != "") {
|
if (ports[i] != "") {
|
||||||
usePorts = ports[i]
|
usePorts = ports[i]
|
||||||
}
|
}
|
||||||
|
if (modules[i] != "" ) {
|
||||||
|
useModules = modules[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a[j]=i
|
a[j]=i
|
||||||
|
@ -1086,9 +1098,12 @@ get_audio_data()
|
||||||
if (ports[i] != "") {
|
if (ports[i] != "") {
|
||||||
usePorts=ports[i]
|
usePorts=ports[i]
|
||||||
}
|
}
|
||||||
|
if (modules[i] != "" ) {
|
||||||
|
useModules = modules[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# create array primary item for master array
|
# create array primary item for master array
|
||||||
print a[j] "," useDrivers "," usePorts
|
print a[j] "," useDrivers "," usePorts "," useModules
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
}') )
|
}') )
|
||||||
|
@ -1732,6 +1747,26 @@ get_memory_data()
|
||||||
echo "$memory"
|
echo "$memory"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# process and return module version data
|
||||||
|
get_module_version_number()
|
||||||
|
{
|
||||||
|
local module_version=''
|
||||||
|
|
||||||
|
if [[ -n $( which modinfo ) ]];then
|
||||||
|
module_version=$( modinfo $1 | gawk '
|
||||||
|
BEGIN { IGNORECASE=1 }
|
||||||
|
/^version/ {
|
||||||
|
gsub(/,/, " ", $2)
|
||||||
|
gsub(/^ +| +$/, "", $2)
|
||||||
|
gsub(/ [ \t]+/, " ", $2)
|
||||||
|
print $2
|
||||||
|
}
|
||||||
|
' )
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$module_version"
|
||||||
|
}
|
||||||
|
|
||||||
## create array of network cards
|
## create array of network cards
|
||||||
get_networking_data()
|
get_networking_data()
|
||||||
{
|
{
|
||||||
|
@ -1756,14 +1791,18 @@ get_networking_data()
|
||||||
if (/driver in use/) {
|
if (/driver in use/) {
|
||||||
drivers[nic] = drivers[nic] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
drivers[nic] = drivers[nic] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
||||||
}
|
}
|
||||||
|
else if (/kernel modules/) {
|
||||||
|
modules[nic] = modules[nic] gensub(/(.*): (.*)/,"\\2","g",$0) ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
j=0
|
j=0
|
||||||
for (i in eth) {
|
for (i in eth) {
|
||||||
usePorts=""
|
|
||||||
useDrivers=""
|
useDrivers=""
|
||||||
|
usePorts=""
|
||||||
|
useModules=""
|
||||||
if (eth[i]>1) {
|
if (eth[i]>1) {
|
||||||
a[j]=eth[i]"x "i
|
a[j]=eth[i]"x "i
|
||||||
## note: this loses the plural ports case, is it needed anyway?
|
## note: this loses the plural ports case, is it needed anyway?
|
||||||
|
@ -1773,6 +1812,9 @@ get_networking_data()
|
||||||
if (drivers[i] != "") {
|
if (drivers[i] != "") {
|
||||||
useDrivers=drivers[i]
|
useDrivers=drivers[i]
|
||||||
}
|
}
|
||||||
|
if (modules[i] != "" ) {
|
||||||
|
useModules = modules[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a[j]=i
|
a[j]=i
|
||||||
|
@ -1782,9 +1824,12 @@ get_networking_data()
|
||||||
if (drivers[i] != "") {
|
if (drivers[i] != "") {
|
||||||
useDrivers=drivers[i]
|
useDrivers=drivers[i]
|
||||||
}
|
}
|
||||||
|
if (modules[i] != "" ) {
|
||||||
|
useModules = modules[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# create array primary item for master array
|
# create array primary item for master array
|
||||||
print a[j] "," useDrivers "," usePorts
|
print a[j] "," useDrivers "," usePorts "," useModules
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
}') )
|
}') )
|
||||||
|
@ -2086,7 +2131,7 @@ print_short_data()
|
||||||
print_audio_data()
|
print_audio_data()
|
||||||
{
|
{
|
||||||
local i='' card_one='Card-1 ' audio_data='' a_audio_data='' port_data=''
|
local i='' card_one='Card-1 ' audio_data='' a_audio_data='' port_data=''
|
||||||
local a_audio_working='' alsa_driver='' alsa_data='' port_plural=''
|
local a_audio_working='' alsa_driver='' alsa_data='' port_plural='' module_version=''
|
||||||
# set A_AUDIO_DATA and get alsa data
|
# set A_AUDIO_DATA and get alsa data
|
||||||
get_audio_data
|
get_audio_data
|
||||||
alsa_data=$( get_audio_alsa_data )
|
alsa_data=$( get_audio_alsa_data )
|
||||||
|
@ -2104,8 +2149,11 @@ print_audio_data()
|
||||||
# port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
|
# port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
|
||||||
# fi
|
# fi
|
||||||
# this should only trigger if the /proc/asound/cards data is used, not lspci -nn
|
# this should only trigger if the /proc/asound/cards data is used, not lspci -nn
|
||||||
|
if [[ -n ${a_audio_working[3]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
module_version=$( print_module_version "${a_audio_working[3]}" )
|
||||||
|
fi
|
||||||
if [[ -n ${a_audio_working[1]} ]];then
|
if [[ -n ${a_audio_working[1]} ]];then
|
||||||
alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}"
|
alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}$module_version"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then
|
if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then
|
||||||
|
@ -2125,7 +2173,10 @@ print_audio_data()
|
||||||
port_data=''
|
port_data=''
|
||||||
alsa_driver=''
|
alsa_driver=''
|
||||||
port_plural=''
|
port_plural=''
|
||||||
|
module_version=''
|
||||||
|
if [[ -n ${a_audio_working[3]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
module_version=$( print_module_version "${a_audio_working[3]}" )
|
||||||
|
fi
|
||||||
# we're testing for the presence of the 2nd array item here, which is the driver name
|
# we're testing for the presence of the 2nd array item here, which is the driver name
|
||||||
if [[ -n ${a_audio_working[1]} ]];then
|
if [[ -n ${a_audio_working[1]} ]];then
|
||||||
alsa_driver="${C1}driver${C2} ${a_audio_working[1]}"
|
alsa_driver="${C1}driver${C2} ${a_audio_working[1]}"
|
||||||
|
@ -2451,10 +2502,28 @@ print_info_data()
|
||||||
print_screen_output "$info_data"
|
print_screen_output "$info_data"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args: $1 - module name (could be > 1, so loop it )
|
||||||
|
print_module_version()
|
||||||
|
{
|
||||||
|
local module_versions='' module='' version=''
|
||||||
|
|
||||||
|
for module in $1
|
||||||
|
do
|
||||||
|
version=$( get_module_version_number $module )
|
||||||
|
if [[ -n $version ]];then
|
||||||
|
module_versions="$module_versions $version"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n $module_versions ]];then
|
||||||
|
echo " ${C1}v:${C2}$module_versions"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
print_networking_data()
|
print_networking_data()
|
||||||
{
|
{
|
||||||
local i='' card_one='Card-1' network_data='' a_network_working='' port_data='' driver_data=''
|
local i='' card_one='Card-1' network_data='' a_network_working='' port_data='' driver_data=''
|
||||||
local card_string='' port_plural=''
|
local card_string='' port_plural='' module_version=''
|
||||||
# set A_NETWORK_DATA
|
# set A_NETWORK_DATA
|
||||||
get_networking_data
|
get_networking_data
|
||||||
|
|
||||||
|
@ -2468,9 +2537,11 @@ print_networking_data()
|
||||||
if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then
|
if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then
|
||||||
card_one='Card'
|
card_one='Card'
|
||||||
fi
|
fi
|
||||||
|
if [[ -n ${a_network_working[3]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
module_version=$( print_module_version "${a_network_working[3]}" )
|
||||||
|
fi
|
||||||
if [[ -n ${a_network_working[1]} ]];then
|
if [[ -n ${a_network_working[1]} ]];then
|
||||||
driver_data=" ${C1}driver${C2} ${a_network_working[1]}"
|
driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
|
if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
|
||||||
|
@ -2491,8 +2562,12 @@ print_networking_data()
|
||||||
port_data=''
|
port_data=''
|
||||||
driver_data=''
|
driver_data=''
|
||||||
port_plural=''
|
port_plural=''
|
||||||
|
module_version=''
|
||||||
|
if [[ -n ${a_network_working[3]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
module_version=$( print_module_version "${a_network_working[3]}" )
|
||||||
|
fi
|
||||||
if [[ -n ${a_network_working[1]} ]];then
|
if [[ -n ${a_network_working[1]} ]];then
|
||||||
driver_data=" ${C1}driver${C2} ${a_network_working[1]}"
|
driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version"
|
||||||
fi
|
fi
|
||||||
if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
|
||||||
if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
|
if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
|
||||||
|
|
Loading…
Reference in a new issue