diff --git a/inxi b/inxi index 199d0cd..77de510 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.6.1 -#### Date: November 21 2008 +#### version: 0.6.2 +#### Date: November 22 2008 ######################################################################## #### 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. @@ -60,6 +60,11 @@ #### Booleans should start with b_ or B_ and state clearly what is being tested #### Arrays should start with a_ or A_ #### 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 #### inxi supports advanced testing triggers to do various things, using -! @@ -1052,6 +1057,9 @@ get_audio_data() if (/driver in use/) { drivers[audioCard] = drivers[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) "" } + else if (/kernel modules:/) { + modules[audioCard] = modules[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) "" + } else if (/I\/O/) { portsTemp = gensub(/\t*I\/O ports at (.*) \[.*\]/,"\\1","g",$0) ports[audioCard] = ports[audioCard] portsTemp " " @@ -1062,8 +1070,9 @@ get_audio_data() END { j=0 for (i in cards) { - usePorts="" useDrivers="" + useModules="" + usePorts="" if (cards[i]>1) { a[j]=cards[i]"x "i if (drivers[i] != "") { @@ -1072,6 +1081,9 @@ get_audio_data() if (ports[i] != "") { usePorts = ports[i] } + if (modules[i] != "" ) { + useModules = modules[i] + } } else { a[j]=i @@ -1086,9 +1098,12 @@ get_audio_data() if (ports[i] != "") { usePorts=ports[i] } + if (modules[i] != "" ) { + useModules = modules[i] + } } # create array primary item for master array - print a[j] "," useDrivers "," usePorts + print a[j] "," useDrivers "," usePorts "," useModules j++ } }') ) @@ -1732,6 +1747,26 @@ get_memory_data() 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 get_networking_data() { @@ -1756,14 +1791,18 @@ get_networking_data() if (/driver in use/) { drivers[nic] = drivers[nic] gensub(/(.*): (.*)/,"\\2","g",$0) "" } + else if (/kernel modules/) { + modules[nic] = modules[nic] gensub(/(.*): (.*)/,"\\2","g",$0) "" + } } } END { j=0 for (i in eth) { - usePorts="" useDrivers="" + usePorts="" + useModules="" if (eth[i]>1) { a[j]=eth[i]"x "i ## note: this loses the plural ports case, is it needed anyway? @@ -1773,6 +1812,9 @@ get_networking_data() if (drivers[i] != "") { useDrivers=drivers[i] } + if (modules[i] != "" ) { + useModules = modules[i] + } } else { a[j]=i @@ -1782,9 +1824,12 @@ get_networking_data() if (drivers[i] != "") { useDrivers=drivers[i] } + if (modules[i] != "" ) { + useModules = modules[i] + } } # create array primary item for master array - print a[j] "," useDrivers "," usePorts + print a[j] "," useDrivers "," usePorts "," useModules j++ } }') ) @@ -2086,7 +2131,7 @@ print_short_data() print_audio_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 get_audio_data alsa_data=$( get_audio_alsa_data ) @@ -2104,8 +2149,11 @@ print_audio_data() # port_data=" ${C1}at port${C2} ${a_audio_working[2]}" # fi # 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 - alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}" + alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}$module_version" fi if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then @@ -2125,7 +2173,10 @@ print_audio_data() port_data='' alsa_driver='' 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 if [[ -n ${a_audio_working[1]} ]];then alsa_driver="${C1}driver${C2} ${a_audio_working[1]}" @@ -2451,10 +2502,28 @@ print_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() { 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 get_networking_data @@ -2468,9 +2537,11 @@ print_networking_data() if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then card_one='Card' 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 - driver_data=" ${C1}driver${C2} ${a_network_working[1]}" + driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version" fi if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then @@ -2491,8 +2562,12 @@ print_networking_data() port_data='' driver_data='' 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 - driver_data=" ${C1}driver${C2} ${a_network_working[1]}" + driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version" fi if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then