From 55d7875ba587d7acc49b9d6cf99a23c2fe9c28a2 Mon Sep 17 00:00:00 2001 From: Harald Hope Date: Sat, 29 Jul 2017 16:41:49 -0700 Subject: [PATCH] New version, new tarball. More optimizations, and fixed a bash 4 syntax regression that would have caused failure on older systems. Also added Bash version checker. Most ps aux data is now searched using bash parameter expansion, and several functions that were in subshells are now printing to globals instead. --- inxi | 514 +++++++++++++++++++++++++------------------------ inxi.changelog | 17 ++ 2 files changed, 284 insertions(+), 247 deletions(-) diff --git a/inxi b/inxi index 87a2065..d4b7817 100755 --- a/inxi +++ b/inxi @@ -1,9 +1,10 @@ #!/usr/bin/env bash ######################################################################## -#### Script Name: inxi -#### Version: 2.3.28 -#### Date: 2017-07-29 -#### Patch Number: 00 +SELF_NAME='inxi' +# don't quote the following, parsers grab these too +SELF_VERSION=2.3.29 +SELF_DATE=2017-07-29 +SELF_PATCH=00 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -413,6 +414,7 @@ B_SUDO_TESTED='false' # echo $BITS ### CONSTANTS/INITIALIZE - SOME MAY BE RESET LATER ### +BASH=${BASH_VERSION%%[^0-9]*} # some bash 4 things can be used but only if tested DCOPOBJ="default" DEBUG=0 # Set debug levels from 1-10 (8-10 trigger logging levels) # Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up' @@ -476,29 +478,26 @@ SUDO_PATH='' ALTERNATE_FTP='' # for data uploads ALTERNATE_WEATHER_LOCATION='' # weather alternate location -SCRIPT_CONFIG_DIR='' -SCRIPT_DATA_DIR='' +SELF_CONFIG_DIR='' +SELF_DATA_DIR='' LOG_FILE='inxi.log' LOG_FILE_1='inxi.1.log' LOG_FILE_2='inxi.2.log' MAN_FILE_DOWNLOAD='https://github.com/smxi/inxi/raw/master/inxi.1.gz' -SCRIPT_NAME='inxi' -SCRIPT_PATCH_NUMBER='' -SCRIPT_PATH='' # filled-in in Main -SCRIPT_VERSION_NUMBER='' # filled-in in Main -SCRIPT_DOWNLOAD='https://github.com/smxi/inxi/raw/master/' -SCRIPT_DOWNLOAD_BRANCH_1='https://github.com/smxi/inxi/raw/one/' -SCRIPT_DOWNLOAD_BRANCH_2='https://github.com/smxi/inxi/raw/two/' -SCRIPT_DOWNLOAD_BRANCH_3='https://github.com/smxi/inxi/raw/three/' -SCRIPT_DOWNLOAD_BRANCH_4='https://github.com/smxi/inxi/raw/four/' -SCRIPT_DOWNLOAD_BRANCH_BSD='https://github.com/smxi/inxi/raw/bsd/' -SCRIPT_DOWNLOAD_BRANCH_GNUBSD='https://github.com/smxi/inxi/raw/gnubsd/' -SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/' +SELF_PATH='' # filled-in in Main +SELF_DOWNLOAD='https://github.com/smxi/inxi/raw/master/' +SELF_DOWNLOAD_BRANCH_1='https://github.com/smxi/inxi/raw/one/' +SELF_DOWNLOAD_BRANCH_2='https://github.com/smxi/inxi/raw/two/' +SELF_DOWNLOAD_BRANCH_3='https://github.com/smxi/inxi/raw/three/' +SELF_DOWNLOAD_BRANCH_4='https://github.com/smxi/inxi/raw/four/' +SELF_DOWNLOAD_BRANCH_BSD='https://github.com/smxi/inxi/raw/bsd/' +SELF_DOWNLOAD_BRANCH_GNUBSD='https://github.com/smxi/inxi/raw/gnubsd/' +SELF_DOWNLOAD_DEV='http://smxi.org/test/' # note, you can use any ip url here as long as it's the only line on the output page. # Also the ip address must be the last thing on that line. If you abuse this ip tool # you will be banned from further access. Most > 24x daily automated queries to it are abuse. WAN_IP_URL='http://smxi.org/opt/ip.php' -KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data) +KONVI_CFG="konversation/scripts/$SELF_NAME.conf" # relative path to $(kde-config --path data) ### INITIALIZE VARIABLES NULL ### ARCH='' # cpu microarchitecture @@ -506,17 +505,24 @@ BSD_TYPE='' BSD_VERSION= CMDL_MAX='' CPU_COUNT_ALPHA='' +CURRENT_KERNEL='' DEV_DISK_ID='' DEV_DISK_LABEL='' DEV_DISK_MAPPER='' DEV_DISK_UUID='' DMIDECODE_DATA='' +DMESG_BOOT_DATA='' DNSTOOL='' DOWNLOADER='wget' IRC_CLIENT='' IRC_CLIENT_VERSION='' +LSPCI_V_DATA='' +LSPCI_N_DATA='' +MEMORY='' PS_THROTTLED='' REPO_DATA='' +SYSCTL_A_DATA='' +UP_TIME='' ### LAYOUT ### # These two determine separators in single line output, to force irc clients not to break off sections @@ -688,20 +694,20 @@ main() eval $LOGFS local color_scheme='' kde_config_app='' - # this will be used by all functions following - local Ps_aux_Data="$( ps aux )" + # this will be used by all functions following, lower case for bash parameter expansion + local Ps_aux_Data="$( ps aux | tr '[:upper:]' '[:lower:]' )" # This function just initializes variables initialize_data # Source global config overrides, needs to be here because some things # can be reset that were set in initialize, but check_required_apps needs - if [[ -s /etc/$SCRIPT_NAME.conf ]];then - source /etc/$SCRIPT_NAME.conf + if [[ -s /etc/$SELF_NAME.conf ]];then + source /etc/$SELF_NAME.conf fi # Source user config variables override /etc/inxi.conf variables - if [[ -s $SCRIPT_CONFIG_DIR/$SCRIPT_NAME.conf ]];then - source $SCRIPT_CONFIG_DIR/$SCRIPT_NAME.conf + if [[ -s $SELF_CONFIG_DIR/$SELF_NAME.conf ]];then + source $SELF_CONFIG_DIR/$SELF_NAME.conf fi set_display_width 'live' # can be reset with -y @@ -717,10 +723,6 @@ main() check_required_apps check_recommended_apps fi - - SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' ) - SCRIPT_PATCH_NUMBER=$( parse_version_data 'patch' ) - # previous source location, check for bugs ## this needs to run before the KONVI stuff is set below @@ -824,7 +826,7 @@ main() # all the pre-start stuff is in place now B_SCRIPT_UP='true' - script_debugger "Debugger: $SCRIPT_NAME is up and running..." + script_debugger "Debugger: $SELF_NAME is up and running..." # then create the output print_it_out @@ -840,42 +842,42 @@ set_user_paths() local b_conf='false' b_data='false' if [[ -n $XDG_CONFIG_HOME ]];then - SCRIPT_CONFIG_DIR=$XDG_CONFIG_HOME + SELF_CONFIG_DIR=$XDG_CONFIG_HOME b_conf=true elif [[ -d $HOME/.config ]];then - SCRIPT_CONFIG_DIR=$HOME/.config + SELF_CONFIG_DIR=$HOME/.config b_conf=true else - SCRIPT_CONFIG_DIR="$HOME/.$SCRIPT_NAME" + SELF_CONFIG_DIR="$HOME/.$SELF_NAME" fi if [[ -n $XDG_DATA_HOME ]];then - SCRIPT_DATA_DIR=$XDG_DATA_HOME/$SCRIPT_NAME + SELF_DATA_DIR=$XDG_DATA_HOME/$SELF_NAME b_data=true elif [[ -d $HOME/.local/share ]];then - SCRIPT_DATA_DIR=$HOME/.local/share/$SCRIPT_NAME + SELF_DATA_DIR=$HOME/.local/share/$SELF_NAME b_data=true else - SCRIPT_DATA_DIR="$HOME/.$SCRIPT_NAME" + SELF_DATA_DIR="$HOME/.$SELF_NAME" fi # note, this used to be created/checked in specific instance, but we'll just do it # universally so it's done at script start. - if [[ ! -d $SCRIPT_DATA_DIR ]];then - mkdir $SCRIPT_DATA_DIR + if [[ ! -d $SELF_DATA_DIR ]];then + mkdir $SELF_DATA_DIR fi - if [[ $b_conf == 'true' && -f $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then - mv -f $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf $SCRIPT_CONFIG_DIR - echo "Moved $SCRIPT_NAME.conf from $HOME/.$SCRIPT_NAME to $SCRIPT_CONFIG_DIR" + if [[ $b_conf == 'true' && -f $HOME/.$SELF_NAME/$SELF_NAME.conf ]];then + mv -f $HOME/.$SELF_NAME/$SELF_NAME.conf $SELF_CONFIG_DIR + echo "Moved $SELF_NAME.conf from $HOME/.$SELF_NAME to $SELF_CONFIG_DIR" fi - if [[ $b_data == 'true' && -d $HOME/.$SCRIPT_NAME ]];then - mv -f $HOME/.$SCRIPT_NAME/* $SCRIPT_DATA_DIR - rm -Rf $HOME/.$SCRIPT_NAME - echo "Moved data dir $HOME/.$SCRIPT_NAME to $SCRIPT_DATA_DIR" + if [[ $b_data == 'true' && -d $HOME/.$SELF_NAME ]];then + mv -f $HOME/.$SELF_NAME/* $SELF_DATA_DIR + rm -Rf $HOME/.$SELF_NAME + echo "Moved data dir $HOME/.$SELF_NAME to $SELF_DATA_DIR" fi - LOG_FILE=$SCRIPT_DATA_DIR/$LOG_FILE - LOG_FILE_1=$SCRIPT_DATA_DIR/$LOG_FILE_1 - LOG_FILE_2=$SCRIPT_DATA_DIR/$LOG_FILE_2 + LOG_FILE=$SELF_DATA_DIR/$LOG_FILE + LOG_FILE_1=$SELF_DATA_DIR/$LOG_FILE_1 + LOG_FILE_2=$SELF_DATA_DIR/$LOG_FILE_2 } #### ------------------------------------------------------------------- @@ -1069,19 +1071,19 @@ parse_version_data() version_data=$( gawk -F ': ' ' /####[[:space:]]+Date:/ { print $NF - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + }' "$SELF_PATH/$SELF_NAME" ) ;; main) version_data=$( gawk ' /####[[:space:]]+Version:/ { print $3 - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + }' "$SELF_PATH/$SELF_NAME" ) ;; patch) version_data=$( gawk ' /####[[:space:]]+Patch Number:/ { print $4 - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + }' "$SELF_PATH/$SELF_NAME" ) ;; esac echo $version_data @@ -1094,7 +1096,7 @@ initialize_paths() local extra_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin" # this needs to be set here because various options call the parent initialize function directly. - SCRIPT_PATH=$( dirname "$0" ) + SELF_PATH=$( dirname "$0" ) # Fallback paths put into $extra_paths; This might, among others, help on gentoo. # Now, create a difference of $PATH and $extra_paths and add that to $PATH: @@ -1182,7 +1184,7 @@ check_required_apps() for app_name in $x_apps do if ! type -p $app_name &>/dev/null;then - script_debugger "Resuming in non X mode: $app_name not found. For package install advice run: $SCRIPT_NAME --recommends" + script_debugger "Resuming in non X mode: $app_name not found. For package install advice run: $SELF_NAME --recommends" B_SHOW_DISPLAY_DATA='false' break fi @@ -1265,7 +1267,7 @@ select_default_color_scheme() { eval $LOGFS local spacer=' ' options='' user_selection='' config_variable='' - local config_file="$SCRIPT_CONFIG_DIR/$SCRIPT_NAME.conf" + local config_file="$SELF_CONFIG_DIR/$SELF_NAME.conf" local irc_clear="" local irc_gui='Unset' irc_console='Unset' irc_x_term='Unset' local console='Unset' virt_term='Unset' global='Unset' @@ -1297,8 +1299,8 @@ select_default_color_scheme() set_color_scheme "0" # print_lines_basic "0" "" "" if [[ $B_IRC == 'false' ]];then - print_lines_basic "0" "" "Welcome to $SCRIPT_NAME! Please select the default $COLOR_SELECTION color scheme." - # print_screen_output "You will see this message only one time per user account, unless you set preferences in: /etc/$SCRIPT_NAME.conf" + print_lines_basic "0" "" "Welcome to $SELF_NAME! Please select the default $COLOR_SELECTION color scheme." + # print_screen_output "You will see this message only one time per user account, unless you set preferences in: /etc/$SELF_NAME.conf" print_screen_output " " fi print_lines_basic "0" "" "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can set your color preferences from color scheme option list below. 0 is no colors, 1 neutral. After these, there are 4 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds; 4-miscellaneous." @@ -1327,11 +1329,11 @@ select_default_color_scheme() if [[ $B_IRC == 'false' ]];then echo -n "" - print_screen_output "$irc_clear $i)${spacer}Remove all color settings. Restore $SCRIPT_NAME default." + print_screen_output "$irc_clear $i)${spacer}Remove all color settings. Restore $SELF_NAME default." print_screen_output "$irc_clear $(($i+1)))${spacer}Continue, no changes or config file setting." print_screen_output "$irc_clear $(($i+2)))${spacer}Exit, use another terminal, or set manually." print_screen_output "$LINE1" - print_lines_basic "0" "" "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c plus one of these numbers:" + print_lines_basic "0" "" "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings and hit ENTER. NOTE: You can bring this option list up by starting $SELF_NAME with option: -c plus one of these numbers:" print_lines_basic "0" "" "94^(console,^no X^-^$console); 95^(terminal,^X^-^$virt_term); 96^(irc,^gui,^X^-^$irc_gui); 97^(irc,^X,^in^terminal^-^$irc_x_term); 98^(irc,^no^X^-^$irc_console); 99^(global^-^$global)" print_lines_basic "0" "" "" print_screen_output "Your selection(s) will be stored here: $config_file" @@ -1387,7 +1389,7 @@ select_default_color_scheme() -e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file set_color_scheme $DEFAULT_COLOR_SCHEME elif [[ $user_selection == $(( $i+1 )) ]];then - print_lines_basic "0" "" "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99" + print_lines_basic "0" "" "Ok, continuing $SELF_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99" if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then set_color_scheme $CONSOLE_COLOR_SCHEME elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then @@ -1397,7 +1399,7 @@ select_default_color_scheme() fi elif [[ $user_selection == $(( $i+2 )) ]];then set_color_scheme $DEFAULT_COLOR_SCHEME - print_screen_output "Ok, exiting $SCRIPT_NAME now. You can set the colors later." + print_screen_output "Ok, exiting $SELF_NAME now. You can set the colors later." exit 0 else print_screen_output "Error - Invalid Selection. You entered this: $user_selection" @@ -1438,18 +1440,18 @@ error_handler() ;; 4) error_message="unsupported verbosity level: $2" ;; - 5) error_message="dependency not met: $2 not found in path.\nFor distribution installation package names and missing apps information, run: $SCRIPT_NAME --recommends" + 5) error_message="dependency not met: $2 not found in path.\nFor distribution installation package names and missing apps information, run: $SELF_NAME --recommends" ;; 6) error_message="/proc not found! Quitting..." ;; - 7) error_message="One of the options you entered in your script parameters: $2\nis not supported.The option may require extra arguments to work.\nFor supported options (and their arguments), check the help menu: $SCRIPT_NAME -h" + 7) error_message="One of the options you entered in your script parameters: $2\nis not supported.The option may require extra arguments to work.\nFor supported options (and their arguments), check the help menu: $SELF_NAME -h" ;; - 8) error_message="the self-updater failed, $DOWNLOADER exited with error: $2.\nYou probably need to be root.\nHint, to make for easy updates without being root, do: chown $SCRIPT_PATH/$SCRIPT_NAME" + 8) error_message="the self-updater failed, $DOWNLOADER exited with error: $2.\nYou probably need to be root.\nHint, to make for easy updates without being root, do: chown $SELF_PATH/$SELF_NAME" ;; 9) error_message="unsupported debugging level: $2" ;; 10) - error_message="the alt download url you provided: $2\nappears to be wrong, download aborted. Please note, the url\nneeds to end in /, without $SCRIPT_NAME, like: http://yoursite.com/downloads/" + error_message="the alt download url you provided: $2\nappears to be wrong, download aborted. Please note, the url\nneeds to end in /, without $SELF_NAME, like: http://yoursite.com/downloads/" ;; 11) error_message="unsupported testing option argument: -! $2" @@ -1461,16 +1463,16 @@ error_handler() error_message="The -t option requires the following extra arguments (no spaces between letters/numbers):\nc m cm [required], for example: -t cm8 OR -t cm OR -t c9\n(numbers: 1-20, > 5 throttled to 5 in irc clients) You entered: $2" ;; 14) - error_message="failed to write correctly downloaded $SCRIPT_NAME to location $SCRIPT_PATH.\nThis usually means you don't have permission to write to that location, maybe you need to be root?\nThe operation failed with error: $2" + error_message="failed to write correctly downloaded $SELF_NAME to location $SELF_PATH.\nThis usually means you don't have permission to write to that location, maybe you need to be root?\nThe operation failed with error: $2" ;; 15) - error_message="failed set execute permissions on $SCRIPT_NAME at location $SCRIPT_PATH.\nThis usually means you don't have permission to set permissions on files there, maybe you need to be root?\nThe operation failed with error: $2" + error_message="failed set execute permissions on $SELF_NAME at location $SELF_PATH.\nThis usually means you don't have permission to set permissions on files there, maybe you need to be root?\nThe operation failed with error: $2" ;; 16) - error_message="$SCRIPT_NAME downloaded but the file data is corrupted. Purged data and using current version." + error_message="$SELF_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" + error_message="All $SELF_NAME self updater features have been disabled by the distribution\npackage maintainer. This includes the option you used: $2" ;; 18) error_message="The argument you provided for $2 does not have supported syntax.\nPlease use the following formatting:\n$3" @@ -1598,7 +1600,7 @@ create_rotate_logfiles() touch $LOG_FILE # and echo the start data echo "=========================================================" >> $LOG_FILE - echo "START $SCRIPT_NAME LOGGING:" >> $LOG_FILE + echo "START $SELF_NAME LOGGING:" >> $LOG_FILE echo "Script started: $( date +%Y-%m-%d-%H:%M:%S )" >> $LOG_FILE echo "=========================================================" >> $LOG_FILE } @@ -1614,26 +1616,26 @@ script_self_updater() local man_file_path="$man_file_location/inxi.1.gz" if [[ $B_IRC == 'true' ]];then - print_screen_output "Sorry, you can't run the $SCRIPT_NAME self updater option (-$3) in an IRC client." + print_screen_output "Sorry, you can't run the $SELF_NAME self updater option (-$3) in an IRC client." exit 1 fi - print_screen_output "Starting $SCRIPT_NAME self updater." - print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER" - print_screen_output "Current version patch number: $SCRIPT_PATCH_NUMBER" - print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH using $2 as download source..." + print_screen_output "Starting $SELF_NAME self updater." + print_screen_output "Currently running $SELF_NAME version number: $SELF_VERSION" + print_screen_output "Current version patch number: $SELF_PATCH" + print_screen_output "Updating $SELF_NAME in $SELF_PATH using $2 as download source..." case $DOWNLOADER in curl) - file_contents="$( curl $NO_SSL_OPT -s $1$SCRIPT_NAME )" || downloader_error=$? + file_contents="$( curl $NO_SSL_OPT -s $1$SELF_NAME )" || downloader_error=$? ;; fetch) - file_contents="$( fetch $NO_SSL_OPT -q -o - $1$SCRIPT_NAME )" || downloader_error=$? + file_contents="$( fetch $NO_SSL_OPT -q -o - $1$SELF_NAME )" || downloader_error=$? ;; ftp) - file_contents="$( ftp $NO_SSL_OPT -o - $1$SCRIPT_NAME 2>/dev/null )" || downloader_error=$? + file_contents="$( ftp $NO_SSL_OPT -o - $1$SELF_NAME 2>/dev/null )" || downloader_error=$? ;; wget) - file_contents="$( wget $NO_SSL_OPT -q -O - $1$SCRIPT_NAME )" || downloader_error=$? + file_contents="$( wget $NO_SSL_OPT -q -O - $1$SELF_NAME )" || downloader_error=$? ;; no-downloader) downloader_error=1 @@ -1644,13 +1646,13 @@ script_self_updater() if [[ $downloader_error -eq 0 ]];then # make sure the whole file got downloaded and is in the variable if [[ -n $( grep '###\*\*EOF\*\*###' <<< "$file_contents" ) ]];then - echo "$file_contents" > $SCRIPT_PATH/$SCRIPT_NAME || error_handler 14 "$?" - chmod +x $SCRIPT_PATH/$SCRIPT_NAME || error_handler 15 "$?" - SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' ) - SCRIPT_PATCH_NUMBER=$( parse_version_data 'patch' ) - print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER" - print_screen_output "New $2 version patch number: $SCRIPT_PATCH_NUMBER" - print_screen_output "To run the new version, just start $SCRIPT_NAME again." + echo "$file_contents" > $SELF_PATH/$SELF_NAME || error_handler 14 "$?" + chmod +x $SELF_PATH/$SELF_NAME || error_handler 15 "$?" + SELF_VERSION=$( parse_version_data 'main' ) + SELF_PATCH=$( parse_version_data 'patch' ) + print_screen_output "Successfully updated to $2 version: $SELF_VERSION" + print_screen_output "New $2 version patch number: $SELF_PATCH" + print_screen_output "To run the new version, just start $SELF_NAME again." print_screen_output "----------------------------------------" print_screen_output "Starting download of man page file now." if [[ ! -d $man_file_location ]];then @@ -1701,7 +1703,7 @@ script_self_updater() fi else print_screen_output "Updating / Installing the Man page requires root user, writing to: $man_file_location" - print_screen_output "If you want the man page, you'll have to run $SCRIPT_NAME -$3 as root." + print_screen_output "If you want the man page, you'll have to run $SELF_NAME -$3 as root." fi fi exit 0 @@ -1764,9 +1766,15 @@ debug_data_collector() local xiin_url="https://github.com/smxi/inxi/raw/xiin/$xiin_file" local Line='-------------------------' root_string='' local start_directory=$( pwd ) - local host="${HOSTNAME,,}" + local host='' local downloader_error=0 debug_i='' + if (( "$BASH" >= 4 ));then + host="${HOSTNAME,,}" + else + host=$( tr '[A-Z]' '[a-z]' <<< "$HOSTNAME" ) + fi + if [[ $B_DEBUG_I == 'true' ]];then debug_i='i' fi @@ -1790,20 +1798,20 @@ debug_data_collector() ftp_upload=$ALTERNATE_FTP fi echo "Starting debugging data collection type: $1" - cd $SCRIPT_DATA_DIR - if [[ -d $SCRIPT_DATA_DIR/$debug_data_dir ]];then + cd $SELF_DATA_DIR + if [[ -d $SELF_DATA_DIR/$debug_data_dir ]];then echo 'Deleting previous xiin data directory...' - rm -rf $SCRIPT_DATA_DIR/$debug_data_dir + rm -rf $SELF_DATA_DIR/$debug_data_dir fi - mkdir $SCRIPT_DATA_DIR/$debug_data_dir - if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then + mkdir $SELF_DATA_DIR/$debug_data_dir + if [[ -f $SELF_DATA_DIR/$debug_data_dir.tar.gz ]];then echo 'Deleting previous tar.gz file...' - rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz + rm -f $SELF_DATA_DIR/$debug_data_dir.tar.gz fi echo 'Collecting system info: sensors, lsusb, lspci, lspci -v data, plus /proc data' echo 'also checking for dmidecode data: note, you must be root to have dmidecode work.' - echo "Data going into: $SCRIPT_DATA_DIR/$debug_data_dir" + echo "Data going into: $SELF_DATA_DIR/$debug_data_dir" # bsd tools http://cb.vu/unixtoolbox.xhtml # freebsd if type -p pciconf &>/dev/null;then @@ -1846,7 +1854,7 @@ debug_data_collector() # fdisk dmidecode &> $debug_data_dir/dmidecode.txt - get_repo_data "$SCRIPT_DATA_DIR/$debug_data_dir" + get_repo_data "$SELF_DATA_DIR/$debug_data_dir" if type -p shopt &>/dev/null;then shopt -s nullglob @@ -1974,7 +1982,7 @@ debug_data_collector() check_recommends_user_output &> $debug_data_dir/check-recommends-user-output.txt # first download and verify xiin if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then - touch $SCRIPT_DATA_DIR/$debug_data_dir/xiin-error.txt + touch $SELF_DATA_DIR/$debug_data_dir/xiin-error.txt echo "Downloading required tree traverse tool $xiin_file..." if [[ -f xiin && ! -f $xiin_file ]];then mv -f xiin $xiin_file @@ -2017,7 +2025,7 @@ debug_data_collector() fi # note, only bash 4> supports ;;& for case, so using if/then here if [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then - xiin_data_file=$SCRIPT_DATA_DIR/$debug_data_dir/xiin-sys.txt + xiin_data_file=$SELF_DATA_DIR/$debug_data_dir/xiin-sys.txt echo 'Collecting networking data...' ifconfig &> $debug_data_dir/ifconfig.txt ip addr &> $debug_data_dir/ip-addr.txt @@ -2214,15 +2222,15 @@ debug_data_collector() cat /etc/mtab &> $debug_data_dir/etc-mtab.txt fi echo 'Creating inxi output file now. This can take a few seconds...' - echo "Starting $SCRIPT_NAME from: $start_directory" + echo "Starting $SELF_NAME from: $start_directory" cd $start_directory - $SCRIPT_PATH/$SCRIPT_NAME -F${debug_i}Rfrploudmxxx -c 0 -@ 8 -y 120 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-F${debug_i}Rfrploudmxxxy120.txt - cp $LOG_FILE $SCRIPT_DATA_DIR/$debug_data_dir - if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then + $SELF_PATH/$SELF_NAME -F${debug_i}Rfrploudmxxx -c 0 -@ 8 -y 120 > $SELF_DATA_DIR/$debug_data_dir/inxi-F${debug_i}Rfrploudmxxxy120.txt + cp $LOG_FILE $SELF_DATA_DIR/$debug_data_dir + if [[ -f $SELF_DATA_DIR/$debug_data_dir.tar.gz ]];then echo "Found and removing previous tar.gz data file: $debug_data_dir.tar.gz" - rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz + rm -f $SELF_DATA_DIR/$debug_data_dir.tar.gz fi - cd $SCRIPT_DATA_DIR + cd $SELF_DATA_DIR echo 'Creating tar.gz compressed file of this material now. Contents:' echo $Line tar -cvzf $debug_data_dir.tar.gz $debug_data_dir @@ -2237,7 +2245,7 @@ debug_data_collector() echo "Data in gz is corrupted, removed gzip file" >> $debug_data_dir/gzip-error.txt else echo 'All done, you can find your data gzipped directory here:' - completed_gz_file=$SCRIPT_DATA_DIR/$debug_data_dir.tar.gz + completed_gz_file=$SELF_DATA_DIR/$debug_data_dir.tar.gz echo $completed_gz_file if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then echo $Line @@ -2281,7 +2289,7 @@ check_recommends_user_output() ftp:ftp-OpenBSD-only~ftp-OpenBSD-only~ftp-OpenBSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(OpenBSD_only)' fi initialize_paths - print_lines_basic "0" "" "$SCRIPT_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SCRIPT_NAME uses. Python is only for debugging data collection." + print_lines_basic "0" "" "$SELF_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SELF_NAME uses. Python is only for debugging data collection." echo $Line echo "Bash version: $( bash --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU bash/ {print $4}' )" if type -p gawk &>/dev/null;then @@ -2307,22 +2315,22 @@ check_recommends_user_output() echo $Line echo "Test One: Required System Directories (Linux Only)." - print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:" + print_lines_basic "0" "" "If one of these system directories is missing, $SELF_NAME cannot operate:" echo check_recommends_items 'required-dirs' echo "Test Two: Required Core Applications." - print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME cannot operate:" + print_lines_basic "0" "" "If one of these applications is missing, $SELF_NAME cannot operate:" echo check_recommends_items 'required-apps' print_lines_basic "0" "" "Test Three: Script Recommends for Graphics Features." - print_lines_basic "0" "" "NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications is missing, $SCRIPT_NAME will have incomplete output:" + print_lines_basic "0" "" "NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications is missing, $SELF_NAME will have incomplete output:" echo check_recommends_items 'recommended-x-apps' echo 'Test Four: Script Recommends for Remaining Features.' - print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:" + print_lines_basic "0" "" "If one of these applications is missing, $SELF_NAME will have incomplete output:" echo check_recommends_items 'recommended-apps' @@ -2333,13 +2341,13 @@ check_recommends_user_output() echo 'Test Six: System Directories for Various Information.' echo '(Unless otherwise noted, these are for GNU/Linux systems)' - print_lines_basic "0" "" "If one of these directories is missing, $SCRIPT_NAME may have incomplete output:" + print_lines_basic "0" "" "If one of these directories is missing, $SELF_NAME may have incomplete output:" echo check_recommends_items 'system-dirs' echo 'Test Seven: System Files for Various Information.' echo '(Unless otherwise noted, these are for GNU/Linux systems)' - print_lines_basic "0" "" "If one of these files is missing, $SCRIPT_NAME may have incomplete output:" + print_lines_basic "0" "" "If one of these files is missing, $SELF_NAME may have incomplete output:" echo check_recommends_items 'system-files' @@ -2879,7 +2887,7 @@ get_parameters() fi ;; U) if [[ $B_ALLOW_UPDATE == 'true' ]];then - script_self_updater "$SCRIPT_DOWNLOAD" 'source server' "$opt" + script_self_updater "$SELF_DOWNLOAD" 'source server' "$opt" else error_handler 17 "-$opt" fi @@ -2986,25 +2994,25 @@ get_parameters() if [[ $B_ALLOW_UPDATE == 'true' ]];then case $OPTARG in 10) - script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG" ;; 11) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'branch one server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_1" 'branch one server' "$opt $OPTARG" ;; 12) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'branch two server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_2" 'branch two server' "$opt $OPTARG" ;; 13) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'branch three server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_3" 'branch three server' "$opt $OPTARG" ;; 14) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'branch four server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_4" 'branch four server' "$opt $OPTARG" ;; 15) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_BSD" 'branch bsd server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_BSD" 'branch bsd server' "$opt $OPTARG" ;; 16) - script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_GNUBSD" 'branch gnubsd server' "$opt $OPTARG" + script_self_updater "$SELF_DOWNLOAD_BRANCH_GNUBSD" 'branch gnubsd server' "$opt $OPTARG" ;; http*) script_self_updater "$OPTARG" 'alt server' "$opt " @@ -3096,18 +3104,18 @@ show_options() # print_lines_basic "1" "" "" # print_lines_basic "2" "" "" # print_screen_output " " - print_lines_basic "0" "" "$SCRIPT_NAME supports the following options. You can combine them, or list them one by one. Examples: $SCRIPT_NAME^-v4^-c6 OR $SCRIPT_NAME^-bDc^6. If you start $SCRIPT_NAME with no arguments, it will show the short form." + print_lines_basic "0" "" "$SELF_NAME supports the following options. You can combine them, or list them one by one. Examples: $SELF_NAME^-v4^-c6 OR $SELF_NAME^-bDc^6. If you start $SELF_NAME with no arguments, it will show the short form." print_screen_output " " print_lines_basic "0" "" "The following options if used without -F, -b, or -v will show just option line(s): A, B, C, D, G, I, M, N, P, R, S, f, i, m, n, o, p, l, u, r, s, t - you can use these alone or together to show just the line(s) you want to see. If you use them with -v^[level], -b or -F, it will show the full output for that line along with the output for the chosen verbosity level." print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -" print_screen_output "Output Control Options:" print_lines_basic "1" "-A" "Audio/sound card information." - print_lines_basic "1" "-b" "Basic output, short form. Like $SCRIPT_NAME^-v^2, only minus hard disk names ." + print_lines_basic "1" "-b" "Basic output, short form. Like $SELF_NAME^-v^2, only minus hard disk names ." print_lines_basic "1" "-B" "Battery info, shows charge, condition, plus extra information (if battery present)." - print_lines_basic "1" "-c" "Color schemes. Scheme number is required. Color selectors run a color selector option prior to $SCRIPT_NAME starting which lets you set the config file value for the selection." - print_lines_basic "1" "" "Supported color schemes: 0-$color_scheme_count Example:^$SCRIPT_NAME^-c^11" + print_lines_basic "1" "-c" "Color schemes. Scheme number is required. Color selectors run a color selector option prior to $SELF_NAME starting which lets you set the config file value for the selection." + print_lines_basic "1" "" "Supported color schemes: 0-$color_scheme_count Example:^$SELF_NAME^-c^11" print_lines_basic "1" "" "Color selectors for each type display (NOTE: irc and global only show safe color set):" -# print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11" +# print_screen_output " Supported color schemes: 0-$color_scheme_count Example: $SELF_NAME -c 11" # print_screen_output " Color selectors for each type display (NOTE: irc and global only show safe color set):" print_lines_basic "2" "94" "Console, out of X" print_lines_basic "2" "95" "Terminal, running in X - like xTerm" @@ -3119,11 +3127,11 @@ show_options() print_lines_basic "1" "-d" "Optical drive data (and floppy disks, if present). Same as -Dd. See also -x and -xx." print_lines_basic "1" "-D" "Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx. Disk total used percentage includes swap partition size(s)." print_lines_basic "1" "-f" "All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'." - print_lines_basic "1" "-F" "Full output for $SCRIPT_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -d -f -l -m -o -p -r -t -u -x" + print_lines_basic "1" "-F" "Full output for $SELF_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -d -f -l -m -o -p -r -t -u -x" print_lines_basic "1" "-G" "Graphic card information (card, display server type/version, resolution, renderer, OpenGL version)." print_lines_basic "1" "-i" "Wan IP address, and shows local interfaces (requires ifconfig network tool). Same as -Nni. Not shown with -F for user security reasons, you shouldn't paste your local/wan IP." - print_lines_basic "1" "-I" "Information: processes, uptime, memory, irc client (or shell type), $SCRIPT_NAME version." + print_lines_basic "1" "-I" "Information: processes, uptime, memory, irc client (or shell type), $SELF_NAME version." print_lines_basic "1" "-l" "$partition_string_u labels. Default: short $partition_string -P. For full -p output, use: -pl (or -plu)." print_lines_basic "1" "-m" "Memory (RAM) data. Physical system memory array(s), capacity, how many devices (slots) supported, and individual memory devices (sticks of memory etc). For devices, shows device locator, size, speed, type (like: DDR3). If neither -I nor -tm are selected, also shows ram used/total. Also see -x, -xx, -xxx" print_lines_basic "1" "-M" "Machine data. Device type (desktop, server, laptop, VM etc.), Motherboard, Bios, and if present, System Builder (Like Lenovo). Shows UEFI/BIOS/UEFI [Legacy}. Older systems/kernels without the required /sys data can use dmidecode instead, run as root. Dmidecode can be forced with -! 33" @@ -3140,10 +3148,10 @@ show_options() print_lines_basic "1" "" "Make sure to have no space between letters and numbers (-t^cm10 - right, -t^cm^10 - wrong)." print_lines_basic "1" "-u" "$partition_string_u UUIDs. Default: short $partition_string -P. For full -p output, use: -pu (or -plu)." print_lines_basic "1" "-v" "Script verbosity levels. Verbosity level number is required. Should not be used with -b or -F" - print_lines_basic "1" "" "Supported levels: 0-$VERBOSITY_LEVELS Example: $SCRIPT_NAME^-v^4" - print_lines_basic "2" "0" "Short output, same as: $SCRIPT_NAME" + print_lines_basic "1" "" "Supported levels: 0-$VERBOSITY_LEVELS Example: $SELF_NAME^-v^4" + print_lines_basic "2" "0" "Short output, same as: $SELF_NAME" print_lines_basic "2" "1" "Basic verbose, -S + basic CPU + -G + basic Disk + -I." - print_lines_basic "2" "2" "Networking card (-N), Machine (-M) data, if present, Battery (-B), basic hard disk data (names only), and, if present, basic raid (devices only, and if inactive, notes that). similar to: $SCRIPT_NAME^-b" + print_lines_basic "2" "2" "Networking card (-N), Machine (-M) data, if present, Battery (-B), basic hard disk data (names only), and, if present, basic raid (devices only, and if inactive, notes that). similar to: $SELF_NAME^-b" print_lines_basic "2" "3" "Advanced CPU (-C), battery, network (-n) data, and switches on -x advanced data option." print_lines_basic "2" "4" "$partition_string_u size/filled data (-P) for (if present): /, /home, /var/, /boot. Shows full disk data (-D)." print_lines_basic "2" "5" "Audio card (-A); sensors^(-s), memory/ram^(-m), $partition_string label^(-l) and UUID^(-u), short form of optical drives, standard raid data (-R)." @@ -3153,7 +3161,7 @@ show_options() # if distro maintainers don't want the weather feature disable it if [[ $B_ALLOW_WEATHER == 'true' ]];then print_lines_basic "1" "-w" "Local weather data/time. To check an alternate location, see: -W^. For extra weather data options see -x, -xx, and -xxx." - print_lines_basic "1" "-W" " Supported options for : postal code; city, state/country; latitude, longitude. Only use if you want the weather somewhere other than the machine running $SCRIPT_NAME. Use only ascii characters, replace spaces in city/state/country names with '+'. Example:^$SCRIPT_NAME^-W^new+york,ny" + print_lines_basic "1" "-W" " Supported options for : postal code; city, state/country; latitude, longitude. Only use if you want the weather somewhere other than the machine running $SELF_NAME. Use only ascii characters, replace spaces in city/state/country names with '+'. Example:^$SELF_NAME^-W^new+york,ny" fi print_lines_basic "1" "-x" "Adds the following extra data (only works with verbose or line output, not short form):" print_lines_basic "2" "-B" "Vendor/model, status (if available)" @@ -3188,7 +3196,7 @@ show_options() if [[ $B_ALLOW_WEATHER == 'true' ]];then print_lines_basic "2" "-w -W" "Humidity, barometric pressure." fi - print_lines_basic "2" "-@ 11-14" "Automatically uploads debugger data tar.gz file to ftp.techpatterns.com. EG: $SCRIPT_NAME^-xx@14" + print_lines_basic "2" "-@ 11-14" "Automatically uploads debugger data tar.gz file to ftp.techpatterns.com. EG: $SELF_NAME^-xx@14" print_lines_basic "1" "-xxx" "Show extra, extra, extra data (only works with verbose or line output, not short form):" print_lines_basic "2" "-B" "chemistry, cycles, location (if available)." print_lines_basic "2" "-m" "Width of memory bus, data and total (if present and greater than data); Detail, if present, for Type; module voltage, if available." @@ -3203,15 +3211,15 @@ show_options() print_screen_output "Additional Options:" print_lines_basic "4" "-h --help" "This help menu." print_lines_basic "4" "-H" "This help menu, plus developer options. Do not use dev options in normal operation!" - print_lines_basic "4" "--recommends" "Checks $SCRIPT_NAME application dependencies + recommends, and directories, then shows what package(s) you need to install to add support for that feature. " + print_lines_basic "4" "--recommends" "Checks $SELF_NAME application dependencies + recommends, and directories, then shows what package(s) you need to install to add support for that feature. " if [[ $B_ALLOW_UPDATE == 'true' ]];then print_lines_basic "4" "-U" "Auto-update script. Will also install/update man page. Note: if you installed as root, you must be root to update, otherwise user is fine. Man page installs require root user mode." fi - print_lines_basic "4" "-V --version" "$SCRIPT_NAME version information. Prints information then exits." + print_lines_basic "4" "-V --version" "$SELF_NAME version information. Prints information then exits." print_screen_output " " print_screen_output "Debugging Options:" print_lines_basic "1" "-%" "Overrides defective or corrupted data." - print_lines_basic "1" "-@" "Triggers debugger output. Requires debugging level 1-14 (8-10 - logging of data). Less than 8 just triggers $SCRIPT_NAME debugger output on screen." + print_lines_basic "1" "-@" "Triggers debugger output. Requires debugging level 1-14 (8-10 - logging of data). Less than 8 just triggers $SELF_NAME debugger output on screen." print_lines_basic "2" "1-7" "On screen debugger output" print_lines_basic "2" "8" "Basic logging" print_lines_basic "2" "9" "Full file/sys info logging" @@ -3378,7 +3386,7 @@ print_lines_basic() print_version_info() { # if not in PATH could be either . or directory name, no slash starting - local script_path=$SCRIPT_PATH script_symbolic_start='' + local script_path=$SELF_PATH script_symbolic_start='' if [[ $script_path == '.' ]];then script_path=$( pwd ) elif [[ -z $( grep '^/' <<< "$script_path" ) ]];then @@ -3386,15 +3394,12 @@ print_version_info() fi # handle if it's a symbolic link, rare, but can happen with script directories in irc clients # which would only matter if user starts inxi with -! 30 override in irc client - if [[ -L $script_path/$SCRIPT_NAME ]];then - script_symbolic_start=$script_path/$SCRIPT_NAME - script_path=$( readlink $script_path/$SCRIPT_NAME ) + if [[ -L $script_path/$SELF_NAME ]];then + script_symbolic_start=$script_path/$SELF_NAME + script_path=$( readlink $script_path/$SELF_NAME ) script_path=$( dirname $script_path ) fi - local last_modified=$( parse_version_data 'date' ) - local year_modified=$( gawk '{print $NF}' <<< "$last_modified" ) - - print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)" + print_screen_output "$SELF_NAME $SELF_VERSION-$SELF_PATCH ($SELF_DATE)" if [[ $B_IRC == 'false' ]];then print_screen_output "Program Location: $script_path" if [[ -n $script_symbolic_start ]];then @@ -3404,7 +3409,7 @@ print_version_info() print_lines_basic "0" "" "IRC:^irc.oftc.net channel:^#smxi" print_lines_basic "0" "" "Forums:^http://techpatterns.com/forums/forum-33.html" print_screen_output " " - print_lines_basic "0" "" "$SCRIPT_NAME - the universal, portable, system information tool for console and irc." + print_lines_basic "0" "" "$SELF_NAME - the universal, portable, system information tool for console and irc." print_screen_output " " print_lines_basic "0" "" "This program started life as a fork of Infobash 3.02: Copyright^(C)^2005-2007^Michiel^de^Boer^a.k.a.^locsmif." print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright^(C)^2008-${year_modified%%-*}^Harald^Hope,^Scott^Rogers,^aka^h2^&trash80." @@ -3440,7 +3445,12 @@ get_start_client() Irc_Client_Path=$( readlink /proc/$PPID/exe ) # Irc_Client_Path=$( ps -p $PPID | gawk '!/[[:space:]]*PID/ {print $5}' ) # echo $( ps -p $PPID ) - irc_client_path_lower=${Irc_Client_Path,,} + if (( "$BASH" >= 4 ));then + irc_client_path_lower=${Irc_Client_Path,,} + else + irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< "$Irc_Client_Path" ) + fi + App_Working_Name=${irc_client_path_lower##*/} # handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where clients # report themselves as perl or unknown shell. IE: when konversation starts inxi @@ -3457,7 +3467,11 @@ get_start_client() fi if [[ -n $pppid && -f /proc/$pppid/exe ]];then Irc_Client_Path="$( readlink /proc/$pppid/exe )" - irc_client_path_lower=${Irc_Client_Path,,} + if (( "$BASH" >= 4 ));then + irc_client_path_lower=${Irc_Client_Path,,} + else + irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< "$Irc_Client_Path" ) + fi App_Working_Name=${irc_client_path_lower##*/} B_Non_Native_App='true' fi @@ -3499,7 +3513,11 @@ get_start_client() if [[ -n $App_Working_Name ]];then Irc_Client_Path=$App_Working_Name - irc_client_path_lower=${Irc_Client_Path,,} + if (( "$BASH" >= 4 ));then + irc_client_path_lower=${Irc_Client_Path,,} + else + irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< "$Irc_Client_Path" ) + fi App_Working_Name=${irc_client_path_lower##*/} B_Non_Native_App='false' get_irc_client_version @@ -3911,7 +3929,7 @@ get_audio_data() IFS=$'\n' # this first step handles the drivers for cases where the second step fails to find one - device_count=$( echo "$Lspci_v_Data" | grep -iEc '(multimedia audio controller|audio device)' ) + device_count=$( echo "$LSPCI_V_DATA" | grep -iEc '(multimedia audio controller|audio device)' ) if [[ $device_count -eq 1 ]] && [[ $B_ASOUND_DEVICE_FILE == 'true' ]];then audio_driver=$( gawk -F ']: ' ' BEGIN { @@ -3934,7 +3952,7 @@ get_audio_data() audio_driver=$( echo $audio_driver ) # now we'll build the main audio data, card name, driver, and port. If no driver is found, # and if the first method above is not null, and one card is found, it will use that instead. - A_AUDIO_DATA=( $( echo "$Lspci_v_Data" | gawk -F ': ' -v audioDriver="$audio_driver" ' + A_AUDIO_DATA=( $( echo "$LSPCI_V_DATA" | gawk -F ': ' -v audioDriver="$audio_driver" ' BEGIN { IGNORECASE=1 } @@ -4566,11 +4584,11 @@ get_cpu_core_count() } END { print coreCount - }' <<< "$Sysctl_a_Data" ) + }' <<< "$SYSCTL_A_DATA" ) cores_per_cpu=$( gawk -F "$gawk_fs" ' /^machdep.cpu.cores_per_package/ { print $NF - }' <<< "$Sysctl_a_Data" ) + }' <<< "$SYSCTL_A_DATA" ) if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then get_cpu_core_count_alpha "$cpu_core_count" @@ -4842,8 +4860,8 @@ get_cpu_data_bsd() fi # avoid setting this for systems where you have no read/execute permissions # might be cases where the dmesg boot file was readable but sysctl perms failed - if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then - if [[ -n $Dmesg_Boot_Data ]];then + if [[ -n $SYSCTL_A_DATA || -n $bsd_cpu_flags ]];then + if [[ -n $DMESG_BOOT_DATA ]];then cpu_max=$( gawk -F ':' ' BEGIN { IGNORECASE=1 @@ -4862,7 +4880,7 @@ get_cpu_data_bsd() print max exit } - }' <<< "$Dmesg_Boot_Data" ) + }' <<< "$DMESG_BOOT_DATA" ) fi IFS=$'\n' A_CPU_DATA=( $( @@ -4963,7 +4981,7 @@ get_cpu_data_bsd() print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor # triggers print case, for architecture, check source for syntax print cpuClock "," min "," max ",,,," - }' <<< "$Sysctl_a_Data" ) ) + }' <<< "$SYSCTL_A_DATA" ) ) IFS="$ORIGINAL_IFS" fi @@ -4977,7 +4995,7 @@ get_cpu_flags_bsd() local cpu_flags='' local gawk_fs=':' - if [[ -n $Dmesg_Boot_Data ]];then + if [[ -n $DMESG_BOOT_DATA ]];then cpu_flags=$( gawk -v bsdVersion="$BSD_VERSION" -F ":" ' BEGIN { IGNORECASE=1 @@ -4997,8 +5015,8 @@ get_cpu_flags_bsd() cpuFlags=tolower(cpuFlags) print cpuFlags exit - }' <<< "$Dmesg_Boot_Data" ) - elif [[ -n $Sysctl_a_Data ]];then + }' <<< "$DMESG_BOOT_DATA" ) + elif [[ -n $SYSCTL_A_DATA ]];then if [[ $BSD_VERSION == 'openbsd' ]];then gawk_fs=':' fi @@ -5010,7 +5028,7 @@ get_cpu_flags_bsd() cpuFlags=tolower($NF) print cpuFlags exit - }' <<< "$Sysctl_a_Data" ) + }' <<< "$SYSCTL_A_DATA" ) fi echo $cpu_flags log_function_data "$cpu_flags" @@ -5426,7 +5444,7 @@ get_desktop_environment() fi desktop_environment="Xfce" elif [[ -n $( grep -is 'BLACKBOX_PID' <<< "$xprop_root" ) ]];then - if [[ -n $( grep -is 'fluxbox' <<< "$Ps_aux_Data" ) ]];then + if [[ -z "${Ps_aux_Data/*fluxbox*/}" ]];then version=$( get_program_version 'fluxbox' '^fluxbox' '2' ) desktop_environment='Fluxbox' else @@ -5435,17 +5453,16 @@ get_desktop_environment() elif [[ -n $( grep -is 'OPENBOX_PID' <<< "$xprop_root" ) ]];then # note: openbox-lxde --version may be present, but returns openbox data version=$( get_program_version 'openbox' '^openbox' '2' ) - if [[ $XDG_CURRENT_DESKTOP == 'LXDE' || \ - -n $( grep -is '/lxsession' <<< "$Ps_aux_Data" ) ]];then + if [[ $XDG_CURRENT_DESKTOP == 'LXDE' || -z "${Ps_aux_Data/*\/lxsession*/}" ]];then if [[ -n $version ]];then version="(Openbox $version)" fi desktop_environment='LXDE' elif [[ $XDG_CURRENT_DESKTOP == 'Razor' || $XDG_CURRENT_DESKTOP == 'LXQt' ]] || \ [[ -n $( grep -Eis '(razor-desktop|lxqt-session)' <<< "$Ps_aux_Data" ) ]];then - if [[ -n $( grep -is 'lxqt-session' <<< "$Ps_aux_Data" ) ]];then + if [[ -z "${Ps_aux_Data/*lxqt-session*/}" ]];then desktop_environment='LXQt' - elif [[ -n $( grep -is 'razor-desktop' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*razor-desktop*/}" ]];then desktop_environment='Razor-Qt' else desktop_environment='LX-Qt-Variant' @@ -5845,9 +5862,9 @@ get_device_vm() fi # this will catch many Linux systems and some BSDs if [[ $vm == 'other-vm?' || $vm == 'bochs' ]];then - vm_data=$vm_data$Lspci_v_Data - vm_data=$vm_data$Sysctl_a_Data - vm_data=$vm_data$Dmesg_Boot_Data + vm_data=$vm_data$LSPCI_V_DATA + vm_data=$vm_data$SYSCTL_A_DATA + vm_data=$vm_data$DMESG_BOOT_DATA if [[ -e /dev/disk/by-id ]];then vm_data=$vm_data$(ls -l /dev/disk/by-id 2>/dev/null ) fi @@ -5918,7 +5935,7 @@ get_display_manager() # might add this in, but the rate of new dm's makes it more likely it's an unknown dm, so # we'll keep output to N/A if [[ -n $x_is_running && -z $dm ]];then - if [[ -n $( grep 'startx$' <<< "$Ps_aux_Data" ) ]];then + if [[ -z "${Ps_aux_Data/*startx*/}" ]];then dm='(startx)' fi fi @@ -6381,8 +6398,8 @@ get_dmesg_boot_data() print $0 }' )" fi - echo "$dmsg_boot_data" - # log_function_data "$dmsg_boot_data" + DMESG_BOOT_DATA="$dmsg_boot_data" + log_function_data "$dmsg_boot_data" eval $LOGFE } @@ -6570,7 +6587,7 @@ get_graphics_card_data() print card "," busId "," driver # print card "," busId "," driver > "/dev/tty" } - }' <<< "$Lspci_v_Data" ) ) + }' <<< "$LSPCI_V_DATA" ) ) IFS="$ORIGINAL_IFS" # for (( i=0; i < ${#A_GRAPHICS_CARD_DATA[@]}; i++ )) # do @@ -6578,7 +6595,7 @@ get_graphics_card_data() # done # GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory.. - # GFXMEM="size=[$(echo "$Lspci_v_Data" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size= 4 ));then + modules="${modules,,}" + else + modules=$( tr '[A-Z]' '[a-z]' <<< "$modules" ) + fi modules=${modules//-/_} # special intel processing, generally no version info though if [[ $modules == 'hda intel' ]];then @@ -14512,8 +14531,7 @@ print_partition_data() # legacy not used print_program_version() { - local patch_version_number=$( get_patch_version_string ) - local program_version="${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number${CN}" + local program_version="${C1}$SELF_NAME$SEP3${C2} $SELF_VERSION$SELF_PATCH${CN}" # great trick from: http://ideatrash.net/2011/01/bash-string-padding-with-sed.html # left pad: sed -e :a -e 's/^.\{1,80\}$/& /;ta' # right pad: sed -e :a -e 's/^.\{1,80\}$/ &/;ta' @@ -14549,7 +14567,7 @@ print_ps_item() eval $LOGFS local a_ps_data='' ps_data='' line_starter='' line_start_data='' full_line='' local app_name='' app_pid='' app_cpu='' app_mem='' throttled='' app_daemon='' - local b_print_first=$2 line_counter=0 i=0 count_nu='' extra_data='' memory='' extra_text='' + local b_print_first=$2 line_counter=0 i=0 count_nu='' extra_data='' memory_info='' extra_text='' if [[ -n $PS_THROTTLED ]];then throttled=" ${C1} - throttled from${C2} $PS_THROTTLED" @@ -14560,19 +14578,21 @@ print_ps_item() if [[ $B_EXTRA_DATA == 'true' ]];then extra_text=" ${C1}- Memory$SEP3 MB / % used" if [[ $B_SHOW_INFO == 'false' && $B_SHOW_PS_MEM_DATA == 'false' ]];then - memory=" - ${C1}Used/Total$SEP3${C2} $( get_memory_data )" + get_memory_data + memory_info=" - ${C1}Used/Total$SEP3${C2} $MEMORY" fi fi - line_start_data="${C1}CPU$SEP3 % used$extra_text$memory${C1} - top${C2} $PS_COUNT ${C1}active$throttled" + line_start_data="${C1}CPU$SEP3 % used$extra_text$memory_info${C1} - top${C2} $PS_COUNT ${C1}active$throttled" ;; mem) if [[ $B_EXTRA_DATA == 'true' ]];then extra_text=" ${C1}- CPU$SEP3 % used" fi if [[ $B_SHOW_INFO == 'false' ]];then - memory=" - ${C1}Used/Total$SEP3${C2} $( get_memory_data )" + get_memory_data + memory_info=" - ${C1}Used/Total$SEP3${C2} $MEMORY" fi - line_start_data="${C1}Memory$SEP3 MB / % used$memory$extra_text${C1} - top${C2} $PS_COUNT ${C1}active$throttled" + line_start_data="${C1}Memory$SEP3 MB / % used$memory_info$extra_text${C1} - top${C2} $PS_COUNT ${C1}active$throttled" ;; esac @@ -14950,7 +14970,8 @@ print_ram_data() memory_line="${C2}$error_string" else if [[ $B_SHOW_INFO == 'false' && $B_SHOW_PS_MEM_DATA == 'false' ]];then - memory_info="${C1}Used/Total$SEP3${C2} $( get_memory_data )" + get_memory_data + memory_info="${C1}Used/Total$SEP3${C2} $MEMORY" fi for (( i=0;i<${#A_MEMORY_DATA[@]};i++ )) do @@ -15230,7 +15251,7 @@ print_repo_data() else repo_type="package manager" fi - repo_full=$( create_print_line "Repos:" "${C1}Error$SEP3${C2} No repo data detected. Does $SCRIPT_NAME support your $repo_type?" ) + repo_full=$( create_print_line "Repos:" "${C1}Error$SEP3${C2} No repo data detected. Does $SELF_NAME support your $repo_type?" ) print_screen_output "$repo_full" fi eval $LOGFE @@ -15388,14 +15409,13 @@ print_system_data() local de_string='' distro_string='' line_starter='System:' local host_kernel_string='' host_string='' desktop_type='Desktop' local host_name=$HOSTNAME - local current_kernel=$( get_kernel_version ) local distro="$( get_distro_data )" local tty_session='' compiler_string='' distro_os='Distro' if [[ -n $BSD_TYPE ]];then distro_os='OS' fi - + get_kernel_version # I think these will work, maybe, if logged in as root and in X if [[ $B_RUNNING_IN_DISPLAY == 'true' ]];then desktop_environment=$( get_desktop_environment ) @@ -15463,7 +15483,7 @@ print_system_data() fi host_string="${C1}Host$SEP3${C2} $host_name " fi - host_kernel_string="$host_string${C1}Kernel$SEP3${C2} $current_kernel$bits " + host_kernel_string="$host_string${C1}Kernel$SEP3${C2} $CURRENT_KERNEL$bits " de_string="${C1}$desktop_type$SEP3${C2} $desktop_environment$de_extra_data$dm_data " distro_string="${C1}$distro_os$SEP3${C2} $distro " diff --git a/inxi.changelog b/inxi.changelog index 918a749..28475b7 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,20 @@ + +===================================================================================== +Version: 2.3.29 +Patch Version: +Script Date: 2017-07-29 +----------------------------------- +Changes: +----------------------------------- +New version, new tarball. More optimizations, and fixed a bash 4 syntax regression that +would have caused failure on older systems. Also added Bash version checker. + +Most ps aux data is now searched using bash parameter expansion, and several functions +that were in subshells are now printing to globals instead. + +----------------------------------- +-- Harald Hope - Sat, 29 Jul 2017 16:37:01 -0700 + ===================================================================================== Version: 2.3.28 Patch Version: 00