mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 00:47:47 +00:00
Added array item, usb, for advanced hard disk output
This commit is contained in:
parent
3fa22cd051
commit
cbe7e922a6
26
inxi
26
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.4.12
|
#### version: 0.4.13
|
||||||
#### Date: November 8 2008
|
#### Date: November 8 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||||
|
@ -1173,7 +1173,7 @@ get_hdd_data_basic()
|
||||||
}' )
|
}' )
|
||||||
|
|
||||||
# create the initial array strings:
|
# create the initial array strings:
|
||||||
# disk-dev, capacity, name
|
# disk-dev, capacity, name, usb or not
|
||||||
# final item is the total of the disk
|
# final item is the total of the disk
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
A_HDD_DATA=( $( gawk -v hddused="$hdd_used" '
|
A_HDD_DATA=( $( gawk -v hddused="$hdd_used" '
|
||||||
|
@ -1181,7 +1181,7 @@ get_hdd_data_basic()
|
||||||
driveSize = $(NF - 1)*1024/1000**3
|
driveSize = $(NF - 1)*1024/1000**3
|
||||||
gsub(/,/, " ", driveSize)
|
gsub(/,/, " ", driveSize)
|
||||||
gsub(/^ +| +$/, "", driveSize)
|
gsub(/^ +| +$/, "", driveSize)
|
||||||
printf( $NF",%.1fGB,\n", driveSize )
|
printf( $NF",%.1fGB,,\n", driveSize )
|
||||||
}
|
}
|
||||||
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
|
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
|
||||||
$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3}
|
$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3}
|
||||||
|
@ -1205,6 +1205,7 @@ get_hdd_data_basic()
|
||||||
get_hard_drive_data_advanced()
|
get_hard_drive_data_advanced()
|
||||||
{
|
{
|
||||||
local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j=''
|
local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j=''
|
||||||
|
local sd_ls_by_id=''
|
||||||
|
|
||||||
## check for all ide type drives, non libata, only do it if hdx is in array
|
## check for all ide type drives, non libata, only do it if hdx is in array
|
||||||
if [[ -n $( egrep 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
|
if [[ -n $( egrep 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
|
||||||
|
@ -1266,9 +1267,14 @@ get_hard_drive_data_advanced()
|
||||||
## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the
|
## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the
|
||||||
# discovered disk name AND ends with the correct identifier, sdx
|
# discovered disk name AND ends with the correct identifier, sdx
|
||||||
temp_name=$( tr ' ' '_' <<< ${a_temp_scsi[$j]} | cut -d '-' -f 1 ) # get rid of whitespace for WDC
|
temp_name=$( tr ' ' '_' <<< ${a_temp_scsi[$j]} | cut -d '-' -f 1 ) # get rid of whitespace for WDC
|
||||||
|
|
||||||
|
sd_ls_by_id=$( ls -l /dev/disk/by-id | egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" )
|
||||||
# echo temp_name:$temp_name
|
# echo temp_name:$temp_name
|
||||||
if [[ -n $( ls -l /dev/disk/by-id | egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" ) ]];then
|
if [[ -n $sd_ls_by_id ]];then
|
||||||
a_temp_working[2]=${a_temp_scsi[$j]}
|
a_temp_working[2]=${a_temp_scsi[$j]}
|
||||||
|
if [[ -n $( grep 'usb-' <<< $sd_ls_by_id ) ]];then
|
||||||
|
a_temp_working[3]='usb'
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
# special initial usb handling
|
# special initial usb handling
|
||||||
|
@ -1279,6 +1285,7 @@ get_hard_drive_data_advanced()
|
||||||
# fi
|
# fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# these loops are to easily extend the cpu array created in the awk script above with more fields per cpu.
|
# these loops are to easily extend the cpu array created in the awk script above with more fields per cpu.
|
||||||
for (( j=0; j < ${#a_temp_working[@]}; j++ ))
|
for (( j=0; j < ${#a_temp_working[@]}; j++ ))
|
||||||
do
|
do
|
||||||
|
@ -1675,7 +1682,7 @@ print_gfx_data()
|
||||||
print_hard_disk_data()
|
print_hard_disk_data()
|
||||||
{
|
{
|
||||||
local hdd_data='' partition_data='' a_partition_working='' hdd_model='' a_hdd_working=''
|
local hdd_data='' partition_data='' a_partition_working='' hdd_model='' a_hdd_working=''
|
||||||
local dev_data='' size_data='' hdd_model_2='' hdd_data_2=''
|
local dev_data='' size_data='' hdd_model_2='' hdd_data_2='' usb_data=''
|
||||||
|
|
||||||
if [[ $VERBOSITY_LEVEL -ge 3 ]];then
|
if [[ $VERBOSITY_LEVEL -ge 3 ]];then
|
||||||
## note: the output part of this should be in the print hdd data function, not here
|
## note: the output part of this should be in the print hdd data function, not here
|
||||||
|
@ -1687,14 +1694,19 @@ print_hard_disk_data()
|
||||||
a_hdd_working=( ${A_HDD_DATA[i]} )
|
a_hdd_working=( ${A_HDD_DATA[i]} )
|
||||||
IFS="$ORIGINAL_IFS"
|
IFS="$ORIGINAL_IFS"
|
||||||
if [[ $B_EXTRA_DATA == 'true' ]];then
|
if [[ $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
if [[ -n ${a_hdd_working[3]} ]];then
|
||||||
|
usb_data="(${a_hdd_working[3]}) "
|
||||||
|
else
|
||||||
|
usb_data=''
|
||||||
|
fi
|
||||||
dev_data="/dev/${a_hdd_working[0]} - "
|
dev_data="/dev/${a_hdd_working[0]} - "
|
||||||
size_data=" - ${a_hdd_working[1]}"
|
size_data=" - ${a_hdd_working[1]}"
|
||||||
fi
|
fi
|
||||||
# wrap to avoid long lines
|
# wrap to avoid long lines
|
||||||
if [[ $i -gt 1 && $B_EXTRA_DATA == 'true' ]] || [[ $i -gt 3 ]];then
|
if [[ $i -gt 1 && $B_EXTRA_DATA == 'true' ]] || [[ $i -gt 3 ]];then
|
||||||
hdd_model_2="${hdd_model_2}${hdd_model_2+${C1}($(($i+1)))${C2}}$dev_data${a_hdd_working[2]}$size_data "
|
hdd_model_2="${hdd_model_2}${hdd_model_2+${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data "
|
||||||
else
|
else
|
||||||
hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}$dev_data${a_hdd_working[2]}$size_data"
|
hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}$usb_data$dev_data${a_hdd_working[2]}$size_data"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -z $hdd_model ]];then
|
if [[ -z $hdd_model ]];then
|
||||||
|
|
Loading…
Reference in a new issue