From b4f59b52965c4b0d887fedd306e65b1a498b698f Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Mon, 27 Jul 2009 22:57:05 +0000 Subject: [PATCH] changed the DIR_ to FILE_ to better indicate they are files, updated app tests to use inxi default of: type -p fine tuned some output stuff for -s sensors output --- inxi | 96 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/inxi b/inxi index aae28ed..c5e3838 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.0.97-b1 +#### version: 1.0.98-b1 #### Date: 27 July 2009 ######################################################################## #### SPECIAL THANKS @@ -237,16 +237,15 @@ B_MOUNTS_DIR='false' B_PARTITIONS_DIR='false' # ### Directory's used when present -DIR_CPUINFO='/proc/cpuinfo' -DIR_MEMINFO='/proc/meminfo' -DIR_ASOUND_DEVICE='/proc/asound/cards' -DIR_ASOUND_VERSION='/proc/asound/version' -DIR_LSB_RELEASE='/etc/lsb-release' -DIR_SCSI='/proc/scsi/scsi' -DIR_MODULES='/proc/modules' # -DIR_MOUNTS='/proc/mounts' -DIR_PARTITIONS='/proc/partitions' # -DIR_IFCONFIG='/sbin/ifconfig' +FILE_CPUINFO='/proc/cpuinfo' +FILE_MEMINFO='/proc/meminfo' +FILE_ASOUND_DEVICE='/proc/asound/cards' +FILE_ASOUND_VERSION='/proc/asound/version' +FILE_LSB_RELEASE='/etc/lsb-release' +FILE_SCSI='/proc/scsi/scsi' +FILE_MODULES='/proc/modules' +FILE_MOUNTS='/proc/mounts' +FILE_PARTITIONS='/proc/partitions' ### Variable initializations: constants DCOPOBJ="default" @@ -515,41 +514,38 @@ initialize_script_data() error_handler 6 fi - if [[ -e $DIR_CPUINFO ]]; then + if [[ -e $FILE_CPUINFO ]]; then B_CPUINFO='true' fi - if [[ -e $DIR_MEMINFO ]];then + if [[ -e $FILE_MEMINFO ]];then B_MEMINFO='true' fi - if [[ -e $DIR_ASOUND_DEVICE ]];then + if [[ -e $FILE_ASOUND_DEVICE ]];then B_ASOUND_CARDS='true' fi - if [[ -e $DIR_ASOUND_VERSION ]];then + if [[ -e $FILE_ASOUND_VERSION ]];then B_ASOUND_VERSION='true' fi - if [[ -f $DIR_LSB_RELEASE ]];then + if [[ -f $FILE_LSB_RELEASE ]];then B_LSB_DIR='true' fi - if [[ -e $DIR_SCSI ]];then + if [[ -e $FILE_SCSI ]];then B_SCSI_DIR='true' fi # lack of ifconfig will throw an error only upon it's usage - if [[ -x ifconfig ]]; then - B_IFCONFIG='true' - DIR_IFCONFIG='ifconfig' # change from full path to use $PATH - elif [[ -x $DIR_IFCONFIG ]];then + if [[ -n $( type -p ifconfig ) ]]; then B_IFCONFIG='true' else - A_INTERFACES_DATA=( "Interfaces tool requires missing app: $DIR_IFCONFIG" ) + A_INTERFACES_DATA=( "Interfaces tool requires missing app: ifconfig" ) fi - if [[ -n $( which sensors ) ]];then + if [[ -n $( type -p sensors ) ]];then B_SENSORS='true' fi @@ -557,15 +553,15 @@ initialize_script_data() B_X_RUNNING='true' fi - if [[ -e $DIR_MODULES ]];then + if [[ -e $FILE_MODULES ]];then B_MODULES_DIR='true' fi - if [[ -e $DIR_MOUNTS ]];then + if [[ -e $FILE_MOUNTS ]];then B_MOUNTS_DIR='true' fi - if [[ -e $DIR_PARTITIONS ]];then + if [[ -e $FILE_PARTITIONS ]];then B_PARTITIONS_DIR='true' fi # gfx output will require this flag @@ -1648,8 +1644,8 @@ get_audio_data() if ( driver != "" ){ print driver } - }' $DIR_ASOUND_DEVICE ) - log_function_data 'cat' "$DIR_ASOUND_DEVICE" + }' $FILE_ASOUND_DEVICE ) + log_function_data 'cat' "$FILE_ASOUND_DEVICE" fi # this is to safeguard against line breaks from results > 1, which if inserted into following @@ -1739,7 +1735,7 @@ get_audio_data() if ( card != "" ){ print card","driver } - }' $DIR_ASOUND_DEVICE ) ) + }' $FILE_ASOUND_DEVICE ) ) fi # alsa usb detection by damentz @@ -1800,8 +1796,8 @@ get_audio_alsa_data() if ( $0 != "" ){ print $0 } - }' $DIR_ASOUND_VERSION ) - log_function_data 'cat' "$DIR_ASOUND_VERSION" + }' $FILE_ASOUND_VERSION ) + log_function_data 'cat' "$FILE_ASOUND_VERSION" fi echo "$alsa_data" log_function_data "alsa_data: $alsa_data" @@ -1857,7 +1853,7 @@ get_cpu_data() IGNORECASE=1 } # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+ - # TAKE NOTE: \t+ will work for $DIR_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES! + # TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES! # Therefore PATCH to use [ \t]+ when TESTING! /^processor[ \t]+:/ { nr = $NF @@ -1922,8 +1918,8 @@ get_cpu_data() else { printf("%s %s\n", max, "Mhz") } - }' $DIR_CPUINFO ) ) - log_function_data 'cat' "$DIR_CPUINFO" + }' $FILE_CPUINFO ) ) + log_function_data 'cat' "$FILE_CPUINFO" fi IFS="$ORIGINAL_IFS" @@ -2014,7 +2010,7 @@ get_cpu_ht_multicore_smp_data() } print type " " physical_cpu_count " " core_count } - ' $DIR_CPUINFO ) ) + ' $FILE_CPUINFO ) ) fi log_function_data "A_CPU_TYPE_PCNT_CCNT: ${A_CPU_TYPE_PCNT_CCNT[@]}" eval $LOGFE @@ -2066,7 +2062,7 @@ get_distro_data() # this handles case where only one release/version file was found, and it's lsb-release. This would # never apply for ubuntu or debian, which will filter down to the following conditions. In general # if there's a specific distro release file available, that's to be preferred, but this is a good backup. - elif [[ -n $distro_file && -f $DIR_LSB_RELEASE && " $DISTROS_LSB_GOOD" == *" $distro_file "* ]];then + elif [[ -n $distro_file && -f $FILE_LSB_RELEASE && " $DISTROS_LSB_GOOD" == *" $distro_file "* ]];then distro=$( get_distro_lsb_data ) elif [[ $distro_file == 'lsb-release' ]];then distro=$( get_distro_lsb_data ) @@ -2155,8 +2151,8 @@ get_distro_lsb_data() } END { print distroId distroRelease distroCodename - }' $DIR_LSB_RELEASE ) - log_function_data 'cat' "$DIR_LSB_RELEASE" + }' $FILE_LSB_RELEASE ) + log_function_data 'cat' "$FILE_LSB_RELEASE" fi # this is HORRIBLY slow, but I don't know why, it runs fast in shell # if [[ -n $( which lsb_release ) && $1 == 'app' ]];then @@ -2328,8 +2324,8 @@ get_graphics_agp_data() agp_module=$( gawk ' /agp/ && !/agpgart/ && $3 > 0 { print(gensub(/(.*)_agp.*/,"\\1","g",$1)) - }' $DIR_MODULES ) - log_function_data 'cat' "$DIR_MODULES" + }' $FILE_MODULES ) + log_function_data 'cat' "$FILE_MODULES" fi log_function_data "agp_module: $agp_module" eval $LOGFE @@ -2464,8 +2460,8 @@ get_hdd_data_basic() else { print "NA,-" # print an empty array, this will be further handled in the print out function } - }' $DIR_PARTITIONS ) ) - log_function_data 'cat' "$DIR_PARTITIONS" + }' $FILE_PARTITIONS ) ) + log_function_data 'cat' "$FILE_PARTITIONS" fi IFS="$ORIGINAL_IFS" log_function_data "A_HDD_DATA: ${A_HDD_DATA[@]}" @@ -2536,8 +2532,8 @@ get_hard_drive_data_advanced() print c } } - }' $DIR_SCSI ) ) - log_function_data 'cat' "$DIR_SCSI" + }' $FILE_SCSI ) ) + log_function_data 'cat' "$FILE_SCSI" fi IFS="$ORIGINAL_IFS" @@ -2620,8 +2616,8 @@ get_memory_data() END { used = tot-notused printf("%.1f/%.1fMB\n", used/1024, tot/1024) - }' $DIR_MEMINFO ) - log_function_data 'cat' "$DIR_MEMINFO" + }' $FILE_MEMINFO ) + log_function_data 'cat' "$FILE_MEMINFO" fi echo "$memory" log_function_data "memory: $memory" @@ -2751,7 +2747,7 @@ get_networking_local_ip_data() eval $LOGFS if [[ $B_IFCONFIG == 'true' ]];then IFS=$'\n' - A_INTERFACES_DATA=( $( $DIR_IFCONFIG | gawk ' + A_INTERFACES_DATA=( $( ifconfig | gawk ' BEGIN { IGNORECASE=1 } @@ -2946,7 +2942,7 @@ get_partition_data_advanced() } } print partition "," label "," uuid - }' $DIR_MOUNTS ) + }' $FILE_MOUNTS ) # echo dev_partition_data: $dev_partition_data # assemble everything we could get for dev/h/dx, label, and uuid @@ -3001,7 +2997,7 @@ get_partition_data_advanced() A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","$dev_item","$dev_label","$dev_uuid IFS="$ORIGINAL_IFS" done - log_function_data 'cat' "$DIR_MOUNTS" + log_function_data 'cat' "$FILE_MOUNTS" fi log_function_data "A_PARTITION_DATA: ${A_PARTITION_DATA[@]}" eval $LOGFE @@ -3467,7 +3463,7 @@ print_audio_data() # if [[ -n ${a_audio_working[2]} ]];then # port_data=" ${C1}at port${C2} ${a_audio_working[2]}" # fi - # this should only trigger if the $DIR_ASOUND_DEVICE data is used, not lspci -nn + # this should only trigger if the $FILE_ASOUND_DEVICE 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