mirror of
https://github.com/smxi/inxi.git
synced 2025-02-24 05:52:18 +00:00
(change version)
new feature and option: -o shows unmounted local partitions, with uuid and label if present. Does not show with -F to avoid excessive output
This commit is contained in:
parent
aa746b3221
commit
bfa54a8ef5
135
inxi
135
inxi
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 1.2.10
|
#### version: 1.3.0
|
||||||
#### Date: January 7 2010
|
#### Date: January 8 2010
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SPECIAL THANKS
|
#### SPECIAL THANKS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
||||||
#### Original infobash author and copyright holder:
|
#### Original infobash author and copyright holder:
|
||||||
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
|
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
|
||||||
#### inxi version: Copyright (C) 2008-9 Scott Rogers & Harald Hope
|
#### inxi version: Copyright (C) 2008-10 Scott Rogers & Harald Hope
|
||||||
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
|
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
|
||||||
#### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
|
#### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
|
||||||
####
|
####
|
||||||
|
@ -171,6 +171,7 @@ A_INTERFACES_DATA=''
|
||||||
A_NETWORK_DATA=''
|
A_NETWORK_DATA=''
|
||||||
A_PARTITION_DATA=''
|
A_PARTITION_DATA=''
|
||||||
A_SENSORS_DATA=''
|
A_SENSORS_DATA=''
|
||||||
|
A_UNMOUNTED_PARTITION_DATA=''
|
||||||
A_X_DATA=''
|
A_X_DATA=''
|
||||||
|
|
||||||
### Boolean true/false globals ## usage: 'B_<var>'
|
### Boolean true/false globals ## usage: 'B_<var>'
|
||||||
|
@ -215,6 +216,7 @@ B_SHOW_SENSORS='false'
|
||||||
# triggers only short inxi output
|
# triggers only short inxi output
|
||||||
B_SHOW_SHORT_OUTPUT='false'
|
B_SHOW_SHORT_OUTPUT='false'
|
||||||
B_SHOW_SYSTEM='false'
|
B_SHOW_SYSTEM='false'
|
||||||
|
B_SHOW_UNMOUNTED_PARTITIONS='false'
|
||||||
B_SHOW_UUIDS='false'
|
B_SHOW_UUIDS='false'
|
||||||
# triggers various debugging and new option testing
|
# triggers various debugging and new option testing
|
||||||
B_TESTING_1='false'
|
B_TESTING_1='false'
|
||||||
|
@ -1015,7 +1017,7 @@ get_parameters()
|
||||||
# the short form only runs if no args output args are used
|
# the short form only runs if no args output args are used
|
||||||
# no need to run through these if there are no args
|
# no need to run through these if there are no args
|
||||||
if [[ -n $1 ]];then
|
if [[ -n $1 ]];then
|
||||||
while getopts Ac:CdDfFGhHiIlNpPrsSuv:Vx%@:${update_flags} opt
|
while getopts Ac:CdDfFGhHiIlNopPrsSuv:Vx%@:${update_flags} opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
A) B_SHOW_AUDIO='true'
|
A) B_SHOW_AUDIO='true'
|
||||||
|
@ -1069,6 +1071,9 @@ get_parameters()
|
||||||
N) B_SHOW_NETWORK='true'
|
N) B_SHOW_NETWORK='true'
|
||||||
use_short='false'
|
use_short='false'
|
||||||
;;
|
;;
|
||||||
|
o) B_SHOW_UNMOUNTED_PARTITIONS='true'
|
||||||
|
use_short='false'
|
||||||
|
;;
|
||||||
p) B_SHOW_PARTITIONS_FULL='true'
|
p) B_SHOW_PARTITIONS_FULL='true'
|
||||||
B_SHOW_PARTITIONS='true'
|
B_SHOW_PARTITIONS='true'
|
||||||
use_short='false'
|
use_short='false'
|
||||||
|
@ -1206,13 +1211,14 @@ show_options()
|
||||||
print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1"
|
print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1"
|
||||||
print_screen_output "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."
|
print_screen_output "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."
|
||||||
print_screen_output "-f Show all cpu flags used, not just the short list. Not shown with -F to avoid spamming."
|
print_screen_output "-f Show all cpu flags used, not just the short list. Not shown with -F to avoid spamming."
|
||||||
print_screen_output "-F Show Full output for $SCRIPT_NAME. Does not show extra verbose options like -f -u -l or -p"
|
print_screen_output "-F Show Full output for $SCRIPT_NAME. Does not show extra verbose options like -f -u -l -p or -o"
|
||||||
print_screen_output "-G Show Graphic card information (card, x type, resolution, glx renderer, version)."
|
print_screen_output "-G Show Graphic card information (card, x type, resolution, glx renderer, version)."
|
||||||
print_screen_output "-i Show Wan IP address, and shows local interfaces (requires ifconfig network tool)."
|
print_screen_output "-i Show Wan IP address, and shows local interfaces (requires ifconfig network tool)."
|
||||||
print_screen_output " Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
|
print_screen_output " Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
|
||||||
print_screen_output "-I Show Information: processes, uptime, memory, irc client, inxi version."
|
print_screen_output "-I Show Information: processes, uptime, memory, irc client, inxi version."
|
||||||
print_screen_output "-l Show partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu)."
|
print_screen_output "-l Show partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu)."
|
||||||
print_screen_output "-N Show Network card information."
|
print_screen_output "-N Show Network card information."
|
||||||
|
print_screen_output "-o Show unmounted partition information (includes UUID and LABEL if available)."
|
||||||
print_screen_output "-p Show full partition information (-P plus all other detected partitions)."
|
print_screen_output "-p Show full partition information (-P plus all other detected partitions)."
|
||||||
print_screen_output "-P Show Partition information (shows what -v 4 would show, but without extra data)."
|
print_screen_output "-P Show Partition information (shows what -v 4 would show, but without extra data)."
|
||||||
print_screen_output " Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted partitions."
|
print_screen_output " Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted partitions."
|
||||||
|
@ -1278,7 +1284,7 @@ print_version_info()
|
||||||
print_screen_output "This script is a fork of Infobash 3.02, which is:"
|
print_screen_output "This script is a fork of Infobash 3.02, which is:"
|
||||||
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
|
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
|
||||||
print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:"
|
print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:"
|
||||||
print_screen_output "Copyright (C) 2008-9 Scott Rogers, Harald Hope, aka trash80 & h2"
|
print_screen_output "Copyright (C) 2008-10 Scott Rogers, Harald Hope, aka trash80 & h2"
|
||||||
print_screen_output ""
|
print_screen_output ""
|
||||||
print_screen_output "This program is free software; you can redistribute it and/or modify"
|
print_screen_output "This program is free software; you can redistribute it and/or modify"
|
||||||
print_screen_output "it under the terms of the GNU General Public License as published by"
|
print_screen_output "it under the terms of the GNU General Public License as published by"
|
||||||
|
@ -3115,6 +3121,61 @@ get_partition_data_advanced()
|
||||||
eval $LOGFE
|
eval $LOGFE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_unmounted_partition_data()
|
||||||
|
{
|
||||||
|
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[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
# Repos will be added as we get distro package manager data to create the repo data.
|
# 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
|
# This method will output the file name also, which is useful to create output that's
|
||||||
# neat and readable.
|
# neat and readable.
|
||||||
|
@ -3680,6 +3741,9 @@ print_it_out()
|
||||||
if [[ $VERBOSITY_LEVEL -ge 4 || $B_SHOW_PARTITIONS == 'true' ]];then
|
if [[ $VERBOSITY_LEVEL -ge 4 || $B_SHOW_PARTITIONS == 'true' ]];then
|
||||||
print_partition_data
|
print_partition_data
|
||||||
fi
|
fi
|
||||||
|
if [[ $B_SHOW_UNMOUNTED_PARTITIONS == 'true' ]];then
|
||||||
|
print_unmounted_partition_data
|
||||||
|
fi
|
||||||
if [[ $VERBOSITY_LEVEL -ge 5 || $B_SHOW_SENSORS == 'true' ]];then
|
if [[ $VERBOSITY_LEVEL -ge 5 || $B_SHOW_SENSORS == 'true' ]];then
|
||||||
print_sensors_data
|
print_sensors_data
|
||||||
fi
|
fi
|
||||||
|
@ -4412,6 +4476,65 @@ print_partition_data()
|
||||||
partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" )
|
partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" )
|
||||||
print_screen_output "$partition_data"
|
print_screen_output "$partition_data"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
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
|
eval $LOGFE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue