and put the functions in alphabetical order, all done now.

This commit is contained in:
inxi-svn 2010-01-09 04:19:15 +00:00
parent 7f76e53bec
commit 80a3db7925

230
inxi
View file

@ -3121,63 +3121,6 @@ get_partition_data_advanced()
eval $LOGFE
}
get_unmounted_partition_data()
{
eval $LOGFS
local a_unmounted_working='' a_unmounted_temp='' mounted_partitions='' separator=''
local dev_disk_label='' dev_disk_uuid='' dev_working='' uuid_working='' label_working=''
if [[ -d /dev/disk/by-label ]];then
dev_disk_label="$( ls -l /dev/disk/by-label )"
fi
if [[ -d /dev/disk/by-uuid ]];then
dev_disk_uuid="$( ls -l /dev/disk/by-uuid )"
fi
# 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
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 '{
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
# echo "${A_UNMOUNTED_PARTITION_DATA[@]}"
eval $LOGFE
}
# Repos will be added as we get distro package manager data to create the repo data.
# This method will output the file name also, which is useful to create output that's
# neat and readable.
@ -3597,6 +3540,63 @@ get_sensors_data()
eval $LOGFE
}
get_unmounted_partition_data()
{
eval $LOGFS
local a_unmounted_working='' a_unmounted_temp='' mounted_partitions='' separator=''
local dev_disk_label='' dev_disk_uuid='' dev_working='' uuid_working='' label_working=''
if [[ -d /dev/disk/by-label ]];then
dev_disk_label="$( ls -l /dev/disk/by-label )"
fi
if [[ -d /dev/disk/by-uuid ]];then
dev_disk_uuid="$( ls -l /dev/disk/by-uuid )"
fi
# 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
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 '{
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
# echo "${A_UNMOUNTED_PARTITION_DATA[@]}"
eval $LOGFE
}
## return uptime string
get_uptime()
{
@ -4484,64 +4484,6 @@ print_partition_data()
eval $LOGFE
}
print_unmounted_partition_data()
{
eval $LOGFS
local a_unmounted_data='' line_starter='' unmounted_data=''
local full_dev='' full_size='' full_label='' full_uuid='' full_string=''
if [[ -z ${A_PARTITION_DATA} ]];then
get_partition_data
fi
get_unmounted_partition_data
if [[ ${#A_UNMOUNTED_PARTITION_DATA[@]} -ge 1 ]];then
for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_unmounted_data=(${A_UNMOUNTED_PARTITION_DATA[i]})
IFS="$ORIGINAL_IFS"
if [[ -z ${a_unmounted_data[0]} ]];then
full_dev='N/A'
else
full_dev="/dev/${a_unmounted_data[0]}"
fi
full_dev="${C1}ID:${C2} $full_dev"
if [[ -z ${a_unmounted_data[1]} ]];then
full_size='N/A'
else
full_size=${a_unmounted_data[1]}
fi
full_size="${C1}size:${C2} $full_size"
if [[ -z ${a_unmounted_data[2]} ]];then
full_label='N/A'
else
full_label=${a_unmounted_data[2]}
fi
full_label="${C1}label:${C2} $full_label"
if [[ -z ${a_unmounted_data[3]} ]];then
full_uuid='N/A'
else
full_uuid=${a_unmounted_data[3]}
fi
full_uuid="${C1}uuid:${C2} $full_uuid"
full_string="$full_dev $full_size $full_label $full_uuid"
if [[ $i -eq 0 ]];then
line_starter='Unmounted:'
else
line_starter=' '
fi
unmounted_data=$( create_print_line "$line_starter" "$full_string" )
print_screen_output "$unmounted_data"
done
else
unmounted_data=$( create_print_line "Unmounted:" "No unmounted partitions detected." )
print_screen_output "$unmounted_data"
fi
eval $LOGFE
}
# currently only apt using distros support this feature, but over time we can add others
print_repo_data()
{
@ -4756,6 +4698,64 @@ print_system_data()
eval $LOGFE
}
print_unmounted_partition_data()
{
eval $LOGFS
local a_unmounted_data='' line_starter='' unmounted_data=''
local full_dev='' full_size='' full_label='' full_uuid='' full_string=''
if [[ -z ${A_PARTITION_DATA} ]];then
get_partition_data
fi
get_unmounted_partition_data
if [[ ${#A_UNMOUNTED_PARTITION_DATA[@]} -ge 1 ]];then
for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_unmounted_data=(${A_UNMOUNTED_PARTITION_DATA[i]})
IFS="$ORIGINAL_IFS"
if [[ -z ${a_unmounted_data[0]} ]];then
full_dev='N/A'
else
full_dev="/dev/${a_unmounted_data[0]}"
fi
full_dev="${C1}ID:${C2} $full_dev"
if [[ -z ${a_unmounted_data[1]} ]];then
full_size='N/A'
else
full_size=${a_unmounted_data[1]}
fi
full_size="${C1}size:${C2} $full_size"
if [[ -z ${a_unmounted_data[2]} ]];then
full_label='N/A'
else
full_label=${a_unmounted_data[2]}
fi
full_label="${C1}label:${C2} $full_label"
if [[ -z ${a_unmounted_data[3]} ]];then
full_uuid='N/A'
else
full_uuid=${a_unmounted_data[3]}
fi
full_uuid="${C1}uuid:${C2} $full_uuid"
full_string="$full_dev $full_size $full_label $full_uuid"
if [[ $i -eq 0 ]];then
line_starter='Unmounted:'
else
line_starter=' '
fi
unmounted_data=$( create_print_line "$line_starter" "$full_string" )
print_screen_output "$unmounted_data"
done
else
unmounted_data=$( create_print_line "Unmounted:" "No unmounted partitions detected." )
print_screen_output "$unmounted_data"
fi
eval $LOGFE
}
########################################################################
#### SCRIPT EXECUTION
########################################################################