small uuid bug fix

This commit is contained in:
inxi-svn 2009-02-07 03:29:29 +00:00
parent aaaff711aa
commit 2dcbd5e05d

93
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.10.0-b1-t6 #### version: 0.10.2-b1-t1
#### Date: 4 February 2009 #### Date: 5 February 2009
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
######################################################################## ########################################################################
@ -63,6 +63,8 @@
#### Do not use `....`, those are totally non-reabable, use $(....) #### Do not use `....`, those are totally non-reabable, use $(....)
#### Do not use one liner flow controls. The ONLY time you should use ; is in #### Do not use one liner flow controls. The ONLY time you should use ; is in
#### this single case: if [[ condition ]];then (ie, never: [[ condition ]] && statement) #### this single case: if [[ condition ]];then (ie, never: [[ condition ]] && statement)
#### Note: [[ -n $something ]] - double brackets do not require quotes: "$something" for variables
#### Always use quotes, double or single, for all string values
#### ####
#### All new code/methods must be in a function. #### All new code/methods must be in a function.
#### For all boolean tests, use 'true' / 'false'. Do NOT use 0 or 1 unless #### For all boolean tests, use 'true' / 'false'. Do NOT use 0 or 1 unless
@ -288,7 +290,7 @@ DISTROS_LSB_GOOD="mandrake-release mandriva-release mandrakelinux-release"
# user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v # user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v
# 00000000 01 01 6f 6e 65 20 74 77 6f 0a |..one two.| # 00000000 01 01 6f 6e 65 20 74 77 6f 0a |..one two.|
A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\<ltd\>" ltd. $'\2'"\<inc\>" inc. $'\2'\<co\> co. "(tm)" "(r)" $'\2'"\(rev ..\)" ) A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\<ltd\>" ltd. $'\2'"\<inc\>" inc. $'\2'\<co\> co. "(tm)" "(r)" $'\2'"\(rev ..\)" )
A_CPU_BANS=( @ cpu deca 'dual core' 'tri core' 'quad core' ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" ) A_CPU_BANS=( @ cpu deca 'dual core' dual-core 'tri core' tri-core 'quad core' quad-core ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
# after processing, the ban arrays will be put into these: # after processing, the ban arrays will be put into these:
BAN_LIST_NORMAL='' BAN_LIST_NORMAL=''
BAN_LIST_CPU='' BAN_LIST_CPU=''
@ -421,27 +423,27 @@ initialize_script_data()
error_handler 6 error_handler 6
fi fi
if [[ -e "$DIR_CPUINFO" ]]; then if [[ -e $DIR_CPUINFO ]]; then
B_CPUINFO='true' B_CPUINFO='true'
fi fi
if [[ -e "$DIR_MEMINFO" ]];then if [[ -e $DIR_MEMINFO ]];then
B_MEMINFO='true' B_MEMINFO='true'
fi fi
if [[ -e "$DIR_ASOUND_DEVICE" ]];then if [[ -e $DIR_ASOUND_DEVICE ]];then
B_ASOUND_CARDS='true' B_ASOUND_CARDS='true'
fi fi
if [[ -e "$DIR_ASOUND_VERSION" ]];then if [[ -e $DIR_ASOUND_VERSION ]];then
B_ASOUND_VERSION='true' B_ASOUND_VERSION='true'
fi fi
if [[ -f "$DIR_LSB_RELEASE" ]];then if [[ -f $DIR_LSB_RELEASE ]];then
B_LSB_DIR='true' B_LSB_DIR='true'
fi fi
if [[ -e "$DIR_SCSI" ]];then if [[ -e $DIR_SCSI ]];then
B_SCSI_DIR='true' B_SCSI_DIR='true'
fi fi
@ -449,7 +451,7 @@ initialize_script_data()
if [[ -x ifconfig ]]; then if [[ -x ifconfig ]]; then
B_IFCONFIG='true' B_IFCONFIG='true'
DIR_IFCONFIG='ifconfig' # change from full path to use $PATH DIR_IFCONFIG='ifconfig' # change from full path to use $PATH
elif [[ -x "$DIR_IFCONFIG" ]];then elif [[ -x $DIR_IFCONFIG ]];then
B_IFCONFIG='true' B_IFCONFIG='true'
else else
A_INTERFACES_DATA=( "Interfaces tool requires missing app: $DIR_IFCONFIG" ) A_INTERFACES_DATA=( "Interfaces tool requires missing app: $DIR_IFCONFIG" )
@ -459,15 +461,15 @@ initialize_script_data()
B_X_RUNNING='true' B_X_RUNNING='true'
fi fi
if [[ -e "$DIR_MODULES" ]];then if [[ -e $DIR_MODULES ]];then
B_MODULES_DIR='true' B_MODULES_DIR='true'
fi fi
if [[ -e "$DIR_MOUNTS" ]];then if [[ -e $DIR_MOUNTS ]];then
B_MOUNTS_DIR='true' B_MOUNTS_DIR='true'
fi fi
if [[ -e "$DIR_PARTITIONS" ]];then if [[ -e $DIR_PARTITIONS ]];then
B_PARTITIONS_DIR='true' B_PARTITIONS_DIR='true'
fi fi
} }
@ -1241,7 +1243,7 @@ get_cmdline()
##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)" ##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
unset A_CMDL unset A_CMDL
## note: need to figure this one out, and ideally clean it up and make it readable ## note: need to figure this one out, and ideally clean it up and make it readable
while read -d $'\0' L && [ "$i" -lt 32 ] while read -d $'\0' L && [[ $i -lt 32 ]]
do do
A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ## A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
done < /proc/$ppid/cmdline done < /proc/$ppid/cmdline
@ -2348,7 +2350,7 @@ get_partition_data()
}' ) ) }' ) )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
get_partition_data_advanced get_partition_data_advanced
fi fi
} }
@ -2358,6 +2360,7 @@ get_partition_data_advanced()
{ {
local a_partition_working='' dev_partition_data='' local a_partition_working='' dev_partition_data=''
local dev_disk_label='' dev_disk_uuid='' dev_item='' dev_label='' dev_uuid='' local dev_disk_label='' dev_disk_uuid='' dev_item='' dev_label='' dev_uuid=''
local mount_point=''
if [[ -d /dev/disk/by-label ]];then if [[ -d /dev/disk/by-label ]];then
dev_disk_label="$( ls -l /dev/disk/by-label )" dev_disk_label="$( ls -l /dev/disk/by-label )"
@ -2366,14 +2369,14 @@ get_partition_data_advanced()
dev_disk_uuid="$( ls -l /dev/disk/by-uuid )" dev_disk_uuid="$( ls -l /dev/disk/by-uuid )"
fi fi
if [[ "$B_MOUNTS_DIR" == 'true' ]];then if [[ $B_MOUNTS_DIR == 'true' ]];then
for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
do do
IFS="," IFS=","
a_partition_working=( ${A_PARTITION_DATA[i]} ) a_partition_working=( ${A_PARTITION_DATA[i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
# note: for swap this will already be set # note: for swap this will already be set
if [[ -z "${a_partition_working[5]}" ]];then if [[ -z ${a_partition_working[5]} ]];then
mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} ) mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} )
#echo mount_point $mount_point #echo mount_point $mount_point
dev_partition_data=$( gawk ' dev_partition_data=$( gawk '
@ -2404,10 +2407,10 @@ get_partition_data_advanced()
# if this works, great, otherwise, just set this to null values # if this works, great, otherwise, just set this to null values
partTemp="'$( readlink /dev/root 2>/dev/null )'" partTemp="'$( readlink /dev/root 2>/dev/null )'"
if ( partTemp != "" ) { if ( partTemp != "" ) {
if ( partTemp ~ /^[hs]d[a-z][0-9]+$/ ) { if ( partTemp ~ /[hs]d[a-z][0-9]/ ) {
partition=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, partTemp ) partition=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, partTemp )
} }
else if ( partTemp ~ /by-uuid\/[a-z0-9]+-[a-z0-9]+-[a-z0-9]+/ ) { else if ( partTemp ~ /by-uuid/ ) {
uuid=gensub( /^(\/dev\/disk\/by-uuid\/)(.+)$/, "\\2", 1, partTemp ) uuid=gensub( /^(\/dev\/disk\/by-uuid\/)(.+)$/, "\\2", 1, partTemp )
} }
else if ( partTemp ~ /by-label/ ) { else if ( partTemp ~ /by-label/ ) {
@ -2438,13 +2441,14 @@ get_partition_data_advanced()
dev_label=${a_partition_working[6]} dev_label=${a_partition_working[6]}
dev_uuid=${a_partition_working[7]} dev_uuid=${a_partition_working[7]}
if [[ -n "$dev_disk_label" ]];then # first if the dev data/label data is incomplete, try to get missing piece
if [[ -n "$dev_item" && -z "$dev_label" ]];then if [[ -n $dev_disk_label ]];then
if [[ -n $dev_item && -z $dev_label ]];then
dev_label=$( echo "$dev_disk_label" | gawk ' dev_label=$( echo "$dev_disk_label" | gawk '
/'$dev_item'$/ { /'$dev_item'$/ {
print $(NF - 2) print $(NF - 2)
}' ) }' )
elif [[ -z "$dev_item" && -n "$dev_label" ]];then elif [[ -z $dev_item && -n $dev_label ]];then
dev_item=$( echo "$dev_disk_label" | gawk ' dev_item=$( echo "$dev_disk_label" | gawk '
/'$dev_label'/ { /'$dev_label'/ {
item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF ) item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF )
@ -2452,13 +2456,14 @@ get_partition_data_advanced()
}' ) }' )
fi fi
fi fi
if [[ -n "$dev_disk_uuid" ]];then # then if dev data/uuid is incomplete, try to get missing piece
if [[ -n "$dev_item" && -z "$dev_uuid" ]];then if [[ -n $dev_disk_uuid ]];then
if [[ -n $dev_item && -z $dev_uuid ]];then
dev_uuid=$( echo "$dev_disk_uuid" | gawk ' dev_uuid=$( echo "$dev_disk_uuid" | gawk '
/'$dev_item'$/ { /'$dev_item'$/ {
print $(NF - 2) print $(NF - 2)
}' ) }' )
elif [[ -z "$dev_item" && -n "$dev_uuid" ]];then elif [[ -z $dev_item && -n $dev_uuid ]];then
dev_item=$( echo "$dev_disk_uuid" | gawk ' dev_item=$( echo "$dev_disk_uuid" | gawk '
/'$dev_uuid'/ { /'$dev_uuid'/ {
item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF ) item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF )
@ -2472,7 +2477,6 @@ get_partition_data_advanced()
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
done done
fi fi
# echo 'A_PARTITION_DATA: ' "${A_PARTITION_DATA[@]}"
} }
## return uptime string ## return uptime string
@ -2629,7 +2633,7 @@ print_short_data()
local cpu_core_alpha=${A_CPU_CORE_DATA[1]} local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
local cpu_type=${A_CPU_CORE_DATA[2]} local cpu_type=${A_CPU_CORE_DATA[2]}
if [[ "$cpu_physical_count" -gt 1 ]];then if [[ $cpu_physical_count -gt 1 ]];then
cpc_plural='(s)' cpc_plural='(s)'
model_plural='s' model_plural='s'
cpu_count_print="$cpu_physical_count " cpu_count_print="$cpu_physical_count "
@ -2676,7 +2680,7 @@ print_short_data()
for i in C1 C2 CN for i in C1 C2 CN
do do
## these need to be in quotes, don't know why ## these need to be in quotes, don't know why
if [[ "${!i}" == "$NORMAL" ]];then if [[ ${!i} == $NORMAL ]];then
declare $i="${!i}15,1" declare $i="${!i}15,1"
else else
declare $i="${!i},1" declare $i="${!i},1"
@ -2804,7 +2808,7 @@ print_cpu_data()
local cpu_core_alpha=${A_CPU_CORE_DATA[1]} local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
local cpu_type=${A_CPU_CORE_DATA[2]} local cpu_type=${A_CPU_CORE_DATA[2]}
if [[ "$cpu_physical_count" -gt 1 ]];then if [[ $cpu_physical_count -gt 1 ]];then
cpc_plural='(s)' cpc_plural='(s)'
cpu_count_print="$cpu_physical_count " cpu_count_print="$cpu_physical_count "
model_plural='s' model_plural='s'
@ -3177,7 +3181,8 @@ print_partition_data()
{ {
local a_partition_working='' partition_used='' swap='' partition_data='' local a_partition_working='' partition_used='' swap='' partition_data=''
local counter=0 line_max=160 i=0 a_partition_data='' line_starter='' local counter=0 line_max=160 i=0 a_partition_data='' line_starter=''
local partitionIdClean='' part_dev='' full_dev='' part_label='' full_label='' part_uuid='' full_uuid='' local partitionIdClean='' part_dev='' full_dev='' part_label='' full_label=''
local part_uuid='' full_uuid='' dev_remote=''
# this handles the different, shorter, irc colors strings embedded in variable data # this handles the different, shorter, irc colors strings embedded in variable data
if [[ $B_RUNNING_IN_SHELL != 'true' ]];then if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
@ -3187,7 +3192,7 @@ print_partition_data()
if [[ $SCHEME -eq 0 ]];then if [[ $SCHEME -eq 0 ]];then
line_max=75 line_max=75
fi fi
if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
line_max=20 line_max=20
fi fi
@ -3201,34 +3206,40 @@ print_partition_data()
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_partition_working[4]} == 'swap' || ${a_partition_working[4]} == 'main' ]];then if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_partition_working[4]} == 'swap' || ${a_partition_working[4]} == 'main' ]];then
if [[ -n "${a_partition_working[2]}" ]];then if [[ -n ${a_partition_working[2]} ]];then
partition_used=" ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})" partition_used=" ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})"
else else
partition_used='' # reset partition used to null partition_used='' # reset partition used to null
fi fi
if [[ "${a_partition_working[4]}" == 'swap' ]];then if [[ ${a_partition_working[4]} == 'swap' ]];then
swap=" ${C1}swap:${C2}" swap=" ${C1}swap:${C2}"
else else
swap='' swap=''
fi fi
# don't show user names in output # don't show user names in output
if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
if [[ -n "${a_partition_working[5]}" ]];then if [[ -n ${a_partition_working[5]} ]];then
if [[ -z $( grep '^//' <<< ${a_partition_working[5]} ) ]];then
part_dev="/dev/${a_partition_working[5]}" part_dev="/dev/${a_partition_working[5]}"
dev_remote='dev'
else
part_dev="${a_partition_working[5]}"
dev_remote='remote'
fi
else else
part_dev='N/A' part_dev='N/A'
fi fi
full_dev=" ${C1}dev:${C2} $part_dev" full_dev=" ${C1}$dev_remote:${C2} $part_dev"
if [[ "$B_SHOW_LABELS" == 'true' ]];then if [[ $B_SHOW_LABELS == 'true' ]];then
if [[ -n "${a_partition_working[6]}" ]];then if [[ -n ${a_partition_working[6]} ]];then
part_label="${a_partition_working[6]}" part_label="${a_partition_working[6]}"
else else
part_label='N/A' part_label='N/A'
fi fi
full_label=" ${C1}label:${C2} $part_label" full_label=" ${C1}label:${C2} $part_label"
fi fi
if [[ "$B_SHOW_UUIDS" == 'true' ]];then if [[ $B_SHOW_UUIDS == 'true' ]];then
if [[ -n "${a_partition_working[7]}" ]];then if [[ -n ${a_partition_working[7]} ]];then
part_uuid="${a_partition_working[7]}" part_uuid="${a_partition_working[7]}"
else else
part_uuid='N/A' part_uuid='N/A'
@ -3265,7 +3276,7 @@ print_system_data()
local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' ) local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' )
local distro="$( get_distro_data )" local distro="$( get_distro_data )"
# check for 64 bit first # check for 64 bit first
if [[ -n "$( uname -m | grep -o 'x86_64' )" ]];then if [[ -n $( uname -m | grep -o 'x86_64' ) ]];then
bits="(64 bit)" bits="(64 bit)"
else else
bits="(32 bit)" bits="(32 bit)"