some code cleanup and variable naming fixes

This commit is contained in:
inxi-svn 2010-01-09 04:49:55 +00:00
parent 80a3db7925
commit d48147d79d

126
inxi
View file

@ -236,11 +236,11 @@ B_ASOUND_CARDS='false'
B_ASOUND_VERSION='false' B_ASOUND_VERSION='false'
B_BASH_ARRAY='false' B_BASH_ARRAY='false'
B_IFCONFIG='false' B_IFCONFIG='false'
B_LSB_DIR='false' B_LSB_FILE='false'
B_SCSI_DIR='false' B_SCSI_FILE='false'
B_MODULES_DIR='false' # B_MODULES_FILE='false' #
B_MOUNTS_DIR='false' B_MOUNTS_FILE='false'
B_PARTITIONS_DIR='false' # B_PARTITIONS_FILE='false' #
### File's used when present ### File's used when present
FILE_CPUINFO='/proc/cpuinfo' FILE_CPUINFO='/proc/cpuinfo'
@ -543,11 +543,11 @@ initialize_script_data()
fi fi
if [[ -f $FILE_LSB_RELEASE ]];then if [[ -f $FILE_LSB_RELEASE ]];then
B_LSB_DIR='true' B_LSB_FILE='true'
fi fi
if [[ -e $FILE_SCSI ]];then if [[ -e $FILE_SCSI ]];then
B_SCSI_DIR='true' B_SCSI_FILE='true'
fi fi
# lack of ifconfig will throw an error only upon it's usage # lack of ifconfig will throw an error only upon it's usage
@ -566,15 +566,15 @@ initialize_script_data()
fi fi
if [[ -e $FILE_MODULES ]];then if [[ -e $FILE_MODULES ]];then
B_MODULES_DIR='true' B_MODULES_FILE='true'
fi fi
if [[ -e $FILE_MOUNTS ]];then if [[ -e $FILE_MOUNTS ]];then
B_MOUNTS_DIR='true' B_MOUNTS_FILE='true'
fi fi
if [[ -e $FILE_PARTITIONS ]];then if [[ -e $FILE_PARTITIONS ]];then
B_PARTITIONS_DIR='true' B_PARTITIONS_FILE='true'
fi fi
# gfx output will require this flag # gfx output will require this flag
if [[ $( whoami ) == 'root' ]];then if [[ $( whoami ) == 'root' ]];then
@ -2070,7 +2070,7 @@ get_distro_data()
# because Mint does not use such, it must be done as below # because Mint does not use such, it must be done as below
## this if statement requires the spaces and * as it is, else it won't work ## this if statement requires the spaces and * as it is, else it won't work
## ##
if [[ " $DISTROS_LSB_GOOD " == *" ${i} "* ]] && [[ $B_LSB_DIR == 'true' ]];then if [[ " $DISTROS_LSB_GOOD " == *" ${i} "* ]] && [[ $B_LSB_FILE == 'true' ]];then
distro_file='lsb-release' distro_file='lsb-release'
else else
distro_file="${i}" distro_file="${i}"
@ -2097,7 +2097,7 @@ get_distro_data()
elif [[ -f /etc/issue ]];then elif [[ -f /etc/issue ]];then
# lsb gives more manageable and accurate output than issue, but mint should use issue for now # lsb gives more manageable and accurate output than issue, but mint should use issue for now
# some bashism, boolean must be in parenthesis to work correctly, ie [[ $(boolean) ]] not [[ $boolean ]] # some bashism, boolean must be in parenthesis to work correctly, ie [[ $(boolean) ]] not [[ $boolean ]]
if [[ $B_LSB_DIR == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then if [[ $B_LSB_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then
distro=$( get_distro_lsb_data ) distro=$( get_distro_lsb_data )
else else
distro=$( gawk ' distro=$( gawk '
@ -2121,7 +2121,7 @@ get_distro_data()
# : ${distro:=Unknown distro o_O} # : ${distro:=Unknown distro o_O}
## test for /etc/lsb-release as a backup in case of failure, in cases where > one version/release file ## test for /etc/lsb-release as a backup in case of failure, in cases where > one version/release file
## were found but the above resulted in null distro value ## were found but the above resulted in null distro value
if [[ -z $distro ]] && [[ $B_LSB_DIR == 'true' ]];then if [[ -z $distro ]] && [[ $B_LSB_FILE == 'true' ]];then
distro=$( get_distro_lsb_data ) distro=$( get_distro_lsb_data )
fi fi
## finally, if all else has failed, give up ## finally, if all else has failed, give up
@ -2145,7 +2145,7 @@ get_distro_lsb_data()
eval $LOGFS eval $LOGFS
local distro='' local distro=''
if [[ $B_LSB_DIR == 'true' ]] && [[ $1 != 'app' ]];then if [[ $B_LSB_FILE == 'true' ]] && [[ $1 != 'app' ]];then
distro=$( gawk -F '=' ' distro=$( gawk -F '=' '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
@ -2406,7 +2406,7 @@ get_graphics_agp_data()
eval $LOGFS eval $LOGFS
local agp_module='' local agp_module=''
if [[ $B_MODULES_DIR == 'true' ]];then if [[ $B_MODULES_FILE == 'true' ]];then
## not used currently ## not used currently
agp_module=$( gawk ' agp_module=$( gawk '
/agp/ && !/agpgart/ && $3 > 0 { /agp/ && !/agpgart/ && $3 > 0 {
@ -2513,7 +2513,7 @@ get_hdd_data_basic()
# final item is the total of the disk # final item is the total of the disk
IFS=$'\n' IFS=$'\n'
if [[ $B_PARTITIONS_DIR == 'true' ]];then if [[ $B_PARTITIONS_FILE == 'true' ]];then
A_HDD_DATA=( $( A_HDD_DATA=( $(
gawk -v hddused="$hdd_used" ' gawk -v hddused="$hdd_used" '
/[hs]d[a-z]$/ { /[hs]d[a-z]$/ {
@ -2593,7 +2593,7 @@ get_hard_drive_data_advanced()
## then handle libata names ## then handle libata names
# first get the ata device names, put them into an array # first get the ata device names, put them into an array
IFS=$'\n' IFS=$'\n'
if [[ $B_SCSI_DIR == 'true' ]]; then if [[ $B_SCSI_FILE == 'true' ]]; then
a_temp_scsi=( $( gawk ' a_temp_scsi=( $( gawk '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
@ -3001,7 +3001,7 @@ get_partition_data_advanced()
fi fi
log_function_data 'raw' "dev_disk_label:\n$dev_disk_label\n\ndev_disk_uuid:\n$dev_disk_uuid" log_function_data 'raw' "dev_disk_label:\n$dev_disk_label\n\ndev_disk_uuid:\n$dev_disk_uuid"
if [[ $B_MOUNTS_DIR == 'true' ]];then if [[ $B_MOUNTS_FILE == 'true' ]];then
for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
do do
IFS="," IFS=","
@ -3546,52 +3546,54 @@ get_unmounted_partition_data()
local a_unmounted_working='' a_unmounted_temp='' mounted_partitions='' separator='' local a_unmounted_working='' a_unmounted_temp='' mounted_partitions='' separator=''
local dev_disk_label='' dev_disk_uuid='' dev_working='' uuid_working='' label_working='' local dev_disk_label='' dev_disk_uuid='' dev_working='' uuid_working='' label_working=''
if [[ -d /dev/disk/by-label ]];then if [[ $B_PARTITIONS_FILE == 'true' ]];then
dev_disk_label="$( ls -l /dev/disk/by-label )" if [[ -d /dev/disk/by-label ]];then
fi dev_disk_label="$( ls -l /dev/disk/by-label )"
if [[ -d /dev/disk/by-uuid ]];then fi
dev_disk_uuid="$( ls -l /dev/disk/by-uuid )" if [[ -d /dev/disk/by-uuid ]];then
fi dev_disk_uuid="$( ls -l /dev/disk/by-uuid )"
# create list for slicing out the mounted partitions
for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_unmounted_working=( ${A_PARTITION_DATA[i]} )
IFS="$ORIGINAL_IFS"
if [[ -n ${a_unmounted_working[6]} ]];then
mounted_partitions="$mounted_partitions$separator${a_unmounted_working[6]}"
separator='|'
fi fi
done
A_UNMOUNTED_PARTITION_DATA=( $( cat /proc/partitions | grep -Ev '('$mounted_partitions')' | gawk '
BEGIN {
IGNORECASE=1
}
# note that size 1 means it is a logical extended partition container
/[a-z][0-9]+$/ && $3 != 1 {
size = sprintf( "%.2f", $3*1024/1000**3 )
print $4 "," size "G"
}' ) )
for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_unmounted_working=( ${A_UNMOUNTED_PARTITION_DATA[i]} )
IFS="$ORIGINAL_IFS"
label_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$dev_disk_label" | gawk '{ # create list for slicing out the mounted partitions
print $(NF - 2) for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
}' ) do
uuid_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$dev_disk_uuid" | gawk '{ IFS=","
print $(NF - 2) a_unmounted_working=( ${A_PARTITION_DATA[i]} )
}' ) IFS="$ORIGINAL_IFS"
if [[ -n ${a_unmounted_working[6]} ]];then
IFS="," mounted_partitions="$mounted_partitions$separator${a_unmounted_working[6]}"
A_UNMOUNTED_PARTITION_DATA[i]=${a_unmounted_working[0]}","${a_unmounted_working[1]}","$label_working","$uuid_working separator='|'
IFS="$ORIGINAL_IFS" fi
done done
A_UNMOUNTED_PARTITION_DATA=( $( grep -Ev '('$mounted_partitions')' $FILE_PARTITIONS | gawk '
BEGIN {
IGNORECASE=1
}
# note that size 1 means it is a logical extended partition container
/[a-z][0-9]+$/ && $3 != 1 {
size = sprintf( "%.2f", $3*1024/1000**3 )
print $4 "," size "G"
}' ) )
for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_unmounted_working=( ${A_UNMOUNTED_PARTITION_DATA[i]} )
IFS="$ORIGINAL_IFS"
label_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$dev_disk_label" | gawk '{
print $(NF - 2)
}' )
uuid_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$dev_disk_uuid" | gawk '{
print $(NF - 2)
}' )
IFS=","
A_UNMOUNTED_PARTITION_DATA[i]=${a_unmounted_working[0]}","${a_unmounted_working[1]}","$label_working","$uuid_working
IFS="$ORIGINAL_IFS"
done
fi
# echo "${A_UNMOUNTED_PARTITION_DATA[@]}" # echo "${A_UNMOUNTED_PARTITION_DATA[@]}"
eval $LOGFE eval $LOGFE