New version, new tarball. Improved B_ALLOW_UPDATES handling, now if set to false,

turns off all -h and -H menu options for updating. Also triggers an error message
if you use -U or -! <10-16/http://>.

Distro maintainers, take note, if you used the B_ALLOW_UPDATES flag, you no longer
need to change the code anywhere, the error messages and blocking the -h output for
update features is automatic as soon as the flag is set to 'false'.

I needed to change the -! handling because -! is now also being used for extra features 
like -! 31 and -! 32 and probably more stuff in the future, plus the -! 30 used by 
things like the inxi gui tool being worked on by trash80.

Also included in this version are more bsd changes, including initial function for pciconf
data parsing, this will be used for -A, -G, and -N options for card data.

Further bsd improvements are better error/no data available messages for -D and -o.
This commit is contained in:
inxi-svn 2013-02-28 23:35:53 +00:00
parent 48fa28f1ec
commit 46e36c755b
2 changed files with 162 additions and 40 deletions

175
inxi
View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 1.8.42
#### Date: February 27 2013
#### Version: 1.8.43
#### Date: February 28 2013
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@ -237,9 +237,12 @@ A_UNMOUNTED_PARTITION_DATA=''
A_X_DATA=''
### Boolean true/false globals ## usage: 'B_<var>'
## Distro maintainer flags ##
# flag to allow distro maintainers to turn off update features. If false, turns off
# -U and -! testing/advanced update options, as well as removing the -U help menu item
B_ALLOW_UPDATE='true'
B_ALLOW_WEATHER='false'
## standard boolean flags ##
B_BSD_RAID='false'
B_COLOR_SCHEME_SET='false'
B_CONSOLE_IRC='false'
@ -317,6 +320,7 @@ B_SHOW_SHORT_OUTPUT='false'
B_SHOW_SYSTEM='false'
B_SHOW_UNMOUNTED_PARTITIONS='false'
B_SHOW_UUIDS='false'
B_SHOW_WEATHER='false'
B_SHOW_X_DATA='false'
B_SYSCTL='false'
# triggers various debugging and new option testing
@ -1240,6 +1244,9 @@ error_handler()
16)
error_message="$SCRIPT_NAME downloaded but the file data is corrupted. Purged data and using current version."
;;
17)
error_message="All $SCRIPT_NAME self updater features have been disabled by the distribution\npackage maintainer. This includes the option you used: $2"
;;
20)
error_message="The option you selected has been deprecated. $2\nSee the -h (help) menu for currently supported options."
;;
@ -1989,12 +1996,12 @@ remove_erroneous_chars()
get_parameters()
{
eval $LOGFS
local opt='' wget_test='' update_flags='U!:' debug_data_type=''
local opt='' wget_test='' debug_data_type='' weather_flag='w'
local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
# If distro maintainers want to not allow updates, turn off that option for users
if [[ $B_ALLOW_UPDATE == 'false' ]];then
update_flags=''
# if distro maintainers don't want the weather feature disable it
if [[ $B_ALLOW_WEATHER == 'false' ]];then
weather_flag=''
fi
if [[ $1 == '--version' ]];then
print_version_info
@ -2009,7 +2016,7 @@ get_parameters()
# no need to run through these if there are no args
# reserved for future use: -g for extra Graphics; -m for extra Machine; -d for extra Disk
elif [[ -n $1 ]];then
while getopts Abc:CdDfFGhHiIlMnNopPrRsSt:uv:VxzZ%@:${update_flags} opt
while getopts Abc:CdDfFGhHiIlMnNopPrRsSt:uUv:V${weather_flag}xzZ%@:!: opt
do
case $opt in
A) B_SHOW_AUDIO='true'
@ -2212,7 +2219,11 @@ get_parameters()
error_handler 4 "$OPTARG"
fi
;;
U) script_self_updater "$SCRIPT_DOWNLOAD" 'svn server' "$opt"
U) if [[ $B_ALLOW_UPDATE == 'true' ]];then
script_self_updater "$SCRIPT_DOWNLOAD" 'svn server' "$opt"
else
error_handler 17 "-$opt"
fi
;;
V) print_version_info
exit 0
@ -2291,26 +2302,37 @@ get_parameters()
3) B_TESTING_1='true'
B_TESTING_2='true'
;;
10)
script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG"
;;
11)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server' "$opt $OPTARG"
;;
12)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server' "$opt $OPTARG"
;;
13)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'svn: branch three server' "$opt $OPTARG"
;;
14)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server' "$opt $OPTARG"
;;
15)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_BSD" 'svn: branch bsd server' "$opt $OPTARG"
;;
16)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_GNUBSD" 'svn: branch gnubsd server' "$opt $OPTARG"
1[0-6]|http*)
if [[ $B_ALLOW_UPDATE == 'true' ]];then
case $OPTARG in
10)
script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG"
;;
11)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server' "$opt $OPTARG"
;;
12)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server' "$opt $OPTARG"
;;
13)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'svn: branch three server' "$opt $OPTARG"
;;
14)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server' "$opt $OPTARG"
;;
15)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_BSD" 'svn: branch bsd server' "$opt $OPTARG"
;;
16)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_GNUBSD" 'svn: branch gnubsd server' "$opt $OPTARG"
;;
http*)
script_self_updater "$OPTARG" 'alt server' "$opt <http...>"
;;
esac
else
error_handler 17 "-$opt $OPTARG"
fi
;;
30)
B_RUNNING_IN_SHELL='true'
@ -2324,9 +2346,6 @@ get_parameters()
ftp*)
ALTERNATE_FTP="$OPTARG"
;;
http*)
script_self_updater "$OPTARG" 'alt server' "$opt <http...>"
;;
*) error_handler 11 "$OPTARG"
;;
esac
@ -2441,6 +2460,10 @@ show_options()
print_screen_output " standard raid data (-R)."
print_screen_output " 6 - Full ${partition_string} (-p), unmounted ${partition_string} (-o), optical drive (-d), full raid; triggers -xx."
print_screen_output " 7 - Network IP data (-i); triggers -xxx."
# if distro maintainers don't want the weather feature disable it
if [[ $B_ALLOW_WEATHER == 'true' ]];then
print_screen_output "-w Local weather data. "
fi
print_screen_output "-x Adds the following extra data (only works with verbose or line output, not short form): "
print_screen_output " -C - Bogomips on Cpu;"
print_screen_output " -d - Extra optical drive data; adds rev version to optical drive."
@ -2511,14 +2534,16 @@ show_options()
print_screen_output "-! 1 - Sets testing flag B_TESTING_1='true' to trigger testing condition 1."
print_screen_output "-! 2 - Sets testing flag B_TESTING_2='true' to trigger testing condition 2."
print_screen_output "-! 3 - Sets flags B_TESTING_1='true' and B_TESTING_2='true'."
print_screen_output "-! 10 - Triggers an update from the primary dev download server instead of svn."
print_screen_output "-! 11 - Triggers an update from svn branch one - if present, of course."
print_screen_output "-! 12 - Triggers an update from svn branch two - if present, of course."
print_screen_output "-! 13 - Triggers an update from svn branch three - if present, of course."
print_screen_output "-! 14 - Triggers an update from svn branch four - if present, of course."
print_screen_output "-! 15 - Triggers an update from svn branch BSD - if present, of course."
print_screen_output "-! 16 - Triggers an update from svn branch GNUBSD - if present, of course."
print_screen_output "-! <http://......> - Triggers an update from whatever server you list."
if [[ $B_ALLOW_UPDATE == 'true' ]];then
print_screen_output "-! 10 - Triggers an update from the primary dev download server instead of svn."
print_screen_output "-! 11 - Triggers an update from svn branch one - if present, of course."
print_screen_output "-! 12 - Triggers an update from svn branch two - if present, of course."
print_screen_output "-! 13 - Triggers an update from svn branch three - if present, of course."
print_screen_output "-! 14 - Triggers an update from svn branch four - if present, of course."
print_screen_output "-! 15 - Triggers an update from svn branch BSD - if present, of course."
print_screen_output "-! 16 - Triggers an update from svn branch GNUBSD - if present, of course."
print_screen_output "-! <http://......> - Triggers an update from whatever server you list."
fi
print_screen_output "-! <ftp.......> - Changes debugging data ftp upload location to whatever you enter here."
print_screen_output " Only used together with -xx@ 11-14, and must be used in front of that."
print_screen_output " Example: inxi -! ftp.yourserver.com/incoming -xx@ 14"
@ -6533,6 +6558,58 @@ get_patch_version_string()
echo $patch_version_number
}
get_pciconf_data()
{
eval $LOGFS
local pciconf="$( type -p pciconf 2>/dev/null )"
local pciconf_data=''
if [[ -n $pciconf ]];then
pciconf_data="$( $pciconf -lv 2>/dev/null )"
if [[ -n $pciconf_data ]];then
pciconf_data=$( gawk '
{
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
gsub(/[[:space:]]+=[[:space:]]+/, "=",$0)
gsub(/^[[:space:]]+|'"'"'|\"|,/, "", $0)
gsub(/=0x/,"=",$0)
# line=gensub(/.*[[:space:]]+(class=[^[:space:]]*|card=[^[:space:]]*)|chip=[^[:space:]]*|rev=[^[:space:]]*|hdr=[^[:space:]]*).*/,"\n\\1","g",$0)
line=gensub(/(.*@.*)/,"\n\\1",$0)
print line
}' <<< "$pciconf_data" )
# now insert into arrays
# order: type,
gawk '
BEGIN {
audio=""
graphics=""
nic=""
fullLine=""
driver=""
vendor=""
device=""
class=""
pciId=""
}
/^.*@/ {
while ( getline && $1 !~ /^$/ ) {
driver=gensub(/^([^0-9@]).*/, "\\1", $2 )
if ( $2 == "class=020000" ) {
}
}
fullLine=class ","
}' <<< "$pciconf_data"
fi
else
A_PCICONF_DATA='pciconf-not-installed'
fi
log_function_data "$pciconf_data"
eval $LOGFE
}
# args: $1 - type cpu/mem
get_ps_tcm_data()
{
@ -8416,6 +8493,7 @@ print_hard_disk_data()
IFS="$ORIGINAL_IFS"
local hdd_capacity="${a_hdd_basic_working[0]}"
local hdd_used=${a_hdd_basic_working[1]}
local bsd_unsupported='Hard drive data not yet supported for BSD systems.'
if [[ $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then
## note: the output part of this should be in the print hdd data function, not here
@ -8491,8 +8569,20 @@ print_hard_disk_data()
hdd_data=$( create_print_line "$Line_Starter" "${hdd_model}${CN}" )
print_screen_output "$hdd_data"
fi
# temporary message to indicate not yet supported
if [[ $BSD_TYPE == 'bsd' ]];then
hdd_data=$bsd_unsupported
hdd_data=$( create_print_line "$Line_Starter" "$hdd_data${CN}" )
print_screen_output "$hdd_data"
Line_Starter=' '
fi
else
hdd_data=$( create_print_line "$Line_Starter" "${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})${CN}" )
# temporary message to indicate not yet supported
hdd_data="${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})"
if [[ $BSD_TYPE == 'bsd' ]];then
hdd_data=$bsd_unsupported
fi
hdd_data=$( create_print_line "$Line_Starter" "$hdd_data${CN}" )
print_screen_output "$hdd_data"
Line_Starter=' '
fi
@ -9965,6 +10055,7 @@ print_unmounted_partition_data()
eval $LOGFS
local a_unmounted_data='' line_starter='' unmounted_data='' full_fs=''
local full_dev='' full_size='' full_label='' full_uuid='' full_string=''
local bsd_unsupported='This feature is not yet supported for BSD systems.'
if [[ -z ${A_PARTITION_DATA} ]];then
get_partition_data
@ -10012,6 +10103,10 @@ print_unmounted_partition_data()
else
line_starter=' '
fi
# temporary message to indicate not yet supported
if [[ $BSD_TYPE == 'bsd' ]];then
full_string=$bsd_unsupported
fi
unmounted_data=$( create_print_line "$line_starter" "$full_string" )
print_screen_output "$unmounted_data"
done

View file

@ -1,3 +1,30 @@
=====================================================================================
Version: 1.8.43
Patch Version: 00
Script Date: February 28 2013
-----------------------------------
Changes:
-----------------------------------
New version, new tarball. Improved B_ALLOW_UPDATES handling, now if set to false,
turns off all -h and -H menu options for updating. Also triggers an error message
if you use -U or -! <10-16/http://>.
Distro maintainers, take note, if you used the B_ALLOW_UPDATES flag, you no longer
need to change the code anywhere, the error messages and blocking the -h output for
update features is automatic as soon as the flag is set to 'false'.
I needed to change the -! handling because -! is now also being used for extra features
like -! 31 and -! 32 and probably more stuff in the future, plus the -! 30 used by
things like the inxi gui tool being worked on by trash80.
Also included in this version are more bsd changes, including initial function for pciconf
data parsing, this will be used for -A, -G, and -N options for card data.
Further bsd improvements are better error/no data available messages for -D and -o.
-----------------------------------
-- Harald Hope - Thu, 28 Feb 2013 15:30:07 -0800
=====================================================================================
Version: 1.8.42
Patch Version: 00