diff --git a/inxi b/inxi index 17b8d1f..0cacf3f 100755 --- a/inxi +++ b/inxi @@ -1,9 +1,10 @@ #!/usr/bin/env bash ######################################################################## -#### Script Name: inxi -#### Version: 2.2.20 -#### Date: 2015-05-11 -#### Patch Number: 01-b1 +SELF_NAME='inxi' +# don't quote the following, parsers grab these too +SELF_VERSION=2.3.35 +SELF_DATE=2017-08-11 +SELF_PATCH=03 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -20,14 +21,20 @@ #### Gaim/Pidgin, Weechat, KVIrc and Kopete. #### Original infobash author and copyright holder: #### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif -#### inxi version: Copyright (C) 2008-2015 Scott Rogers & Harald Hope +#### inxi version: Copyright (C) 2008-2017 Harald Hope +#### Additional features (C) Scott Rogers - kde, cpu info #### Further fixes (listed as known): Horst Tritremmel #### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch #### Jarett.Stevens - dmidecde -M patch for older systems with the /sys #### -#### Current script home page/wiki/svn: http://inxi.googlecode.com +#### Current script home page/wiki/git: https://github.com/smxi/inxi +#### Documentation/wiki pages will move to http://smxi.org soon. #### Script forums: http://techpatterns.com/forums/forum-33.html #### IRC support: irc.oftc.net channel #smxi +#### Version control: +#### * https://github.com/smxi/inxi +#### * git: git pull https://github.com/smxi/inxi master +#### * source checkout url: https://github.com/smxi/inxi #### #### This program is free software; you can redistribute it and/or modify #### it under the terms of the GNU General Public License as published by @@ -45,6 +52,9 @@ #### If you don't understand what Free Software is, please read (or reread) #### this page: http://www.gnu.org/philosophy/free-sw.html ######################################################################## + +#### +#### PACKAGE NAME NOTES #### * Package names in (...) are the Debian Squeeze package name. Check your #### distro for proper package name by doing this: which #### then find what package owns that application file. Or run --recommends @@ -178,17 +188,18 @@ #### raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259 #### http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array #### https://raid.wiki.kernel.org/index.php/Mdstat +#### dmi data: http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf ######################################################################## #### TESTING FLAGS #### inxi supports advanced testing triggers to do various things, using -! #### -! 1 - triggers default B_TESTING_1='true' to trigger some test or other #### -! 2 - triggers default B_TESTING_2='true' to trigger some test or other #### -! 3 - triggers B_TESTING_1='true' and B_TESTING_2='true' -#### -! 10 - triggers an update from the primary dev download server instead of svn -#### -! 11 - triggers an update from svn branch one - if present, of course -#### -! 12 - triggers an update from svn branch two - if present, of course -#### -! 13 - triggers an update from svn branch three - if present, of course -#### -! 14 - triggers an update from svn branch four - if present, of course +#### -! 10 - triggers an update from the primary dev download server instead of source +#### -! 11 - triggers an update from source branch one - if present, of course +#### -! 12 - triggers an update from source branch two - if present, of course +#### -! 13 - triggers an update from source branch three - if present, of course +#### -! 14 - triggers an update from source branch four - if present, of course #### -! - Triggers an update from whatever server you list. #### LOG FLAGS (logs to $HOME/.inxi/inxi.log with rotate 3 total) #### -@ 8 - Basic data logging of generated data / array values @@ -246,6 +257,7 @@ ORIGINAL_IFS="$IFS" ## Initialize A_ALSA_DATA='' A_AUDIO_DATA='' +A_BATTERY_DATA='' A_CMDL='' A_CPU_CORE_DATA='' A_CPU_DATA='' @@ -285,6 +297,8 @@ B_DBUS_CLIENT='false' B_DCOP='false' # Debug flood override: make 'true' to allow long debug output B_DEBUG_FLOOD='false' +# for special -i debugging cases +B_DEBUG_I='false' B_DMIDECODE_SET='false' # show extra output data B_EXTRA_DATA='false' @@ -305,7 +319,7 @@ B_PCICONF='false' B_PCICONF_SET='false' # kde qdbus B_QDBUS='false' -B_PORTABLE='false' +B_POSSIBLE_PORTABLE='false' B_RAID_SET='false' B_ROOT='false' B_RUN_COLOR_SELECTOR='false' @@ -324,6 +338,8 @@ B_SHOW_BASIC_RAID='false' B_SHOW_BASIC_CPU='false' B_SHOW_BASIC_DISK='false' B_SHOW_BASIC_OPTICAL='false' +B_SHOW_BATTERY='false' +B_SHOW_BATTERY_FORCED='false' B_SHOW_CPU='false' B_SHOW_DISPLAY_DATA='false' B_SHOW_DISK_TOTAL='false' @@ -389,11 +405,21 @@ B_HDDTEMP_TESTED='false' B_MODINFO_TESTED='false' B_SUDO_TESTED='false' +# cpu 64 bit able or not. Does not tell you actual kernel/OS installed +# if ((1<<32)); then +# BITS=64 +# else +# BITS=32 +# fi +# 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' DEBUG_BUFFER_INDEX=0 +DISPLAY_OPT='' # for console switches ## note: the debugger rerouting to /dev/null has been moved to the end of the get_parameters function ## so -@[number] debug levels can be set if there is a failure, otherwise you can't even see the errors SED_I='-i' # for gnu sed, will be set to -i '' for bsd sed @@ -402,7 +428,9 @@ SED_RX='-r' # for gnu sed, will be set to -E for bsd sed for backward compatibil # default to false, no konversation found, 1 is native konvi (qt3/KDE3) script mode, 2 is /cmd inxi start, ## 3 is Konversation > 1.2 (qt4/KDE4) KONVI=0 -# NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups. +NO_SSL='' +NO_SSL_OPT='' +# NO_CPU_COUNT=0 # Whether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups. # This is a variable that controls how many parameters inxi will parse in a /proc//cmdline file before stopping. PARAMETER_LIMIT=30 SCHEME=0 # set default scheme - do not change this, it's set dynamically @@ -448,46 +476,54 @@ HDDTEMP_PATH='' MODINFO_PATH='' SUDO_PATH='' -SCRIPT_DATA_DIR="$HOME/.inxi" ALTERNATE_FTP='' # for data uploads ALTERNATE_WEATHER_LOCATION='' # weather alternate location -LOG_FILE="$SCRIPT_DATA_DIR/inxi.log" -LOG_FILE_1="$SCRIPT_DATA_DIR/inxi.1.log" -LOG_FILE_2="$SCRIPT_DATA_DIR/inxi.2.log" -MAN_FILE_DOWNLOAD='http://inxi.googlecode.com/svn/trunk/inxi.1.gz' -MAN_FILE_LOCATION='/usr/share/man/man1' -SCRIPT_NAME='inxi' -SCRIPT_PATCH_NUMBER='' -SCRIPT_PATH='' #filled-in in Main -SCRIPT_VERSION_NUMBER="" #filled-in in Main -SCRIPT_DOWNLOAD='http://inxi.googlecode.com/svn/trunk/' -SCRIPT_DOWNLOAD_BRANCH_1='http://inxi.googlecode.com/svn/branches/one/' -SCRIPT_DOWNLOAD_BRANCH_2='http://inxi.googlecode.com/svn/branches/two/' -SCRIPT_DOWNLOAD_BRANCH_3='http://inxi.googlecode.com/svn/branches/three/' -SCRIPT_DOWNLOAD_BRANCH_4='http://inxi.googlecode.com/svn/branches/four/' -SCRIPT_DOWNLOAD_BRANCH_BSD='http://inxi.googlecode.com/svn/branches/bsd/' -SCRIPT_DOWNLOAD_BRANCH_GNUBSD='http://inxi.googlecode.com/svn/branches/gnubsd/' -SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/' +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' +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. +# 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 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='' +LINE_LENGTH=0 +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 @@ -591,8 +627,21 @@ MAGENTA,YELLOW,NORMAL RED,CYAN,NORMAL RED,WHITE,NORMAL BLUE,WHITE,NORMAL + +RED,BLUE,NORMAL +RED,DBLUE,NORMAL +BLACK,BLUE,NORMAL +BLACK,DBLUE,NORMAL +NORMAL,BLUE,NORMAL +BLUE,MAGENTA,NORMAL +DBLUE,MAGENTA,NORMAL +BLACK,MAGENTA,NORMAL +MAGENTA,BLUE,NORMAL +MAGENTA,DBLUE,NORMAL ) +#echo ${#A_COLOR_SCHEMES[@]};exit + # WARNING: In the main part below (search for 'KONVI') # there's a check for Konversation-specific config files. # Any one of these can override the above if inxi is run @@ -601,14 +650,14 @@ BLUE,WHITE,NORMAL ## DISTRO DATA/ID ## # In cases of derived distros where the version file of the base distro can also be found under /etc, # the derived distro's version file should go first. (Such as with Sabayon / Gentoo) -DISTROS_DERIVED="antix-version aptosid-version kanotix-version knoppix-version mandrake-release pardus-release porteus-version sabayon-release siduction-version sidux-version slitaz-release solusos-release turbolinux-release zenwalk-version" +DISTROS_DERIVED="antix-version aptosid-version kanotix-version knoppix-version mandrake-release mx-version pardus-release porteus-version sabayon-release siduction-version sidux-version slitaz-release solusos-release turbolinux-release zenwalk-version" # debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu. -DISTROS_EXCLUDE_LIST="debian_version ubuntu_version" +DISTROS_EXCLUDE_LIST="debian_version devuan_version ubuntu_version" DISTROS_PRIMARY="arch-release gentoo-release redhat-release slackware-version SuSE-release" DISTROS_LSB_GOOD="mandrake-release mandriva-release mandrakelinux-release" # this is being used both by core distros and derived distros now, eg, solusos 1 uses it for solusos id, while # debian, solusos base, uses it as well, so we have to know which it is. -DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release" +DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release " ## Distros with known problems # DSL (Bash 2.05b: grep -m doesn't work; arrays won't work) --> unusable output # Puppy Linux 4.1.2 (Bash 3.0: arrays won't work) --> works partially @@ -616,10 +665,15 @@ DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release" ## OUTPUT FILTERS/SEARCH ## # Note that \ bans only words, not parts of strings; in \ you can't use punctuation characters like . or , # we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes. + BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\|inc\.|\|intl\.|co\.|\|corp\.|\|\(tm\)|\(r\)|®|\(rev ..\)' BAN_LIST_CPU='@||cpu |cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]' +# See github issue 75 for more details on value: *, triggers weird behaviors if present in value +# /sys/devices/virtual/dmi/id/product_name:['*'] +# this is for bash arrays AND avoiding * in arrays: ( fred * greg ) expands to the contents of the directory +BAN_LIST_ARRAY=',|\*' -SENSORS_GPU_SEARCH='intel|radeon|nouveau' +SENSORS_GPU_SEARCH='amdgpu|intel|radeon|nouveau' ### USB networking search string data, because some brands can have other products than ### wifi/nic cards, they need further identifiers, with wildcards. @@ -635,24 +689,28 @@ USB_NETWORK_SEARCH="$USB_NETWORK_SEARCH|050d:935b|0bda:8189|0bda:8197" ######################################################################## main() { + # This must be set first so log paths are present when logging starts. + set_user_paths + 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 $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then - source $HOME/.$SCRIPT_NAME/$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 # echo SCHEME $SCHEME @@ -666,10 +724,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 @@ -680,7 +734,7 @@ main() # note: this only works if it's run from inside konversation as a script builtin or something # only do this if inxi has been started as a konversation script, otherwise bypass this -# KONVI=3 ## for testing puroses + # KONVI=3 ## for testing puroses if [[ $KONVI -eq 1 || $KONVI -eq 3 ]];then if [[ $KONVI -eq 1 ]]; then ## dcop Konversation (ie 1.x < 1.2(qt3)) DCPORT="$1" @@ -773,7 +827,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 @@ -784,6 +838,49 @@ main() exit 0 } +set_user_paths() +{ + local b_conf='false' b_data='false' + + if [[ -n $XDG_CONFIG_HOME ]];then + SELF_CONFIG_DIR=$XDG_CONFIG_HOME + b_conf=true + elif [[ -d $HOME/.config ]];then + SELF_CONFIG_DIR=$HOME/.config + b_conf=true + else + SELF_CONFIG_DIR="$HOME/.$SELF_NAME" + fi + if [[ -n $XDG_DATA_HOME ]];then + SELF_DATA_DIR=$XDG_DATA_HOME/$SELF_NAME + b_data=true + elif [[ -d $HOME/.local/share ]];then + SELF_DATA_DIR=$HOME/.local/share/$SELF_NAME + b_data=true + else + 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 $SELF_DATA_DIR ]];then + mkdir $SELF_DATA_DIR + fi + + 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/.$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=$SELF_DATA_DIR/$LOG_FILE + LOG_FILE_1=$SELF_DATA_DIR/$LOG_FILE_1 + LOG_FILE_2=$SELF_DATA_DIR/$LOG_FILE_2 +} + #### ------------------------------------------------------------------- #### basic tests: set script data, booleans, PATH, version numbers #### ------------------------------------------------------------------- @@ -826,18 +923,25 @@ initialize_data() initialize_paths + if type -p dig &>/dev/null;then + DNSTOOL='dig' + fi # set downloaders. if ! type -p wget &>/dev/null;then # first check for bsd stuff if type -p fetch &>/dev/null;then DOWNLOADER='fetch' + NO_SSL=' --no-verify-peer' elif type -p curl &>/dev/null;then DOWNLOADER='curl' - elif [[ $BSD_VERSION == 'openbsd' && -n $( type -p ftp ) ]];then + NO_SSL=' --insecure' + elif [[ $BSD_VERSION == 'openbsd' ]] && type -p ftp &>/dev/null;then DOWNLOADER='ftp' else DOWNLOADER='no-downloader' fi + else + NO_SSL=' --no-check-certificate' fi if [[ -n $BSD_TYPE ]];then @@ -846,9 +950,9 @@ initialize_data() fi else # found a case of battery existing but having nothing in it on desktop mobo - # not all laptops show the first, - if [[ -n $( ls /proc/acpi/battery 2>/dev/null ) ]];then - B_PORTABLE='true' + # not all laptops show the first. /proc/acpi/battery is deprecated. + if [[ -n $( ls /proc/acpi/battery 2>/dev/null ) || -n $( ls /sys/class/power_supply/ 2>/dev/null ) ]];then + B_POSSIBLE_PORTABLE='true' fi fi if [[ -e $FILE_CPUINFO ]]; then @@ -960,30 +1064,30 @@ set_display_width() # arg: $1 - version number: main/patch/date parse_version_data() { - local version_data='' - - # note, using ####[[:space:]]+ to avoid having this function also trip the version datas + # note, this is only now used for self updater function case $1 in date) - version_data=$( gawk -F ': ' ' - /####[[:space:]]+Date:/ { + SELF_DATE=$( gawk -F '=' ' + /^SELF_DATE/ { print $NF - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + exit + }' "$SELF_PATH/$SELF_NAME" ) ;; main) - version_data=$( gawk ' - /####[[:space:]]+Version:/ { - print $3 - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + SELF_VERSION=$( gawk -F '=' ' + /^SELF_VERSION/ { + print $NF + exit + }' "$SELF_PATH/$SELF_NAME" ) ;; patch) - version_data=$( gawk ' - /####[[:space:]]+Patch Number:/ { - print $4 - }' "$SCRIPT_PATH/$SCRIPT_NAME" ) + SELF_PATCH=$( gawk -F '=' ' + /^SELF_PATCH/ { + print $NF + exit + }' "$SELF_PATH/$SELF_NAME" ) ;; esac - echo $version_data } initialize_paths() @@ -993,8 +1097,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: IFS=":" @@ -1017,6 +1120,7 @@ initialize_paths() # echo "PATH='$PATH'" ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""' } + # No args taken. check_recommended_apps() { @@ -1081,7 +1185,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 @@ -1164,7 +1268,7 @@ select_default_color_scheme() { eval $LOGFS local spacer=' ' options='' user_selection='' config_variable='' - local config_file="$HOME/.$SCRIPT_NAME/$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' @@ -1196,11 +1300,11 @@ 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 3 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds." + 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." if [[ $B_IRC == 'false' ]];then print_lines_basic "0" "" "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)" fi @@ -1226,11 +1330,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" @@ -1261,9 +1365,6 @@ select_default_color_scheme() set_color_scheme $user_selection # make file/directory first if missing if [[ ! -f $config_file ]];then - if [[ ! -d $HOME/.$SCRIPT_NAME ]];then - mkdir $HOME/.$SCRIPT_NAME - fi touch $config_file fi if [[ -z $( grep -s "$config_variable=" $config_file ) ]];then @@ -1289,7 +1390,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 @@ -1299,7 +1400,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" @@ -1340,39 +1441,39 @@ 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" ;; 12) - error_message="the svn branch download url: $2\nappears to be empty currently. Make sure there is an actual svn branch version\nactive before you try this again. Check http://code.google.com/p/inxi\nto verify the branch status." + error_message="the git branch download url: $2\nappears to be empty currently. Make sure there is an actual source branch version\nactive before you try this again. Check https://github.com/smxi/inxi\nto verify the branch status." ;; 13) 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" @@ -1403,10 +1504,10 @@ script_debugger() { eval $LOGFS if [[ $B_SCRIPT_UP == 'true' ]];then - # only return if debugger is off and no pre start up errors have occured + # only return if debugger is off and no pre start up errors have occurred if [[ $DEBUG -eq 0 && $DEBUG_BUFFER_INDEX -eq 0 ]];then return 0 - # print out the stored debugging information if errors occured + # print out the stored debugging information if errors occurred elif [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#A_DEBUG_BUFFER[@]}; DEBUG_BUFFER_INDEX++ )) do @@ -1487,9 +1588,6 @@ log_function_data() # will have max 3 files, inxi.log, inxi.1.log, inxi.2.log create_rotate_logfiles() { - if [[ ! -d $SCRIPT_DATA_DIR ]];then - mkdir $SCRIPT_DATA_DIR - fi # do the rotation if logfile exists if [[ -f $LOG_FILE ]];then # copy if present second to third @@ -1503,7 +1601,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 } @@ -1515,29 +1613,31 @@ script_self_updater() { eval $LOGFS local downloader_error=0 file_contents='' downloader_man_error=0 - local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz" + local man_file_location=$( set_man_location ) + 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 "Current version release date: $SELF_DATE" + print_screen_output "Updating $SELF_NAME in $SELF_PATH using $2 as download source..." case $DOWNLOADER in curl) - file_contents="$( curl -s $1$SCRIPT_NAME )" || downloader_error=$? + file_contents="$( curl $NO_SSL_OPT -s $1$SELF_NAME )" || downloader_error=$? ;; fetch) - file_contents="$( fetch -q -o - $1$SCRIPT_NAME )" || downloader_error=$? + file_contents="$( fetch $NO_SSL_OPT -q -o - $1$SELF_NAME )" || downloader_error=$? ;; ftp) - file_contents="$( ftp -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 -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 @@ -1548,29 +1648,31 @@ 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 "$?" + parse_version_data 'main' + parse_version_data 'patch' + parse_version_data 'date' + print_screen_output "Successfully updated to $2 version: $SELF_VERSION" + print_screen_output "New $2 version patch number: $SELF_PATCH" + print_screen_output "New $2 version release date: $SELF_DATE" + 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 - print_screen_output "The required man directory was not detected on your system, unable to continue: $MAN_FILE_LOCATION" + if [[ ! -d $man_file_location ]];then + print_screen_output "The required man directory was not detected on your system, unable to continue: $man_file_location" else if [[ $B_ROOT == 'true' ]];then print_screen_output "Checking Man page download URL..." if [[ -f /usr/share/man/man8/inxi.8.gz ]];then print_screen_output "Updating man page location to man1." - mv -f /usr/share/man/man8/inxi.8.gz /usr/share/man/man1/inxi.1.gz + mv -f /usr/share/man/man8/inxi.8.gz $man_file_location/inxi.1.gz if type -p mandb &>/dev/null;then exec $( type -p mandb ) -q fi fi if [[ $DOWNLOADER == 'wget' ]];then - wget -q --spider $MAN_FILE_DOWNLOAD || downloader_man_error=$? + wget $NO_SSL_OPT -q --spider $MAN_FILE_DOWNLOAD || downloader_man_error=$? fi if [[ $downloader_man_error -eq 0 ]];then if [[ $DOWNLOADER == 'wget' ]];then @@ -1579,16 +1681,16 @@ script_self_updater() print_screen_output "Downloading Man page file now." case $DOWNLOADER in curl) - curl -s -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? + curl $NO_SSL_OPT -s -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? ;; fetch) - fetch -q -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? + fetch $NO_SSL_OPT -q -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? ;; ftp) - ftp -o $man_file_path $MAN_FILE_DOWNLOAD 2>/dev/null || downloader_man_error=$? + ftp $NO_SSL_OPT -o $man_file_path $MAN_FILE_DOWNLOAD 2>/dev/null || downloader_man_error=$? ;; wget) - wget -q -O $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? + wget $NO_SSL_OPT -q -O $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$? ;; no-downloader) downloader_man_error=1 @@ -1604,8 +1706,8 @@ script_self_updater() print_screen_output "Man file download URL failed, unable to continue: $MAN_FILE_DOWNLOAD" 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 "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 $SELF_NAME -$3 as root." fi fi exit 0 @@ -1614,7 +1716,7 @@ script_self_updater() fi # now run the error handlers on any wget failure else - if [[ $2 == 'svn server' ]];then + if [[ $2 == 'source server' ]];then error_handler 8 "$downloader_error" elif [[ $2 == 'alt server' ]];then error_handler 10 "$1" @@ -1625,17 +1727,59 @@ script_self_updater() eval $LOGFS } +set_man_location() +{ + local location='' default_location='/usr/share/man/man1' + local man_paths=$(man --path 2>/dev/null) man_local='/usr/local/share/man' + local b_use_local=false + + if [[ -n "$man_paths" && -n $( grep $man_local <<< "$man_paths" ) ]];then + b_use_local=true + fi + + # for distro installs, existing inxi man manual installs, do nothing + if [[ -f $default_location/inxi.1.gz ]];then + location=$default_location + else + if [[ $b_use_local == 'true' ]];then + if [[ ! -d $man_local/man1 ]];then + mkdir $man_local/man1 + fi + location="$man_local/man1" + fi +# print_screen_output "Updating man page location to man1." +# mv -f /usr/share/man/man1/inxi.1.gz /usr/local/share/man/man1/inxi.1.gz +# if type -p mandb &>/dev/null;then +# exec $( type -p mandb ) -q +# fi + fi + + if [[ -z "$location" ]];then + location=$default_location + fi + + echo $location +} + # args: $1 - debug data type: sys|xorg|disk debug_data_collector() { - local xiin_app='' xiin_data_file='' xiin_download='' error='' b_run_xiin='false' - local debug_data_dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids='' - local completed_gz_file='' xiin_file='xiin.py' ftp_upload='ftp.techpatterns.com/incoming' - local xiin_url="http://inxi.googlecode.com/svn/branches/xiin/$xiin_file" - local Line='-------------------------' root_string='' + local xiin_app='' xiin_data_file='' error='' b_run_xiin='false' b_xiin_downloaded='false' + local Debug_Data_Dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids='' + local completed_gz_file='' Xiin_File='xiin.py' ftp_upload='ftp.techpatterns.com/incoming' + local Line='-------------------------' local start_directory=$( pwd ) - local host=$( tr '[A-Z]' '[a-z]' <<< "$HOSTNAME" ) - local downloader_error=0 + local host='' debug_i='' root_string='' + + 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 if [[ -n $host ]];then host=${host// /-} @@ -1649,397 +1793,514 @@ debug_data_collector() root_string='-root' fi - debug_data_dir="inxi$bsd_string-$host-$(date +%Y%m%d-%H%M%S)-$1$root_string" + Debug_Data_Dir="inxi$bsd_string-$host-$(date +%Y%m%d-%H%M%S)-$1$root_string" if [[ $B_IRC == 'false' ]];then if [[ -n $ALTERNATE_FTP ]];then ftp_upload=$ALTERNATE_FTP fi echo "Starting debugging data collection type: $1" - echo -n "Checking/creating required directories... " - if [[ ! -d $SCRIPT_DATA_DIR ]];then - mkdir $SCRIPT_DATA_DIR - fi - echo 'completed' - 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 - pciconf -l -cv &> $debug_data_dir/bsd-pciconf-cvl.txt - pciconf -vl &> $debug_data_dir/bsd-pciconf-vl.txt - pciconf -l &> $debug_data_dir/bsd-pciconf-l.txt + pciconf -l -cv &> $Debug_Data_Dir/bsd-pciconf-cvl.txt + pciconf -vl &> $Debug_Data_Dir/bsd-pciconf-vl.txt + pciconf -l &> $Debug_Data_Dir/bsd-pciconf-l.txt else - touch $debug_data_dir/bsd-pciconf-absent + touch $Debug_Data_Dir/bsd-pciconf-absent fi # openbsd if type -p pcidump &>/dev/null;then - pcidump &> $debug_data_dir/bsd-pcidump-openbsd.txt - pcidump -v &> $debug_data_dir/bsd-pcidump-v-openbsd.txt + pcidump &> $Debug_Data_Dir/bsd-pcidump-openbsd.txt + pcidump -v &> $Debug_Data_Dir/bsd-pcidump-v-openbsd.txt else - touch $debug_data_dir/bsd-pcidump-openbsd-absent + touch $Debug_Data_Dir/bsd-pcidump-openbsd-absent fi # netbsd if type -p pcictl &>/dev/null;then - pcictl list &> $debug_data_dir/bsd-pcictl-list-netbsd.txt - pcictl list -n &> $debug_data_dir/bsd-pcictl-list-n-netbsd.txt + pcictl list &> $Debug_Data_Dir/bsd-pcictl-list-netbsd.txt + pcictl list -n &> $Debug_Data_Dir/bsd-pcictl-list-n-netbsd.txt else - touch $debug_data_dir/bsd-pcictl-netbsd-absent + touch $Debug_Data_Dir/bsd-pcictl-netbsd-absent fi if type -p sysctl &>/dev/null;then - sysctl -a &> $debug_data_dir/bsd-sysctl-a.txt + sysctl -a &> $Debug_Data_Dir/bsd-sysctl-a.txt else - touch $debug_data_dir/bsd-sysctl-absent + touch $Debug_Data_Dir/bsd-sysctl-absent fi if type -p usbdevs &>/dev/null;then - usbdevs -v &> $debug_data_dir/bsd-usbdevs-v.txt + usbdevs -v &> $Debug_Data_Dir/bsd-usbdevs-v.txt else - touch $debug_data_dir/bsd-usbdevs-absent + touch $Debug_Data_Dir/bsd-usbdevs-absent fi if type -p kldstat &>/dev/null;then - kldstat &> $debug_data_dir/bsd-kldstat.txt + kldstat &> $Debug_Data_Dir/bsd-kldstat.txt else - touch $debug_data_dir/bsd-kldstat-absent + touch $Debug_Data_Dir/bsd-kldstat-absent fi # diskinfo -v # fdisk - dmidecode &> $debug_data_dir/dmidecode.txt + 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;a_distro_ids=(/etc/*[-_]{release,version});shopt -u nullglob;echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt + shopt -s nullglob + a_distro_ids=(/etc/*[-_]{release,version}) + shopt -u nullglob + echo ${a_distro_ids[@]} &> $Debug_Data_Dir/etc-distro-files.txt for distro_file in ${a_distro_ids[@]} /etc/issue do if [[ -f $distro_file ]];then - cat $distro_file &> $debug_data_dir/distro-file${distro_file//\//-} + cat $distro_file &> $Debug_Data_Dir/distro-file${distro_file//\//-} fi done fi - dmesg &> $debug_data_dir/dmesg.txt - lscpu &> $debug_data_dir/lscpu.txt - lspci &> $debug_data_dir/lspci.txt - lspci -k &> $debug_data_dir/lspci-k.txt - lspci -knn &> $debug_data_dir/lspci-knn.txt - lspci -n &> $debug_data_dir/lspci-n.txt - lspci -nn &> $debug_data_dir/lspci-nn.txt - lspci -mm &> $debug_data_dir/lspci-mm.txt - lspci -mmnn &> $debug_data_dir/lspci-mmnn.txt - lspci -mmnnv &> $debug_data_dir/lspci-mmnnv.txt - lspci -v &> $debug_data_dir/lspci-v.txt - lsusb &> $debug_data_dir/lsusb.txt - ls /sys &> $debug_data_dir/ls-sys.txt - ps aux &> $debug_data_dir/ps-aux.txt - ps -e &> $debug_data_dir/ps-e.txt - ps -p 1 &> $debug_data_dir/ps-p-1.txt - cat /proc/1/comm &> $debug_data_dir/proc-1-comm.txt - runlevel &> $debug_data_dir/runlevel.txt - if type -p rc-status &>/dev/null;then - rc-status -a &> $debug_data_dir/rc-status-a.txt - rc-status -l &> $debug_data_dir/rc-status-l.txt - rc-status -r &> $debug_data_dir/rc-status-r.txt + dmesg &> $Debug_Data_Dir/dmesg.txt + lscpu &> $Debug_Data_Dir/lscpu.txt + lspci &> $Debug_Data_Dir/lspci.txt + lspci -k &> $Debug_Data_Dir/lspci-k.txt + lspci -knn &> $Debug_Data_Dir/lspci-knn.txt + lspci -n &> $Debug_Data_Dir/lspci-n.txt + lspci -nn &> $Debug_Data_Dir/lspci-nn.txt + lspci -mm &> $Debug_Data_Dir/lspci-mm.txt + lspci -mmnn &> $Debug_Data_Dir/lspci-mmnn.txt + lspci -mmnnv &> $Debug_Data_Dir/lspci-mmnnv.txt + lspci -v &> $Debug_Data_Dir/lspci-v.txt + lsusb &> $Debug_Data_Dir/lsusb.txt + if type -p hciconfig &>/dev/null;then + hciconfig -a &> $Debug_Data_Dir/hciconfig-a.txt else - touch $debug_data_dir/rc-status-absent + touch $Debug_Data_Dir/hciconfig-absent + fi + ls /sys &> $Debug_Data_Dir/ls-sys.txt + ps aux &> $Debug_Data_Dir/ps-aux.txt + ps -e &> $Debug_Data_Dir/ps-e.txt + ps -p 1 &> $Debug_Data_Dir/ps-p-1.txt + cat /proc/1/comm &> $Debug_Data_Dir/proc-1-comm.txt + runlevel &> $Debug_Data_Dir/runlevel.txt + if type -p rc-status &>/dev/null;then + rc-status -a &> $Debug_Data_Dir/rc-status-a.txt + rc-status -l &> $Debug_Data_Dir/rc-status-l.txt + rc-status -r &> $Debug_Data_Dir/rc-status-r.txt + else + touch $Debug_Data_Dir/rc-status-absent fi if type -p systemctl &>/dev/null;then - systemctl list-units &> $debug_data_dir/systemctl-list-units.txt - systemctl list-units --type=target &> $debug_data_dir/systemctl-list-units-target.txt + systemctl list-units &> $Debug_Data_Dir/systemctl-list-units.txt + systemctl list-units --type=target &> $Debug_Data_Dir/systemctl-list-units-target.txt else - touch $debug_data_dir/systemctl-absent + touch $Debug_Data_Dir/systemctl-absent fi if type -p initctl &>/dev/null;then - initctl list &> $debug_data_dir/initctl-list.txt + initctl list &> $Debug_Data_Dir/initctl-list.txt else - touch $debug_data_dir/initctl-absent + touch $Debug_Data_Dir/initctl-absent fi - sensors &> $debug_data_dir/sensors.txt + sensors &> $Debug_Data_Dir/sensors.txt if type -p strings &>/dev/null;then - touch $debug_data_dir/strings-present + touch $Debug_Data_Dir/strings-present else - touch $debug_data_dir/strings-absent + touch $Debug_Data_Dir/strings-absent fi + local id_dir='/sys/class/power_supply/' + local ids=$( ls $id_dir 2>/dev/null ) + if [[ -n $ids ]];then + for batid in $ids + do + cat $id_dir$batid'/uevent' &> $Debug_Data_Dir/sys-power-supply-$batid.txt + done + else + touch $Debug_Data_Dir/sys-power-supply-none + fi + # leaving this commented out to remind that some systems do not # support strings --version, but will just simply hang at that command # which you can duplicate by simply typing: strings then hitting enter, you will get hang. - # strings --version &> $debug_data_dir/strings.txt + # strings --version &> $Debug_Data_Dir/strings.txt if type -p nvidia-smi &>/dev/null;then - nvidia-smi -q &> $debug_data_dir/nvidia-smi-q.txt - nvidia-smi -q -x &> $debug_data_dir/nvidia-smi-xq.txt + nvidia-smi -q &> $Debug_Data_Dir/nvidia-smi-q.txt + nvidia-smi -q -x &> $Debug_Data_Dir/nvidia-smi-xq.txt else - touch $debug_data_dir/nvidia-smi-absent + touch $Debug_Data_Dir/nvidia-smi-absent fi - head -n 1 /proc/asound/card*/codec* &> $debug_data_dir/proc-asound-card-codec.txt - ls /usr/bin/gcc* &> $debug_data_dir/gcc-sys-versions.txt - if type -p gcc &>/dev/null;then - gcc --version &> $debug_data_dir/gcc-version.txt + head -n 1 /proc/asound/card*/codec* &> $Debug_Data_Dir/proc-asound-card-codec.txt + if [[ -f /proc/version ]];then + cat /proc/version &> $Debug_Data_Dir/proc-version.txt else - touch $debug_data_dir/gcc-absent + touch $Debug_Data_Dir/proc-version-absent + fi + echo $CC &> $Debug_Data_Dir/cc-content.txt + ls /usr/bin/gcc* &> $Debug_Data_Dir/gcc-sys-versions.txt + if type -p gcc &>/dev/null;then + gcc --version &> $Debug_Data_Dir/gcc-version.txt + else + touch $Debug_Data_Dir/gcc-absent fi if type -p clang &>/dev/null;then - clang --version &> $debug_data_dir/clang-version.txt + clang --version &> $Debug_Data_Dir/clang-version.txt else - touch $debug_data_dir/clang-absent + touch $Debug_Data_Dir/clang-absent + fi + if type -p systemd-detect-virt &>/dev/null;then + systemd-detect-virt &> $Debug_Data_Dir/systemd-detect-virt-info.txt + else + touch $Debug_Data_Dir/systemd-detect-virt-absent fi - cat /etc/src.conf &> $debug_data_dir/bsd-etc-src-conf.txt - cat /etc/make.conf &> $debug_data_dir/bsd-etc-make-conf.txt - cat /etc/issue &> $debug_data_dir/etc-issue.txt - cat $FILE_LSB_RELEASE &> $debug_data_dir/lsb-release.txt - cat $FILE_OS_RELEASE &> $debug_data_dir/os-release.txt - cat $FILE_ASOUND_DEVICE &> $debug_data_dir/proc-asound-device.txt - cat $FILE_ASOUND_VERSION &> $debug_data_dir/proc-asound-version.txt - cat $FILE_CPUINFO &> $debug_data_dir/proc-cpu-info.txt - cat $FILE_MEMINFO &> $debug_data_dir/proc-meminfo.txt - cat $FILE_MODULES &> $debug_data_dir/proc-modules.txt - cat /proc/net/arp &> $debug_data_dir/proc-net-arp.txt - # bsd data - cat /var/run/dmesg.boot &> $debug_data_dir/bsd-var-run-dmesg.boot.txt - echo $COLS_INNER &> $debug_data_dir/cols-inner.txt - 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 - echo "Downloading required tree traverse tool $xiin_file..." - if [[ -f xiin && ! -f $xiin_file ]];then - mv -f xiin $xiin_file - fi - # -Nc is creating really weird download anomolies, so using -O instead - case $DOWNLOADER in - curl) - xiin_download="$( curl -s $xiin_url )" || downloader_error=$? - ;; - fetch) - xiin_download="$( fetch -q -o - $xiin_url )" || downloader_error=$? - ;; - ftp) - xiin_download="$( ftp -o - $xiin_url 2>/dev/null )" || downloader_error=$? - ;; - wget) - xiin_download="$( wget -q -O - $xiin_url )" || downloader_error=$? - ;; - no-downloader) - downloader_error=1 - ;; - esac - # if nothing got downloaded kick out error, otherwise we'll use an older version - if [[ $downloader_error -gt 0 && ! -f $xiin_file ]];then - echo -e "ERROR: Failed to download required file: $xiin_file\nMaybe the remote site is down or your networking is broken?" - echo "Continuing with incomplete data collection." - echo "$xiin_file download failed and no existing $xiin_file" >> $debug_data_dir/xiin-error.txt - elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $xiin_file ]];then - if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then - echo "Updating $xiin_file from remote location" - echo "$xiin_download" > $xiin_file - else - echo "Using local $xiin_file due to download failure" - fi - b_run_xiin='true' - else - echo -e "ERROR: $xiin_file downloaded but the program file data is corrupted.\nContinuing with incomplete data collection." - echo "$xiin_file downloaded but the program file data is corrupted." >> $debug_data_dir/xiin-error.txt - fi - 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 - echo 'Collecting networking data...' - ifconfig &> $debug_data_dir/ifconfig.txt - ip addr &> $debug_data_dir/ip-addr.txt - if [[ $b_run_xiin == 'true' && -z $BSD_TYPE ]];then - echo $Line - echo "Running $xiin_file tool now on /sys..." - echo "Using Python version:" && python --version - python --version &> $debug_data_dir/python-version.txt - python ./$xiin_file -d /sys -f $xiin_data_file - if [[ $? -ne 0 ]];then - error=$? - echo -e "ERROR: $xiin_file exited with error $error - removing data file.\nContinuing with incomplete data collection." - echo "Continuing with incomplete data collection." - rm -f $xiin_data_file - echo "$xiin_file data generation failed with python error $error" >> $debug_data_dir/xiin-error.txt - fi - echo $Line - fi - fi + cat /etc/src.conf &> $Debug_Data_Dir/bsd-etc-src-conf.txt + cat /etc/make.conf &> $Debug_Data_Dir/bsd-etc-make-conf.txt + cat /etc/issue &> $Debug_Data_Dir/etc-issue.txt + cat $FILE_LSB_RELEASE &> $Debug_Data_Dir/lsb-release.txt + cat $FILE_OS_RELEASE &> $Debug_Data_Dir/os-release.txt + cat $FILE_ASOUND_DEVICE &> $Debug_Data_Dir/proc-asound-device.txt + cat $FILE_ASOUND_VERSION &> $Debug_Data_Dir/proc-asound-version.txt + cat $FILE_CPUINFO &> $Debug_Data_Dir/proc-cpu-info.txt + cat $FILE_MEMINFO &> $Debug_Data_Dir/proc-meminfo.txt + cat $FILE_MODULES &> $Debug_Data_Dir/proc-modules.txt + cat /proc/net/arp &> $Debug_Data_Dir/proc-net-arp.txt + # bsd data + cat /var/run/dmesg.boot &> $Debug_Data_Dir/bsd-var-run-dmesg.boot.txt + echo $COLS_INNER &> $Debug_Data_Dir/cols-inner.txt + echo $XDG_CONFIG_HOME &> $Debug_Data_Dir/xdg_config_home.txt + echo $XDG_CONFIG_DIRS &> $Debug_Data_Dir/xdg_config_dirs.txt + echo $XDG_DATA_HOME &> $Debug_Data_Dir/xdg_data_home.txt + echo $XDG_DATA_DIRS &> $Debug_Data_Dir/xdg_data_dirs.txt + + check_recommends_user_output &> $Debug_Data_Dir/check-recommends-user-output.txt if [[ $1 == 'xorg' || $1 == 'all' ]];then if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then echo 'Warning: only some of the data collection can occur if you are not in X' - touch $debug_data_dir/warning-user-not-in-x + touch $Debug_Data_Dir/warning-user-not-in-x fi if [[ $B_ROOT == 'true' ]];then echo 'Warning: only some of the data collection can occur if you are running as Root user' - touch $debug_data_dir/warning-root-user + touch $Debug_Data_Dir/warning-root-user fi echo 'Collecting Xorg log and xorg.conf files' if [[ -e $FILE_XORG_LOG ]];then - cat $FILE_XORG_LOG &> $debug_data_dir/xorg-log-file.txt + cat $FILE_XORG_LOG &> $Debug_Data_Dir/xorg-log-file.txt else - touch $debug_data_dir/xorg-log-file-absent + touch $Debug_Data_Dir/xorg-log-file-absent fi if [[ -e /etc/X11/xorg.conf ]];then - cat /etc/X11/xorg.conf &> $debug_data_dir/xorg-conf.txt + cat /etc/X11/xorg.conf &> $Debug_Data_Dir/xorg-conf.txt else - touch $debug_data_dir/xorg-conf-file-absent + touch $Debug_Data_Dir/xorg-conf-file-absent fi if [[ -n $( ls /etc/X11/xorg.conf.d/ 2>/dev/null ) ]];then - ls /etc/X11/xorg.conf.d &> $debug_data_dir/ls-etc-x11-xorg-conf-d.txt + ls /etc/X11/xorg.conf.d &> $Debug_Data_Dir/ls-etc-x11-xorg-conf-d.txt xorg_d_files=$(ls /etc/X11/xorg.conf.d) for xorg_file in $xorg_d_files do - cat /etc/X11/xorg.conf.d/$xorg_file &> $debug_data_dir/xorg-conf-d-$xorg_file.txt + cat /etc/X11/xorg.conf.d/$xorg_file &> $Debug_Data_Dir/xorg-conf-d-$xorg_file.txt done else - touch $debug_data_dir/xorg-conf-d-files-absent + touch $Debug_Data_Dir/xorg-conf-d-files-absent fi echo 'Collecting X, xprop, glxinfo, xrandr, xdpyinfo data, wayland, weston...' if type -p weston-info &>/dev/null; then - weston-info &> $debug_data_dir/weston-info.txt + weston-info &> $Debug_Data_Dir/weston-info.txt else - touch $debug_data_dir/weston-info-absent + touch $Debug_Data_Dir/weston-info-absent fi if type -p weston &>/dev/null; then - weston --version &> $debug_data_dir/weston-version.txt + weston --version &> $Debug_Data_Dir/weston-version.txt else - touch $debug_data_dir/weston-absent + touch $Debug_Data_Dir/weston-absent fi if type -p xprop &>/dev/null; then - xprop -root &> $debug_data_dir/xprop_root.txt + xprop -root &> $Debug_Data_Dir/xprop_root.txt else - touch $debug_data_dir/xprop-absent + touch $Debug_Data_Dir/xprop-absent fi - if type -p xprop &>/dev/null; then - glxinfo &> $debug_data_dir/glxinfo.txt + if type -p glxinfo &>/dev/null; then + glxinfo &> $Debug_Data_Dir/glxinfo-full.txt + glxinfo -B &> $Debug_Data_Dir/glxinfo-B.txt else - touch $debug_data_dir/glxinfo-absent + touch $Debug_Data_Dir/glxinfo-absent fi if type -p xdpyinfo &>/dev/null; then - xdpyinfo &> $debug_data_dir/xdpyinfo.txt + xdpyinfo &> $Debug_Data_Dir/xdpyinfo.txt else - touch $debug_data_dir/xdpyinfo-absent + touch $Debug_Data_Dir/xdpyinfo-absent fi if type -p xrandr &>/dev/null; then - xrandr &> $debug_data_dir/xrandr.txt + xrandr &> $Debug_Data_Dir/xrandr.txt else - touch $debug_data_dir/xrandr-absent + touch $Debug_Data_Dir/xrandr-absent fi if type -p X &>/dev/null; then - X -version &> $debug_data_dir/x-version.txt + X -version &> $Debug_Data_Dir/x-version.txt else - touch $debug_data_dir/x-absent + touch $Debug_Data_Dir/x-absent fi if type -p Xorg &>/dev/null; then - Xorg -version &> $debug_data_dir/xorg-version.txt + Xorg -version &> $Debug_Data_Dir/xorg-version.txt else - touch $debug_data_dir/xorg-absent + touch $Debug_Data_Dir/xorg-absent fi - echo $GNOME_DESKTOP_SESSION_ID &> $debug_data_dir/gnome-desktop-session-id.txt + echo $GNOME_DESKTOP_SESSION_ID &> $Debug_Data_Dir/gnome-desktop-session-id.txt # kde 3 id - echo $KDE_FULL_SESSION &> $debug_data_dir/kde3-ful-session.txt - echo $KDE_SESSION_VERSION &> $debug_data_dir/kde456-session-version.txt - echo "$(kded$KDE_SESSION_VERSION --version )" &> $debug_data_dir/kde-version-data.txt - echo $XDG_CURRENT_DESKTOP &> $debug_data_dir/xdg-current-desktop.txt + echo $KDE_FULL_SESSION &> $Debug_Data_Dir/kde3-full-session.txt + echo $KDE_SESSION_VERSION &> $Debug_Data_Dir/kde-gte-4-session-version.txt + if type -p kf5-config &>/dev/null; then + kf5-config --version &> $Debug_Data_Dir/kde-kf5-config-version-data.txt + elif type -p kf6-config &>/dev/null; then + kf6-config --version &> $Debug_Data_Dir/kde-kf6-config-version-data.txt + elif type -p kf$KDE_SESSION_VERSION-config &>/dev/null; then + kf$KDE_SESSION_VERSION-config --version &> $Debug_Data_Dir/kde-kf$KDE_SESSION_VERSION-KSV-config-version-data.txt + else + touch $Debug_Data_Dir/kde-kf-config-absent + fi + if type -p plasmashell &>/dev/null; then + plasmashell --version &> $Debug_Data_Dir/kde-plasmashell-version-data.txt + else + touch $Debug_Data_Dir/kde-plasmashell-absent + fi + if type -p kwin_x11 &>/dev/null; then + kwin_x11 --version &> $Debug_Data_Dir/kde-kwin_x11-version-data.txt + else + touch $Debug_Data_Dir/kde-kwin_x11-absent + fi + if type -p kded4 &>/dev/null; then + kded4 --version &> $Debug_Data_Dir/kded4-version-data.txt + elif type -p kded5 &>/dev/null; then + kded5 --version &> $Debug_Data_Dir/kded5-version-data.txt + elif type -p kded &>/dev/null; then + kded --version &> $Debug_Data_Dir/kded-version-data.txt + else + touch $Debug_Data_Dir/kded-$KDE_SESSION_VERSION-absent + fi + # kde 5/plasma desktop 5, this is maybe an extra package and won't be used + if type -p about-distro &>/dev/null; then + about-distro &> $Debug_Data_Dir/kde-about-distro.txt + else + touch $Debug_Data_Dir/kde-about-distro-absent + fi + echo $XDG_CURRENT_DESKTOP &> $Debug_Data_Dir/xdg-current-desktop.txt + echo $XDG_SESSION_DESKTOP &> $Debug_Data_Dir/xdg-session-desktop.txt + echo $DESKTOP_SESSION &> $Debug_Data_Dir/desktop-session.txt + echo $GDMSESSION &> $Debug_Data_Dir/gdmsession.txt + # wayland data collectors: + echo $XDG_SESSION_TYPE &> $Debug_Data_Dir/xdg-session-type.txt + echo $WAYLAND_DISPLAY &> $Debug_Data_Dir/wayland-display.txt + echo $GDK_BACKEND &> $Debug_Data_Dir/gdk-backend.txt + echo $QT_QPA_PLATFORM &> $Debug_Data_Dir/qt-qpa-platform.txt + echo $CLUTTER_BACKEND &> $Debug_Data_Dir/clutter-backend.txt + echo $SDL_VIDEODRIVER &> $Debug_Data_Dir/sdl-videodriver.txt + if type -p loginctl &>/dev/null;then + loginctl --no-pager list-sessions &> $Debug_Data_Dir/loginctl-list-sessions.txt + else + touch $Debug_Data_Dir/loginctl-absent + fi fi if [[ $1 == 'disk' || $1 == 'all' ]];then echo 'Collecting dev, label, disk, uuid data, df...' - ls -l /dev &> $debug_data_dir/dev-data.txt - ls -l /dev/disk &> $debug_data_dir/dev-disk-data.txt - ls -l /dev/disk/by-id &> $debug_data_dir/dev-disk-id-data.txt - ls -l /dev/disk/by-label &> $debug_data_dir/dev-disk-label-data.txt - ls -l /dev/disk/by-uuid &> $debug_data_dir/dev-disk-uuid-data.txt + ls -l /dev &> $Debug_Data_Dir/dev-data.txt + ls -l /dev/disk &> $Debug_Data_Dir/dev-disk-data.txt + ls -l /dev/disk/by-id &> $Debug_Data_Dir/dev-disk-id-data.txt + ls -l /dev/disk/by-label &> $Debug_Data_Dir/dev-disk-label-data.txt + ls -l /dev/disk/by-uuid &> $Debug_Data_Dir/dev-disk-uuid-data.txt # http://comments.gmane.org/gmane.linux.file-systems.zfs.user/2032 - ls -l /dev/disk/by-wwn &> $debug_data_dir/dev-disk-wwn-data.txt - ls -l /dev/disk/by-path &> $debug_data_dir/dev-disk-path-data.txt - ls -l /dev/mapper &> $debug_data_dir/dev-disk-mapper-data.txt - readlink /dev/root &> $debug_data_dir/dev-root.txt - df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-h-T-P-excludes.txt - df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-T-P-excludes.txt - df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs --total &> $debug_data_dir/df-T-P-excludes-total.txt - df -h -T &> $debug_data_dir/bsd-df-h-T-no-excludes.txt - df -h &> $debug_data_dir/bsd-df-h-no-excludes.txt - df -k -T &> $debug_data_dir/bsd-df-k-T-no-excludes.txt - df -k &> $debug_data_dir/bsd-df-k-no-excludes.txt - atacontrol list &> $debug_data_dir/bsd-atacontrol-list.txt - camcontrol devlist &> $debug_data_dir/bsd-camcontrol-devlist.txt + ls -l /dev/disk/by-wwn &> $Debug_Data_Dir/dev-disk-wwn-data.txt + ls -l /dev/disk/by-path &> $Debug_Data_Dir/dev-disk-path-data.txt + ls -l /dev/mapper &> $Debug_Data_Dir/dev-disk-mapper-data.txt + readlink /dev/root &> $Debug_Data_Dir/dev-root.txt + df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $Debug_Data_Dir/df-h-T-P-excludes.txt + df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $Debug_Data_Dir/df-T-P-excludes.txt + df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs --total &> $Debug_Data_Dir/df-T-P-excludes-total.txt + df -h -T &> $Debug_Data_Dir/bsd-df-h-T-no-excludes.txt + df -h &> $Debug_Data_Dir/bsd-df-h-no-excludes.txt + df -k -T &> $Debug_Data_Dir/bsd-df-k-T-no-excludes.txt + df -k &> $Debug_Data_Dir/bsd-df-k-no-excludes.txt + atacontrol list &> $Debug_Data_Dir/bsd-atacontrol-list.txt + camcontrol devlist &> $Debug_Data_Dir/bsd-camcontrol-devlist.txt # bsd tool - mount &> $debug_data_dir/mount.txt - btrfs filesystem show &> $debug_data_dir/btrfs-filesystem-show.txt - btrfs filesystem show --mounted &> $debug_data_dir/btrfs-filesystem-show-mounted.txt - # btrfs filesystem show --all-devices &> $debug_data_dir/btrfs-filesystem-show-all-devices.txt - gpart list &> $debug_data_dir/bsd-gpart-list.txt - gpart show &> $debug_data_dir/bsd-gpart-show.txt - gpart status &> $debug_data_dir/bsd-gpart-status.txt - swapctl -l -k &> $debug_data_dir/bsd-swapctl-l-k.txt - swapon -s &> $debug_data_dir/swapon-s.txt - sysctl -b kern.geom.conftxt &> $debug_data_dir/bsd-sysctl-b-kern.geom.conftxt.txt - sysctl -b kern.geom.confxml &> $debug_data_dir/bsd-sysctl-b-kern.geom.confxml.txt - zfs list &> $debug_data_dir/bsd-zfs-list.txt - zpool list &> $debug_data_dir/bsd-zpool-list.txt - zpool list -v &> $debug_data_dir/bsd-zpool-list-v.txt - df -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 &> $debug_data_dir/df-P-excludes.txt - df -P &> $debug_data_dir/bsd-df-P-no-excludes.txt - cat /proc/mdstat &> $debug_data_dir/proc-mdstat.txt - cat $FILE_PARTITIONS &> $debug_data_dir/proc-partitions.txt - cat $FILE_SCSI &> $debug_data_dir/proc-scsi.txt - cat $FILE_MOUNTS &> $debug_data_dir/proc-mounts.txt - cat /proc/sys/dev/cdrom/info &> $debug_data_dir/proc-cdrom-info.txt - ls /proc/ide/ &> $debug_data_dir/proc-ide.txt - cat /proc/ide/*/* &> $debug_data_dir/proc-ide-hdx-cat.txt - cat /etc/fstab &> $debug_data_dir/etc-fstab.txt - cat /etc/mtab &> $debug_data_dir/etc-mtab.txt + mount &> $Debug_Data_Dir/mount.txt + btrfs filesystem show &> $Debug_Data_Dir/btrfs-filesystem-show.txt + btrfs filesystem show --mounted &> $Debug_Data_Dir/btrfs-filesystem-show-mounted.txt + # btrfs filesystem show --all-devices &> $Debug_Data_Dir/btrfs-filesystem-show-all-devices.txt + gpart list &> $Debug_Data_Dir/bsd-gpart-list.txt + gpart show &> $Debug_Data_Dir/bsd-gpart-show.txt + gpart status &> $Debug_Data_Dir/bsd-gpart-status.txt + swapctl -l -k &> $Debug_Data_Dir/bsd-swapctl-l-k.txt + swapon -s &> $Debug_Data_Dir/swapon-s.txt + sysctl -b kern.geom.conftxt &> $Debug_Data_Dir/bsd-sysctl-b-kern.geom.conftxt.txt + sysctl -b kern.geom.confxml &> $Debug_Data_Dir/bsd-sysctl-b-kern.geom.confxml.txt + zfs list &> $Debug_Data_Dir/bsd-zfs-list.txt + zpool list &> $Debug_Data_Dir/bsd-zpool-list.txt + zpool list -v &> $Debug_Data_Dir/bsd-zpool-list-v.txt + df -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 &> $Debug_Data_Dir/df-P-excludes.txt + df -P &> $Debug_Data_Dir/bsd-df-P-no-excludes.txt + cat /proc/mdstat &> $Debug_Data_Dir/proc-mdstat.txt + cat $FILE_PARTITIONS &> $Debug_Data_Dir/proc-partitions.txt + cat $FILE_SCSI &> $Debug_Data_Dir/proc-scsi.txt + cat $FILE_MOUNTS &> $Debug_Data_Dir/proc-mounts.txt + cat /proc/sys/dev/cdrom/info &> $Debug_Data_Dir/proc-cdrom-info.txt + ls /proc/ide/ &> $Debug_Data_Dir/proc-ide.txt + cat /proc/ide/*/* &> $Debug_Data_Dir/proc-ide-hdx-cat.txt + cat /etc/fstab &> $Debug_Data_Dir/etc-fstab.txt + 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" + if [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then + echo 'Collecting networking data...' + ifconfig &> $Debug_Data_Dir/ifconfig.txt + ip addr &> $Debug_Data_Dir/ip-addr.txt + fi + # first download and verify xiin + if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then + touch $SELF_DATA_DIR/$Debug_Data_Dir/xiin-error.txt + fi + # note, only bash 4> supports ;;& for case, so using if/then here + if [[ -z $BSD_TYPE ]] && [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then + echo $Line + xiin_data_file=$SELF_DATA_DIR/$Debug_Data_Dir/xiin-sys.txt + touch $xiin_data_file + if type -p perl &>/dev/null;then + echo "Collecting data from /sys..." + echo -n "Using Perl: " && perl --version | grep -oE 'v[0-9.]+' + xiin_data="$( perl -e ' + use File::Find; + use strict; + # use warnings; + # use 5.010; + my @content = (); + find( \&wanted, "/sys"); + process_data( @content ); + sub wanted { + return if -d; # not directory + return unless -e; # Must exist + return unless -r; # Must be readable + return unless -f; # Must be file + # note: a new file in 4.11 /sys can hang this, it is /parameter/ then + # a few variables. Since inxi does not need to see that file, we will + # not use it. Also do not need . files or __ starting files + return if $File::Find::name =~ /\/(\.[a-z]|__|parameters\/|debug\/)/; + # comment this one out if you experience hangs + return unless -T; # Must be ascii like + # print $File::Find::name . "\n"; + push @content, $File::Find::name; + return; + } + sub process_data { + my $result = ""; + my $row = ""; + my $fh; + my $data=""; + my $sep=""; + # no sorts, we want the order it comes in + # @content = sort @content; + foreach (@content){ + $data=""; + $sep=""; + open($fh, "<$_"); + while ($row = <$fh>) { + chomp $row; + $data .= $sep . "\"" . $row . "\""; + $sep=", "; + } + $result .= "$_:[$data]\n"; + # print "$_:[$data]\n" + } + # print scalar @content . "\n"; + print "$result"; + } ' )" + if [[ -z "$xiin_data" ]];then + echo -e "ERROR: failed to generate /sys data - removing data file.\nContinuing with incomplete data collection." + echo "Continuing with incomplete data collection." + rm -f $xiin_data_file + echo "/sys data generation failed. No data collected." >> $Debug_Data_Dir/xiin-error.txt + else + echo 'Completed /sys data collection.' + echo -n "$xiin_data" > $xiin_data_file + fi + fi + if [[ -z "$xiin_data" ]];then + download_xiin 'sys' + if [[ $? -eq 0 ]];then + b_run_xiin='true' + b_xiin_downloaded='true' + echo "Running $Xiin_File tool now on /sys..." + echo -n "Using " && python --version + python --version &> $Debug_Data_Dir/python-version.txt + python ./$Xiin_File -d /sys -f $xiin_data_file + if [[ $? -ne 0 ]];then + error=$? + echo -e "ERROR: $Xiin_File exited with error $error - removing data file.\nContinuing with incomplete data collection." + rm -f $xiin_data_file + echo "$Xiin_File data generation failed with python error $error" >> $Debug_Data_Dir/xiin-error.txt + fi + fi + fi + + fi + # has to be before gz cleanup + if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then + if [[ $b_xiin_downloaded == 'false' ]];then + echo $Line + download_xiin 'upload' + if [[ $? -eq 0 ]];then + b_run_xiin='true' + fi + fi + fi + echo $Line + echo "Creating $SELF_NAME output file now. This can take a few seconds..." + echo "Starting $SELF_NAME from: $start_directory" cd $start_directory - $SCRIPT_PATH/$SCRIPT_NAME -FRfrploudmxxx -c 0 -@ 8 -y 120 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-FRfrploudmxxxy120.txt - cp $LOG_FILE $SCRIPT_DATA_DIR/$debug_data_dir - if [[ -f $SCRIPT_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 + $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 $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 + tar -cvzf $Debug_Data_Dir.tar.gz $Debug_Data_Dir echo $Line echo 'Cleaning up leftovers...' - rm -rf $debug_data_dir + rm -rf $Debug_Data_Dir echo 'Testing gzip file integrity...' - gzip -t $debug_data_dir.tar.gz + gzip -t $Debug_Data_Dir.tar.gz if [[ $? -gt 0 ]];then echo 'Data in gz is corrupted, removing gzip file, try running data collector again.' - rm -f $debug_data_dir.tar.gz - echo "Data in gz is corrupted, removed gzip file" >> $debug_data_dir/gzip-error.txt + rm -f $Debug_Data_Dir.tar.gz + 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 if [[ $b_run_xiin == 'true' ]];then echo "Running automatic upload of data to remote server $ftp_upload now..." - python ./$xiin_file --version - python ./$xiin_file -u $completed_gz_file $ftp_upload + python ./$Xiin_File --version + python ./$Xiin_File -u $completed_gz_file $ftp_upload if [[ $? -gt 0 ]];then echo $Line echo "Error: looks like the ftp upload failed. Error number: $?" - echo "The ftp upload failed. Error number: $?" >> $debug_data_dir/xiin-error.txt + # echo "The ftp upload failed. Error number: $?" >> $Debug_Data_Dir/xiin-error.txt fi else - echo 'Unable to run the automoatic ftp upload because of an error with the xiin download.' - echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $debug_data_dir/xiin-error.txt + echo 'Unable to run the automatic ftp upload because of an error with the xiin download.' + # echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $Debug_Data_Dir/xiin-error.txt fi else echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming' @@ -2051,12 +2312,73 @@ debug_data_collector() fi exit 0 } +# $1 - download type [sys|upload] +function download_xiin() +{ + local xiin_download='' xiin_url="https://github.com/smxi/inxi/raw/xiin/$Xiin_File" + local downloader_error=0 download_type='uploader' + + if [[ $1 == 'sys' ]];then + download_type='tree traverse' + fi + touch $Debug_Data_Dir/download_xiin.txt + echo "download_xiin: \$1 - $1" >> $Debug_Data_Dir/download_xiin.txt + echo "Downloading required $download_type tool $Xiin_File..." + if [[ -f xiin && ! -f $Xiin_File ]];then + mv -f xiin $Xiin_File + fi + # -Nc is creating really weird download anomalies, so using -O instead + case $DOWNLOADER in + curl) + xiin_download="$( curl $NO_SSL_OPT -s $xiin_url )" || downloader_error=$? + ;; + fetch) + xiin_download="$( fetch $NO_SSL_OPT -q -o - $xiin_url )" || downloader_error=$? + ;; + ftp) + xiin_download="$( ftp $NO_SSL_OPT -o - $xiin_url 2>/dev/null )" || downloader_error=$? + ;; + wget) + xiin_download="$( wget $NO_SSL_OPT -q -O - $xiin_url )" || downloader_error=$? + ;; + no-downloader) + downloader_error=100 + ;; + esac + # if nothing got downloaded kick out error, otherwise we'll use an older version + if [[ $downloader_error -gt 0 && ! -f $Xiin_File ]];then + echo -e "ERROR: Failed to download required file: $Xiin_File\nMaybe the remote site is down or your networking is broken?" + if [[ $1 == 'sys' ]];then + echo "Continuing with incomplete data collection." + else + echo "$SELF_NAME will be unable to automatically upload the debugger data." + fi + echo "$Xiin_File download failed and no existing $Xiin_File: error: $downloader_error" >> $Debug_Data_Dir/xiin-error.txt + return 1 + elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $Xiin_File ]];then + if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then + echo "Updating $Xiin_File from remote location" + echo "$xiin_download" > $Xiin_File + else + echo "Using local $Xiin_File due to download failure" + fi + return 0 + else + if [[ $1 == 'sys' ]];then + echo -e "ERROR: $Xiin_File downloaded but the program file data is corrupted.\nContinuing with incomplete data collection." + else + echo -e "ERROR: $Xiin_File downloaded but the program file data is corrupted.\nWill not be able to automatically upload debugger data file." + fi + echo "$Xiin_File downloaded but the program file data is corrupted." >> $Debug_Data_Dir/xiin-error.txt + return 2 + fi +} check_recommends_user_output() { local Line=$LINE1 local gawk_version='N/A' sed_version='N/A' sudo_version='N/A' python_version='N/A' - local downloaders_bsd='' + local downloaders_bsd='' perl_version='N/A' if [[ $B_IRC == 'true' ]];then print_screen_output "Sorry, you can't run this option in an IRC client." @@ -2068,7 +2390,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 @@ -2087,29 +2409,34 @@ check_recommends_user_output() if type -p python &>/dev/null;then python_version=$( python --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Python/ {print $2}' ) fi + # NOTE: does not actually handle 5/6 version, but ok for now + if type -p perl &>/dev/null;then + perl_version=$(perl --version | grep -m 1 -oE 'v[0-9.]+') + fi echo "Gawk version: $gawk_version" echo "Sed version: $sed_version" echo "Sudo version: $sudo_version" echo "Python version: $python_version" + echo "Perl version: $perl_versio" 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' @@ -2120,13 +2447,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' @@ -2161,8 +2488,10 @@ check_recommends_items() xrandr:x11-xserver-utils~xrandr~x11-server-utils~:-G_single_screen_resolution ' local recommended_apps=' + dig:dnsutils~dnsutils~bind-utils:-i_first_wlan_ip_default_test dmidecode:dmidecode~dmidecode~dmidecode~:-M_if_no_sys_machine_data;_-m_memory file:file~file~file~:-o_unmounted_file_system + hciconfig:bluez~bluez-utils~bluez-utils~:-n_-i_bluetooth_data hddtemp:hddtemp~hddtemp~hddtemp~:-Dx_show_hdd_temp ifconfig:net-tools~net-tools~net-tools~:-i_ip_lan-deprecated ip:iproute~iproute2~iproute~:-i_ip_lan @@ -2448,7 +2777,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:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt + while getopts AbBc:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt do case $opt in A) B_SHOW_AUDIO='true' @@ -2461,9 +2790,14 @@ get_parameters() B_SHOW_GRAPHICS='true' B_SHOW_INFO='true' B_SHOW_MACHINE='true' + B_SHOW_BATTERY='true' B_SHOW_NETWORK='true' B_SHOW_SYSTEM='true' ;; + B) B_SHOW_BATTERY_FORCED='true' + B_SHOW_BATTERY='true' + use_short='false' + ;; c) if [[ $OPTARG =~ ^[0-9][0-9]?$ ]];then case $OPTARG in 99) @@ -2527,6 +2861,7 @@ get_parameters() B_SHOW_GRAPHICS='true' B_SHOW_INFO='true' B_SHOW_MACHINE='true' + B_SHOW_BATTERY='true' B_SHOW_NETWORK='true' B_SHOW_PARTITIONS='true' B_SHOW_RAID='true' @@ -2553,6 +2888,7 @@ get_parameters() use_short='false' ;; M) B_SHOW_MACHINE='true' + B_SHOW_BATTERY='true' use_short='false' ;; n) B_SHOW_ADVANCED_NETWORK='true' @@ -2619,6 +2955,7 @@ get_parameters() if [[ $OPTARG -ge 2 ]];then B_SHOW_BASIC_DISK='true' B_SHOW_BASIC_RAID='true' + B_SHOW_BATTERY='true' B_SHOW_MACHINE='true' B_SHOW_NETWORK='true' fi @@ -2656,7 +2993,7 @@ get_parameters() fi ;; U) if [[ $B_ALLOW_UPDATE == 'true' ]];then - script_self_updater "$SCRIPT_DOWNLOAD" 'svn server' "$opt" + script_self_updater "$SELF_DOWNLOAD" 'source server' "$opt" else error_handler 17 "-$opt" fi @@ -2703,7 +3040,7 @@ get_parameters() ## debuggers and testing tools %) B_HANDLE_CORRUPT_DATA='true' ;; - @) if [[ -n $( grep -E "^([1-9]|1[0-4])$" <<< $OPTARG ) ]];then + @) if [[ -n $( grep -E "^([1-9]|1[0-5])$" <<< $OPTARG ) ]];then DEBUG=$OPTARG if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then B_UPLOAD_DEBUG_DATA='true' @@ -2723,7 +3060,7 @@ get_parameters() LOGFE=$LOGFE_STRING create_rotate_logfiles # create/rotate logfiles before we do anything else ;; - 11|12|13|14) + 11|12|13|14|15) case $OPTARG in 11) debug_data_type='sys' @@ -2737,6 +3074,10 @@ get_parameters() 14) debug_data_type='all' ;; + 15) + debug_data_type='all' + B_DEBUG_I='true' + ;; esac initialize_data debug_data_collector $debug_data_type @@ -2759,25 +3100,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" 'svn: 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" 'svn: 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" 'svn: 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" 'svn: 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" 'svn: 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" 'svn: 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 " @@ -2799,6 +3140,18 @@ get_parameters() 33) B_FORCE_DMIDECODE='true' ;; + 34) + NO_SSL_OPT=$NO_SSL + ;; + 40*) + DISPLAY=${OPTARG/40/} + if [[ $DISPLAY == '' ]];then + DISPLAY=':0' + fi + DISPLAY_OPT="-display $DISPLAY" + B_SHOW_DISPLAY_DATA='true' + B_RUNNING_IN_DISPLAY='true' + ;; ftp*) ALTERNATE_FTP="$OPTARG" ;; @@ -2857,17 +3210,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, 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_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" "-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" "-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 $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" @@ -2876,23 +3230,23 @@ show_options() print_lines_basic "2" "98" "Console IRC not in X" print_lines_basic "2" "99" "Global - Overrides/removes all settings. Setting specific removes global." print_lines_basic "1" "-C" "CPU output, including per CPU clockspeed and max CPU speed (if available)." - print_lines_basic "1" "-d" "Optical drive data. Same as -Dd. See also -x and -xx." + 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" "-G" "Graphic card information (card, display server type/version, resolution, glx renderer, version)." + 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). Also see -x, -xx, -xxx" - print_lines_basic "1" "-M" "Machine data. Motherboard, Bios, and if present, System Builder (Like Lenovo). Older systems/kernels without the required /sys data can use dmidecode instead, run as root. Dmidecode can be forced with -! 33" + 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" print_lines_basic "1" "-n" "Advanced Network card information. Same as -Nn. Shows interface, speed, mac id, state, etc." print_lines_basic "1" "-N" "Network card information. With -x, shows PCI BusID, Port number." print_lines_basic "1" "-o" "Unmounted $partition_string information (includes UUID and LABEL if available). Shows file system type if you have file installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^^ALL^=^NOPASSWD:^/usr/bin/file^" print_lines_basic "1" "-p" "Full $partition_string information (-P plus all other detected ${partition_string}s)." - print_lines_basic "1" "-P" "Basic $partition_string information (shows what -v^4 would show, but without extra data). Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted ${partition_string}s." - print_lines_basic "1" "-r" "Distro repository data. Supported repo types: APT; PACMAN; PISI; PORTAGE; PORTS (BSDs); SLACKPKG; URPMQ; YUM; ZYPP." + print_lines_basic "1" "-P" "Basic $partition_string information (shows what -v^4 would show, but without extra data). Shows, if detected: / /boot /home /opt /tmp /usr /var /var/log /var/tmp . Use -p to see all mounted ${partition_string}s." + print_lines_basic "1" "-r" "Distro repository data. Supported repo types: APK; APT; PACMAN; PISI; PORTAGE; PORTS (BSDs); SLACKPKG; URPMQ; YUM; ZYPP." print_lines_basic "1" "-R" "RAID data. Shows RAID devices, states, levels, and components, and extra data with -x/-xx. md-raid: If device is resyncing, shows resync progress line as well." print_lines_basic "1" "-s" "Sensors output (if sensors installed/configured): mobo/cpu/gpu temp; detected fan speeds. Gpu temp only for Fglrx/Nvidia drivers. Nvidia shows screen number for > 1 screens." print_lines_basic "1" "-S" "System information: host name, kernel, desktop environment (if in X), distro" @@ -2900,11 +3254,11 @@ 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, shows 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" "3" "Advanced CPU (-C), network (-n) data, and switches on -x advanced data option." + 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)." print_lines_basic "2" "6" "Full $partition_string (-p), unmounted $partition_string (-o), optical drive (-d), full raid; triggers -xx." @@ -2913,30 +3267,32 @@ 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" "-C" "CPU Flags, Bogomips on Cpu;" + print_lines_basic "2" "-B" "Vendor/model, status (if available)" + print_lines_basic "2" "-C" "CPU Flags, Bogomips on Cpu;CPU microarchitecture / revision if found, like: (Sandy Bridge rev.2)" print_lines_basic "2" "-d" "Extra optical drive data; adds rev version to optical drive." print_lines_basic "2" "-D" "Hdd temp with disk data if you have hddtemp installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^^ALL^=^NOPASSWD:^/usr/sbin/hddtemp" print_lines_basic "2" "-G" "Direct rendering status for Graphics (in X)." print_lines_basic "2" "-G" "(for single gpu, nvidia driver) screen number gpu is running on." - print_lines_basic "2" "-i" "IPv6 as well for LAN interface (IF) devices." + print_lines_basic "2" "-i" "For IPv6, show additional IP v6 scope addresses: Global, Site, Temporary, Unknown." print_lines_basic "2" "-I" "System GCC, default. With -xx, also show other installed GCC versions. If running in console, not in IRC client, shows shell version number, if detected. Init/RC Type and runlevel (if available)." print_lines_basic "2" "-m" "Part number; Max memory module size (if available)." print_lines_basic "2" "-N -A" "Version/port(s)/driver version (if available) for Network/Audio;" print_lines_basic "2" "-N -A -G" "Network, audio, graphics, shows PCI Bus ID/Usb ID number of card." print_lines_basic "2" "-R" "md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5); blocks; chunk size; bitmap (if present). Resync line, shows blocks synced/total blocks. zfs-raid: Shows raid array full size; available size; portion allocated to RAID" - print_lines_basic "2" "-S" "Desktop toolkit if avaliable (GNOME/XFCE/KDE only); Kernel gcc version" + print_lines_basic "2" "-S" "Desktop toolkit if available (GNOME/XFCE/KDE only); Kernel gcc version" print_lines_basic "2" "-t" "Memory use output to cpu (-xt c), and cpu use to memory (-xt m)." if [[ $B_ALLOW_WEATHER == 'true' ]];then print_lines_basic "2" "-w -W" "Wind speed and time zone (-w only)." fi print_lines_basic "1" "-xx" "Show extra, extra data (only works with verbose or line output, not short form):" print_lines_basic "2" "-A" "Chip vendor:product ID for each audio device." + print_lines_basic "2" "-B" "serial number, voltage (if available)." print_lines_basic "2" "-C" "Minimum CPU speed, if available." print_lines_basic "2" "-D" "Disk serial number." - print_lines_basic "2" "-G" "Chip vendor:product ID for each video card." + print_lines_basic "2" "-G" "Chip vendor:product ID for each video card; (mir/wayland only) compositor (alpha test); OpenGL compatibility version, if free drivers and available." print_lines_basic "2" "-I" "Other detected installed gcc versions (if present). System default runlevel. Adds parent program (or tty) for shell info if not in IRC (like Konsole or Gterm). Adds Init/RC (if found) version number." print_lines_basic "2" "-m" "Manufacturer, Serial Number, single/double bank (if found)." print_lines_basic "2" "-M" "Chassis information, bios rom size (dmidecode only), if data for either is available." @@ -2946,8 +3302,9 @@ 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." print_lines_basic "2" "-S" "Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel)." if [[ $B_ALLOW_WEATHER == 'true' ]];then @@ -2960,15 +3317,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" @@ -2984,6 +3341,8 @@ show_options() print_lines_basic "1" "-! 31" "Turns off hostname in output. Useful if showing output from servers etc." print_lines_basic "1" "-! 32" "Turns on hostname in output. Overrides global B_SHOW_HOST='false'" print_lines_basic "1" "-! 33" "Forces use of dmidecode data instead of /sys where relevant (-M)." + print_lines_basic "1" "-! 34" "Skips SSL certificate checks for all downloader activies (wget/fetch/curl only). Must go before other options." + print_lines_basic "1" "-! 40" "Will try to get display data out of X. Default gets it from display :0. If you use this format: -! 40:1 it would get it from display 1 instead, or any display you specify as long as there is no space between -! 40 and the :[display-number]." if [[ $1 == 'full' ]];then print_screen_output " " @@ -2992,13 +3351,13 @@ show_options() print_lines_basic "1" "-! 2" "Sets testing flag B_TESTING_2='true' to trigger testing condition 2." print_lines_basic "1" "-! 3" "Sets flags B_TESTING_1='true' and B_TESTING_2='true'." if [[ $B_ALLOW_UPDATE == 'true' ]];then - print_lines_basic "1" "-! 10" "Triggers an update from the primary dev download server instead of svn." - print_lines_basic "1" "-! 11" "Triggers an update from svn branch one - if present, of course." - print_lines_basic "1" "-! 12" "Triggers an update from svn branch two - if present, of course." - print_lines_basic "1" "-! 13" "Triggers an update from svn branch three - if present, of course." - print_lines_basic "1" "-! 14" "Triggers an update from svn branch four - if present, of course." - print_lines_basic "1" "-! 15" "Triggers an update from svn branch BSD - if present, of course." - print_lines_basic "1" "-! 16" "Triggers an update from svn branch GNUBSD - if present, of course." + print_lines_basic "1" "-! 10" "Triggers an update from the primary dev download server instead of source server." + print_lines_basic "1" "-! 11" "Triggers an update from source branch one - if present, of course." + print_lines_basic "1" "-! 12" "Triggers an update from source branch two - if present, of course." + print_lines_basic "1" "-! 13" "Triggers an update from source branch three - if present, of course." + print_lines_basic "1" "-! 14" "Triggers an update from source branch four - if present, of course." + print_lines_basic "1" "-! 15" "Triggers an update from source branch BSD - if present, of course." + print_lines_basic "1" "-! 16" "Triggers an update from source branch GNUBSD - if present, of course." print_lines_basic "1" "-! " " Triggers an update from whatever server you list." print_lines_basic "1" "" "Example: inxi^-!^http://yourserver.com/testing/inxi" fi @@ -3133,7 +3492,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 @@ -3141,25 +3500,22 @@ 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 print_screen_output "Started via symbolic link: $script_symbolic_start" fi - print_lines_basic "0" "" "Website:^http://inxi.googlecode.com" + print_lines_basic "0" "" "Website:^https://github.com/smxi/inxi^or^http://smxi.org/" 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." @@ -3195,7 +3551,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=$( tr '[A-Z]' '[a-z]' <<< $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 @@ -3212,7 +3573,11 @@ get_start_client() fi if [[ -n $pppid && -f /proc/$pppid/exe ]];then Irc_Client_Path="$( readlink /proc/$pppid/exe )" - irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< $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 @@ -3254,7 +3619,11 @@ get_start_client() if [[ -n $App_Working_Name ]];then Irc_Client_Path=$App_Working_Name - irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< $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 @@ -3666,7 +4035,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 { @@ -3689,7 +4058,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 } @@ -3697,7 +4066,11 @@ get_audio_data() audioCard=gensub(/^[0-9a-f:\.]+ [^:]+: (.+)$/,"\\1","g",$0) # The doublequotes are necessary because of the pipes in the variable. gsub(/'"$BAN_LIST_NORMAL"'/, "", audioCard) - gsub(/,/, " ", audioCard) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", audioCard) + if ( '$COLS_INNER' < 100 ){ + sub(/Series Family/,"Series", audioCard) + sub(/High Definition/,"High Def.", audioCard) + } gsub(/^ +| +$/, "", audioCard) gsub(/ [ \t]+/, " ", audioCard) aPciBusId[audioCard] = gensub(/(^[0-9a-f:\.]+) [^:]+: .+$/,"\\1","g",$0) @@ -3705,7 +4078,7 @@ get_audio_data() # loop until you get to the end of the data block while (getline && !/^$/) { - gsub( /,/, "", $0 ) + gsub(/'"$BAN_LIST_ARRAY"'/, "", $0 ) if (/driver in use/) { drivers[audioCard] = drivers[audioCard] gensub( /(.*): (.*)/ ,"\\2", "g" ,$0 ) "" } @@ -3816,7 +4189,7 @@ get_audio_usb_data() separator="" } { - gsub( /,/, " ", $0 ) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 ) gsub(/'"$BAN_LIST_NORMAL"'/, "", $0) gsub(/ [ \t]+/, " ", $0) for ( i=7; i<= NF; i++ ) { @@ -3864,8 +4237,8 @@ get_audio_alsa_data() # some alsa strings have the build date in (...) # remove trailing . and remove possible second line if compiled by user $0 !~ /compile/ { - gsub( /Driver | [(].*[)]|\.$/,"",$0 ) - gsub(/,/, " ", $0) + gsub(/Driver | [(].*[)]|\.$/,"",$0 ) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0) gsub(/^ +| +$/, "", $0) gsub(/ [ \t]+/, " ", $0) sub(/Advanced Linux Sound Architecture/, "ALSA", $0) @@ -3883,12 +4256,441 @@ get_audio_alsa_data() eval $LOGFE } +get_battery_data() +{ + eval $LOGFS + local a_temp='' id_file='' count=0 + local id_dir='/sys/class/power_supply/' + local ids=$( ls $id_dir 2>/dev/null ) battery_file='' + + # ids='BAT0 BAT1 BAT2' + if [[ -n $ids && $B_FORCE_DMIDECODE == 'false' ]];then + for idx in $ids + do + battery_file=$id_dir$idx'/uevent' + if [[ -r $battery_file ]];then + # echo $battery_file + count=$(( $count + 1 )) + IFS=$'\n' + battery_data=$( + gawk -F '=' ' + BEGIN { + IGNORECASE=1 + name="" + status="" + present="" + chemistry="" + cycles="" + voltage_min_design="" + voltage_now="" + power_now="" + # charge: mAh + charge_full_design="" + charge_full="" + charge_now="" + # energy: Wh + energy_full_design="" + energy_full="" + energy_now="" + capacity="" + capacity_level="" + model="" + company="" + serial="" + of_orig="" + location="" + b_ma="false" # trips ma x voltage + } + { + gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2) + gsub(/^ +| +$/, "", $2) + } + $1 ~ /^POWER_SUPPLY_NAME$/ { + name=$NF + } + $1 ~ /^POWER_SUPPLY_STATUS$/ { + status=$NF + } + $1 ~ /^POWER_SUPPLY$/ { + present=$NF + } + $1 ~ /^POWER_SUPPLY_TECHNOLOGY$/ { + chemistry=$NF + } + $1 ~ /^POWER_SUPPLY_CYCLE_COUNT$/ { + cycles=$NF + } + $1 ~ /^POWER_SUPPLY_VOLTAGE_MIN_DESIGN$/ { + voltage_min_design = $NF / 1000000 + voltage_min_design = sprintf( "%.1f", voltage_min_design ) + } + $1 ~ /^POWER_SUPPLY_VOLTAGE_NOW$/ { + voltage_now = $NF / 1000000 + voltage_now = sprintf( "%.1f", voltage_now ) + } + $1 ~ /^POWER_SUPPLY_POWER_NOW$/ { + power_now=$NF + } + $1 ~ /^POWER_SUPPLY_ENERGY_FULL_DESIGN$/ { + energy_full_design = $NF / 1000000 + } + $1 ~ /^POWER_SUPPLY_ENERGY_FULL$/ { + energy_full = $NF / 1000000 + } + $1 ~ /^POWER_SUPPLY_ENERGY_NOW$/ { + energy_now = $NF / 1000000 + energy_now = sprintf( "%.1f", energy_now ) + } + # note: the following 3 were off, 100000 instead of 1000000 + # why this is, I do not know. I did not document any reason for that + # so going on assumption it is a mistake. CHARGE is mAh, which are converted + # to Wh by: mAh x voltage. Note: voltage fluctuates so will make results vary slightly. + $1 ~ /^POWER_SUPPLY_CHARGE_FULL_DESIGN$/ { + charge_full_design = $NF / 1000000 + b_ma="true" + } + $1 ~ /^POWER_SUPPLY_CHARGE_FULL$/ { + charge_full = $NF / 1000000 + b_ma="true" + } + $1 ~ /^POWER_SUPPLY_CHARGE_NOW$/ { + charge_now = $NF / 1000000 + b_ma="true" + } + $1 ~ /^POWER_SUPPLY_CAPACITY$/ { + if ( $NF != "" ){ + capacity=$NF "%" + } + } + $1 ~ /^POWER_SUPPLY_CAPACITY_LEVEL$/ { + capacity_level=$NF + } + $1 ~ /^POWER_SUPPLY_MODEL_NAME$/ { + model=$NF + } + $1 ~ /^POWER_SUPPLY_MANUFACTURER$/ { + company=$NF + } + $1 ~ /^POWER_SUPPLY_SERIAL_NUMBER$/ { + serial=$NF + } + END { + # note:voltage_now fluctuates, which will make capacity numbers change a bit + # if any of these values failed, the math will be wrong, but no way to fix that + # tests show more systems give right capacity/charge with voltage_min_design + # than with voltage_now + if (b_ma == "true" && voltage_min_design != ""){ + if (charge_now != ""){ + energy_now=charge_now*voltage_min_design + } + if (charge_full != ""){ + energy_full=charge_full*voltage_min_design + } + if (charge_full_design != ""){ + energy_full_design=charge_full_design*voltage_min_design + } + } + if (energy_now != "" && energy_full != "" ){ + capacity = 100*energy_now/energy_full + capacity = sprintf( "%.1f%", capacity ) + } + if (energy_full_design != "" && energy_full != "" ){ + of_orig=100*energy_full/energy_full_design + of_orig = sprintf( "%.0f%", of_orig ) + } + if (energy_now != "" ){ + energy_now = sprintf( "%.1f", energy_now ) + } + if (energy_full_design != "" ){ + energy_full_design = sprintf( "%.1f", energy_full_design ) + } + if ( energy_full != "" ){ + energy_full = sprintf( "%.1f", energy_full ) + } + entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now "," + entry = entry power_now "," energy_full_design "," energy_full "," energy_now "," capacity "," + entry = entry capacity_level "," of_orig "," model "," company "," serial "," location + print entry + }' < $battery_file ) + # <<< "$data" ) + # < $battery_file ) + A_BATTERY_DATA[$count]=$battery_data + IFS="$ORIGINAL_IFS" + fi + done + elif [[ $B_FORCE_DMIDECODE == 'true' ]] || [[ ! -d $id_dir && -z $ids ]];then + get_dmidecode_data + if [[ -n $DMIDECODE_DATA ]];then + if [[ $DMIDECODE_DATA == 'dmidecode-error-'* ]];then + A_BATTERY_DATA[0]=$DMIDECODE_DATA + # please note: only dmidecode version 2.11 or newer supports consistently the -s flag + else + IFS=$'\n' + # NOTE: this logic has a flaw, which is multiple batteries, which won't work without + # gawk arrays, but sorry, too much of a pain given how little useful data from dmidecode + A_BATTERY_DATA=( $( gawk -F ':' ' + BEGIN { + IGNORECASE=1 + name="" + status="" + present="" + chemistry="" + cycles="" + voltage_min_design="" + voltage_now="" + power_now="" + charge_full_design="" + charge_full="" + charge_now="" + capacity="" + capacity_level="" + model="" + company="" + serial="" + of_orig="" + location="" + bItemFound="false" + } + { + gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2) + gsub(/^ +| +$/, "", $1) + gsub(/^ +| +$/, "", $2) + } + /^Portable Battery/ { + while ( getline && !/^$/ ) { + if ( $1 ~ /^Location/ ) { location=$2 } + if ( $1 ~ /^Manufacturer/ ) { company=$2 } + if ( $1 ~ /^Serial/ ) { serial=$2 } + if ( $1 ~ /^Name/ ) { model=$2 } + if ( $1 ~ /^Design Capacity/ ) { + sub(/^[[:space:]]*mwh/, "", $2) + charge_full_design = $NF / 1000 + charge_full_design = sprintf( "%.1f", charge_full_design ) + } + if ( $1 ~ /^Design Voltage/ ) { + sub(/^[[:space:]]*mv/, "", $2) + voltage_min_design = $NF / 1000 + voltage_min_design = sprintf( "%.1f", voltage_min_design ) + } + if ( $1 ~ /^SBDS Chemistry/ ) { chemistry=$2 } + } + testString=company serial model charge_full_design voltage_min_design + if ( testString != "" ) { + bItemFound="true" + exit # exit loop, we are not handling > 1 batteries + } + } + END { + if ( bItemFound == "true" ) { + name="BAT-1" + if (charge_now != "" && charge_full != "" ){ + capacity = 100*charge_now/charge_full + capacity = sprintf( "%.1f%", capacity ) + } + if (charge_full_design != "" && charge_full != "" ){ + of_orig=100*charge_full/charge_full_design + of_orig = sprintf( "%.0f%", of_orig ) + } + entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now "," + entry = entry power_now "," charge_full_design "," charge_full "," charge_now "," capacity "," + entry = entry capacity_level "," of_orig "," model "," company "," serial "," location + print entry + } + }' <<< "$DMIDECODE_DATA" ) ) + IFS="$ORIGINAL_IFS" + fi + fi + fi + # echo $array_string + + #echo ${#A_BATTERY_DATA[@]} + a_temp=${A_BATTERY_DATA[@]} + + # echo $a_temp + log_function_data "A_BATTERY_DATA: $a_temp" + eval $LOGFE +} + +## args: $1 type [intel|amd|centaur|arm]; $2 family [hex]; $3 model id [hex]; +get_cpu_architecture() +{ + eval $LOGFS + case $1 in + amd) + case $2 in + 4) + case $3 in + 3|7|8|9|A)ARCH='Am486';; + E|F)ARCH='Am5x86';; + esac + ;; + 5) + case $3 in + 0|1|2|3)ARCH='K5';; + 6|7)ARCH='K6';; + 8)ARCH='K6-2';; + 9|D)ARCH='K6-3';; + A)ARCH='Geode';; + esac + ;; + 6) + case $3 in + 1|2)ARCH='K7';; + 3|4)ARCH='K7 Thunderbird';; + 6|7|8|A)ARCH='K7 Palomino+';; + *)ARCH='K7';; + esac + ;; + F) + case $3 in + 4|5|7|8|B|C|E|F|14|15|17|18|1B|1C|1F)ARCH='K8';; + 21|23|24|25|27|28|2C|2F)ARCH='K8 rev.E';; + 41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|7F|C1)ARCH='K8 rev.F+';; + *)ARCH='K8';; + esac + ;; + 10) + case $3 in + 2|4|5|6|8|9|A)ARCH='K10';; + *)ARCH='K10';; + esac + ;; + 11) + case $3 in + 3)ARCH='K8 rev.E+';; + esac + ;; + 12) + case $3 in + 1)ARCH='K10';; + *)ARCH='K10';; + esac + ;; + 14) + case $3 in + 1|2)ARCH='Bobcat';; + *)ARCH='Bobcat';; + esac + ;; + 15) + case $3 in + 0|1)ARCH='Bulldozer';; + 2|10|13)ARCH='Piledriver';; + 30|38)ARCH='Steamroller';; + 60|65|70)ARCH='Excavator';; + *)ARCH='Bulldozer';; + esac + ;; + 16) + case $3 in + 0)ARCH='Jaguar';; + 30)ARCH='Puma';; + *)ARCH='Jaguar';; + esac + ;; + 17) + case $3 in + 1)ARCH='Zen';; + *)ARCH='Zen';; + esac + ;; + esac + ;; + arm) + if [[ "$2" != '' ]];then + ARCH="ARMv$2" + else + ARCH='ARM' + fi + ;; + centaur) # aka VIA + case $2 in + 5) + case $3 in + 4)ARCH='WinChip C6';; + 8)ARCH='WinChip 2';; + 9)ARCH='WinChip 3';; + esac + ;; + 6) + case $3 in + 6)ARCH='WinChip-based';; + 7|8)ARCH='C3';; + 9)ARCH='C3-2';; + A|D)ARCH='C7';; + F)ARCH='Isaiah';; + esac + ;; + esac + ;; + intel) + case $2 in + 4) + case $3 in + 0|1|2|3|4|5|6|7|8|9)ARCH='486';; + esac + ;; + 5) + case $3 in + 1|2|3|7)ARCH='P5';; + 4|8)ARCH='P5';; # MMX + 9)ARCH='Quark';; + esac + ;; + 6) + case $3 in + 1)ARCH='P6 Pro';; + 3|5|6)ARCH='P6 II';; + 7|8|A|B)ARCH='P6 III';; + 9)ARCH='Banias';; # pentium M + 15)ARCH='Dothan Tolapai';; # pentium M system on chip + D)ARCH='Dothan';; # Pentium M + E)ARCH='Yonah';; + F|16)ARCH='Conroe';; + 17|1D)ARCH='Penryn';; + 1A|1E|1F|2E|25|2C|2F)ARCH='Nehalem';; + 1C|26)ARCH='Bonnell';; + 27|35|36)ARCH='Saltwell';; + 25|2C|2F)ARCH='Westmere';; + 26|27)ARCH='Bonnell';; + 2A|2D)ARCH='Sandy Bridge';; + 37|4A|4D|5A)ARCH='Silvermont';; + 3A|3E)ARCH='Ivy Bridge';; + 3C|3F|45|46)ARCH='Haswell';; + 3D|47|4F|56)ARCH='Broadwell';; + 4E|55|9E)ARCH='Skylake';; + 4C|5D)ARCH='Airmont';; + 8E|9E)ARCH='Kaby Lake';; + 57)ARCH='Knights Landing';; + 85)ARCH='Knights Mill';; + esac + ;; + B) + case $3 in + 1)ARCH='Knights Corner';; + esac + ;; + F) + case $3 in + 0|1|2)ARCH='Netburst Willamette';; + 3|4|6)ARCH='Netburst Prescott';; # Nocona + *)ARCH='Netburst';; + esac + ;; + esac + ;; + + esac + log_function_data "ARCH: $ARCH" + eval $LOGFE +} + ## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text ## return value cpu core count string, this helps resolve the multi redundant lines of old style output get_cpu_core_count() { eval $LOGFS - local cpu_physical_count='' cpu_core_count='' cpu_type='' cpu_alpha_count='' cores_per_cpu='' + local cpu_physical_count='' cpu_core_count='' cpu_type='' cores_per_cpu='' local array_data='' if [[ $B_CPUINFO_FILE == 'true' ]]; then @@ -3901,11 +4703,11 @@ get_cpu_core_count() cpu_type=${A_CPU_TYPE_PCNT_CCNT[0]} # match the numberic value to an alpha value - cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" ) + get_cpu_core_count_alpha "$cpu_core_count" # create array, core count integer; core count string - # A_CPU_CORE_DATA=( "$cpu_core_count" "$cpu_alpha_count Core$cpu_type" ) - array_data="$cpu_physical_count,$cpu_alpha_count,$cpu_type,$cpu_core_count" + # A_CPU_CORE_DATA=( "$cpu_core_count" "$CPU_COUNT_ALPHA Core$cpu_type" ) + array_data="$cpu_physical_count,$CPU_COUNT_ALPHA,$cpu_type,$cpu_core_count" IFS=',' A_CPU_CORE_DATA=( $array_data ) IFS="$ORIGINAL_IFS" @@ -3928,14 +4730,14 @@ 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 - cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" ) + get_cpu_core_count_alpha "$cpu_core_count" if [[ $cpu_core_count -gt 1 ]];then cpu_type='-SMP-' else @@ -3952,7 +4754,7 @@ get_cpu_core_count() else cpu_physical_count=1 fi - array_data="$cpu_physical_count,$cpu_alpha_count,$cpu_type,$cpu_core_count" + array_data="$cpu_physical_count,$CPU_COUNT_ALPHA,$cpu_type,$cpu_core_count" IFS=',' A_CPU_CORE_DATA=( $array_data ) IFS="$ORIGINAL_IFS" @@ -3967,23 +4769,21 @@ get_cpu_core_count() get_cpu_core_count_alpha() { eval $LOGFS - local cpu_alpha_count='' - + case $1 in - 1) cpu_alpha_count='Single';; - 2) cpu_alpha_count='Dual';; - 3) cpu_alpha_count='Triple';; - 4) cpu_alpha_count='Quad';; - 5) cpu_alpha_count='Penta';; - 6) cpu_alpha_count='Hexa';; - 7) cpu_alpha_count='Hepta';; - 8) cpu_alpha_count='Octa';; - 9) cpu_alpha_count='Ennea';; - 10) cpu_alpha_count='Deca';; - *) cpu_alpha_count='Multi';; + 1) CPU_COUNT_ALPHA='Single';; + 2) CPU_COUNT_ALPHA='Dual';; + 3) CPU_COUNT_ALPHA='Triple';; + 4) CPU_COUNT_ALPHA='Quad';; + 5) CPU_COUNT_ALPHA='Penta';; + 6) CPU_COUNT_ALPHA='Hexa';; + 7) CPU_COUNT_ALPHA='Hepta';; + 8) CPU_COUNT_ALPHA='Octa';; + 9) CPU_COUNT_ALPHA='Ennea';; + 10) CPU_COUNT_ALPHA='Deca';; + *) CPU_COUNT_ALPHA='Multi';; esac - - echo $cpu_alpha_count + log_function_data "CPU_COUNT_ALPHA: $CPU_COUNT_ALPHA" eval $LOGFE } @@ -4014,38 +4814,74 @@ get_cpu_data() nr = 0 count = 0 bArm = "false" + bProcInt = "false" # this will avoid certain double counts with processor/Processor lines # ARM cpus are erratic in /proc/cpuinfo this hack can sometimes resolve it. Linux only. sysSpeed="'$(get_cpu_speed_hack)'" speed = 0 max = 0 min = 0 + type="" + family="" + model_nu="" + rev="" } # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+ # TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES! # Therefore PATCH to use [ \t]+ when TESTING! /^processor[ \t]+:/ { - gsub(/,/, " ", $NF) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF) gsub(/^ +| +$/, "", $NF) if ( $NF ~ "^[0-9]+$" ) { nr = $NF + bProcInt = "true" } else { - if ( $NF ~ "^ARM" ) { - bArm = "true" + # this protects against double processor lines, one int, one string + if ( bProcInt == "false" ){ + count += 1 + nr = count - 1 } - count += 1 - nr = count - 1 + # note: alternate: + # Processor : AArch64 Processor rev 4 (aarch64) + # but no model name type + if ( $NF ~ "(ARM|AArch)" ) { + bArm = "true" + if ( type=""){ + type="arm" + } + } + gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) + gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) + gsub(/^ +| +$/, "", $NF) + gsub(/ [ \t]+/, " ", $NF) cpu[nr, "model"] = $NF } } + # arm + /^cpu architecture/ && (family = "") { + gsub(/^ +| +$/, "", $NF) + family=$NF + } + /^cpu family/ && ( family == ""){ + gsub(/^ +| +$/, "", $NF) + family=toupper( sprintf("%x", $NF) ) + } + /^(stepping|cpu revission)/ && ( rev == "" ){ + gsub(/^ +| +$/, "", $NF) + rev=$NF + } + /^model[ \t]*:/ && ( model_nu == ""){ + gsub(/^ +| +$/, "", $NF) + model_nu=toupper( sprintf("%x", $NF) ) + } /^model name|^cpu\t+:/ { gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) - gsub(/,/, " ", $NF) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF) gsub(/^ +| +$/, "", $NF) gsub(/ [ \t]+/, " ", $NF) cpu[nr, "model"] = $NF - if ( $NF ~ "^ARM" ) { + if ( $NF ~ "^(ARM|AArch)" ) { bArm = "true" } } @@ -4077,10 +4913,23 @@ get_cpu_data() } /^bogomips/ { cpu[nr, "bogomips"] = $NF + # print nr " " cpu[nr, "bogomips"] > "/dev/tty" } /vendor_id/ { gsub(/genuine|authentic/,"",$NF) cpu[nr, "vendor"] = tolower( $NF ) + if ( type == ""){ + if ( $NF ~ /.*intel.*/ ) { + type="intel" + } + else if ($NF ~ /.*amd.*/){ + type="amd" + } + # via + else if ($NF ~ /.*centaur.*/){ + type="centaur" + } + } } END { #if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that @@ -4095,6 +4944,7 @@ get_cpu_data() } else if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) { cpu[i, "speed"] = cpu[i, "bogomips"] + } print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"] "," bArm } @@ -4108,11 +4958,15 @@ get_cpu_data() sub(/\.[0-9]+$/,"",max) sub(/\.[0-9]+$/,"",speed) sub(/\.[0-9]+$/,"",min) + if ( bArm == "true" ){ + type = "arm" + } if (speed == 0) { - print "N/A," min "," max + print "N/A," min "," max "," type "," family "," model_nu } else { - print speed "," min "," max + # print speed "," min "," max "," type "," family "," model_nu "," rev > "/dev/tty" + print speed "," min "," max "," type "," family "," model_nu "," rev } } ' $FILE_CPUINFO ) ) @@ -4152,11 +5006,11 @@ 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 + IGNORECASE=1 } # NOTE: freebsd may say: 2300-MHz, so check for dash as well $1 ~ /^(CPU|cpu0)$/ { @@ -4172,7 +5026,7 @@ get_cpu_data_bsd() print max exit } - }' <<< "$Dmesg_Boot_Data" ) + }' <<< "$DMESG_BOOT_DATA" ) fi IFS=$'\n' A_CPU_DATA=( $( @@ -4187,11 +5041,16 @@ get_cpu_data_bsd() bSwitchFs="false" min=0 max=0 + # these can be found in dmesg.boot just like in cpuinfo except all in one row + type="" + family="" + model_nu="" + rev="" } /^hw.model/ && ( bsdVersion != "darwin" ) { gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) - gsub(/,/," ",$NF) + gsub(/'"$BAN_LIST_ARRAY"'/," ",$NF) sub(/[a-z]+-core/, "", $NF ) gsub(/^ +| +$|\"/, "", $NF) gsub(/ [ \t]+/, " ", $NF) @@ -4248,7 +5107,7 @@ get_cpu_data_bsd() /^machdep.cpu.brand_string/ { gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) - gsub(/,/," ",$NF) + gsub(/'"$BAN_LIST_ARRAY"'/," ",$NF) sub(/[a-z]+-core/, "", $NF ) gsub(/^ +| +$|\"/, "", $NF) gsub(/ [ \t]+/, " ", $NF) @@ -4266,9 +5125,9 @@ get_cpu_data_bsd() sub(/\.[0-9]+/,"",min) sub(/\.[0-9]+/,"",max) print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor - # triggers print case - print cpuClock "," min "," max - }' <<< "$Sysctl_a_Data" ) ) + # triggers print case, for architecture, check source for syntax + print cpuClock "," min "," max ",,,," + }' <<< "$SYSCTL_A_DATA" ) ) IFS="$ORIGINAL_IFS" fi @@ -4282,7 +5141,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 @@ -4295,15 +5154,15 @@ get_cpu_flags_bsd() gsub(/<[a-z0-9]+>/,"", $2) # all the flags are contained within < ... > on freebsd at least gsub(/.*<|>.*/,"", $2) - gsub(/,/," ", $2) + gsub(/'"$BAN_LIST_ARRAY"'/," ", $2) cpuFlags = cpuFlags " " $2 } } 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 @@ -4315,7 +5174,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" @@ -4356,6 +5215,7 @@ get_cpu_ht_multicore_smp_data() arm_count = 0 nr = 0 bArm = "false" + bProcInt = "false" # this will avoid certain double counts with processor/Processor lines bXeon = "false" } # hack to handle xeons which can have buggy /proc/cpuinfo files @@ -4370,23 +5230,32 @@ get_cpu_ht_multicore_smp_data() } } # array of logical processors, both HT and physical + # IMPORTANT: some variants have two lines, one the actual cpu id number, + # the other a misnamed model name line. + # processor : 0 + # Processor : AArch64 Processor rev 4 (aarch64) /^processor/ { - gsub(/,/, " ", $NF) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF) gsub(/^ +| +$/, "", $NF) if ( $NF ~ "^[0-9]+$" ) { a_processor_id[proc_iter] = $NF proc_iter++ + bProcInt = "true" } else { # note, for dual core, this can be off by one because the first # line says: Processor : Arm.. but subsequent say: processor : 0 and so on as usual - if ( $NF ~ "^ARM" ) { + # Processor : AArch64 Processor rev 4 (aarch64) + if ( $NF ~ "^(ARM|AArch)" ) { bArm = "true" } - arm_count += 1 - nr = arm_count - 1 - # note: do not iterate because new ARM syntax puts cpu in processsor : 0 syntax - a_processor_id[proc_iter] = nr + # this protects against double processor lines, one int, one string + if ( bProcInt == "false" ){ + arm_count += 1 + nr = arm_count - 1 + # note: do not iterate because new ARM syntax puts cpu in processsor : 0 syntax + a_processor_id[proc_iter] = nr + } } } # array of physical cpu ids, note, this will be unset for vm cpus in many cases @@ -4497,24 +5366,45 @@ get_desktop_environment() # set the default, this function only runs in X, if null, don't print data out local desktop_environment='' xprop_root='' version2='' - local version='' version_data='' toolkit='' + local version='' version_data='' version2_data='' toolkit='' # works on 4, assume 5 will id the same, why not, no need to update in future # KDE_SESSION_VERSION is the integer version of the desktop + # NOTE: as of plasma 5, the tool: about-distro MAY be available, that will show + # actual desktop data, so once that's in debian/ubuntu, if it gets in, add that test if [[ $XDG_CURRENT_DESKTOP == 'KDE' || -n $KDE_SESSION_VERSION ]]; then # note the command is actually like, kded4 --version, so we construct it - version_data=$( kded$KDE_SESSION_VERSION --version 2>/dev/null ) - version=$( grep -si '^KDE Development Platform:' <<< "$version_data" | gawk '{print $4}' ) + # this was supposed to extend to 5, but 5 changed it, so it uses the more reliable way + if [[ $KDE_SESSION_VERSION -le 4 ]];then + version_data=$( kded$KDE_SESSION_VERSION --version 2>/dev/null ) + version=$( grep -si '^KDE Development Platform:' <<< "$version_data" | gawk '{print $4}' ) + else + # NOTE: this command string is almost certain to change, and break, with next major plasma desktop, ie, 6 + # version=$( qdbus org.kde.plasmashell /MainApplication org.qtproject.Qt.QCoreApplication.applicationVersion 2>/dev/null ) + #Qt: 5.4.2 + #KDE Frameworks: 5.11.0 + #kf5-config: 1.0 + # for QT, and Frameworks if we use it + if type -p kf$KDE_SESSION_VERSION-config &>/dev/null;then + version_data=$( kf$KDE_SESSION_VERSION-config --version 2>/dev/null ) + # version=$( grep -si '^KDE Frameworks:' <<< "$version_data" | gawk '{print $NF}' ) + fi + # plasmashell 5.3.90 + if type -p plasmashell &>/dev/null;then + version2_data=$( plasmashell --version 2>/dev/null ) + version=$( grep -si '^plasmashell' <<< "$version2_data" | gawk '{print $NF}' ) + fi + fi if [[ -z $version ]];then version=$KDE_SESSION_VERSION fi - if [[ $B_EXTRA_DATA == 'true' ]];then + if [[ $B_EXTRA_DATA == 'true' && -n $version_data ]];then toolkit=$( grep -si '^Qt:' <<< "$version_data" | gawk '{print $2}' ) if [[ -n $toolkit ]];then version="$version (Qt $toolkit)" fi fi - desktop_environment="KDE" + desktop_environment="KDE Plasma" # KDE_FULL_SESSION property is only available since KDE 3.5.5. # src: http://humanreadable.nfshost.com/files/startkde elif [[ $KDE_FULL_SESSION == 'true' ]]; then @@ -4544,6 +5434,19 @@ get_desktop_environment() fi fi desktop_environment="Unity" + elif [[ $XDG_CURRENT_DESKTOP == *Budgie* ]];then + version=$( get_program_version 'budgie-desktop' '^budgie-desktop' '2' ) + # not certain will always have version, so keep output right if not + if [[ -n $version ]];then + version="$version " + fi + if [[ $B_EXTRA_DATA == 'true' ]];then + toolkit=$( get_de_gtk_data ) + if [[ -n $toolkit ]];then + version="$version(Gtk $toolkit)" + fi + fi + desktop_environment="Budgie" elif [[ $XDG_CURRENT_DESKTOP == 'LXQt' ]];then # if type -p lxqt-about &>/dev/null;then # version=$( get_program_version 'lxqt-about' '^lxqt-about' '2' ) @@ -4578,13 +5481,13 @@ get_desktop_environment() # did we find it? If not, start the xprop tests if [[ -z $desktop_environment ]];then if type -p xprop &>/dev/null;then - xprop_root="$( xprop -root 2>/dev/null )" + xprop_root="$( xprop -root $DISPLAY_OPT 2>/dev/null | tr '[:upper:]' '[:lower:]' )" fi # note that cinnamon split from gnome, and and can now be id'ed via xprop, # but it will still trigger the next gnome true case, so this needs to go before gnome test # eventually this needs to be better organized so all the xprop tests are in the same # section, but this is good enough for now. - if [[ -n $xprop_root && -n $( grep -is '^_MUFFIN' <<< "$xprop_root" ) ]];then + if [[ -n $xprop_root && -z ${xprop_root/*_muffin*/} ]];then version=$( get_program_version 'cinnamon' '^cinnamon' '2' ) # not certain cinn will always have version, so keep output right if not if [[ -n $version ]];then @@ -4597,7 +5500,7 @@ get_desktop_environment() fi fi desktop_environment="Cinnamon" - elif [[ $XDG_CURRENT_DESKTOP == 'MATE' ]] || [[ -n $xprop_root && -n $( grep -is '^_MARCO' <<< "$xprop_root" ) ]];then + elif [[ $XDG_CURRENT_DESKTOP == 'MATE' ]] || [[ -n $xprop_root && -z ${xprop_root/*_marco*/} ]];then version=$( get_program_version 'mate-about' '^MATE[[:space:]]DESKTOP' 'NF' ) # not certain cinn/mate will always have version, so keep output right if not if [[ -n $version ]];then @@ -4632,7 +5535,7 @@ get_desktop_environment() if [[ -n $xprop_root ]];then # String: "This is xfdesktop version 4.2.12" # alternate: xfce4-about --version > xfce4-about 4.10.0 (Xfce 4.10) - if [[ -n $( grep -Eis '\"xfce4\"' <<< "$xprop_root" ) ]];then + if [[ -z ${xprop_root/*\"xfce4\"*/} ]];then version=$( get_program_version 'xfdesktop' 'xfdesktop[[:space:]]version' '5' ) # arch linux reports null, so use alternate if null if [[ -z $version ]];then @@ -4649,7 +5552,7 @@ get_desktop_environment() fi desktop_environment="Xfce" # when 5 is released, the string may need updating - elif [[ -n $( grep -is '\"xfce5\"' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*\"xfce5\"*/} ]];then version=$( get_program_version 'xfdesktop' 'xfdesktop[[:space:]]version' '5' ) # arch linux reports null, so use alternate if null if [[ -z $version ]];then @@ -4666,7 +5569,7 @@ get_desktop_environment() fi desktop_environment="Xfce" # case where no xfce number exists, just xfce - elif [[ -n $( grep -is 'xfce' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*xfce*/} ]];then version=$( get_program_version 'xfdesktop' 'xfdesktop[[:space:]]version' '5' ) # arch linux reports null, so use alternate if null if [[ -z $version ]];then @@ -4686,27 +5589,26 @@ get_desktop_environment() fi fi desktop_environment="Xfce" - elif [[ -n $( grep -is 'BLACKBOX_PID' <<< "$xprop_root" ) ]];then - if [[ -n $( grep -is 'fluxbox' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z ${xprop_root/*blackbox_pid*/} ]];then + if [[ -z "${Ps_aux_Data/*fluxbox*/}" ]];then version=$( get_program_version 'fluxbox' '^fluxbox' '2' ) desktop_environment='Fluxbox' else desktop_environment='Blackbox' fi - elif [[ -n $( grep -is 'OPENBOX_PID' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*openbox_pid*/} ]];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 + [[ -n $( grep -Es '(razor-desktop|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' @@ -4717,24 +5619,26 @@ get_desktop_environment() else desktop_environment='Openbox' fi - elif [[ -n $( grep -is 'ICEWM' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*icewm*/} ]];then version=$( get_program_version 'icewm' '^icewm' '2' ) desktop_environment='IceWM' - elif [[ -n $( grep -is 'ENLIGHTENMENT' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*enlightenment*/} ]];then # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Enlightenment 0.16.999.49898" version=$( grep -is 'ENLIGHTENMENT_VERSION' <<< "$xprop_root" | cut -d '"' -f 2 | gawk '{print $2}' ) desktop_environment='Enlightenment' - elif [[ -n $( grep -is '^I3_' <<< "$xprop_root" ) ]];then + # need to check starts line because it's so short + elif [[ -n $( grep -s '^i3_' <<< "$xprop_root" ) ]];then version=$( get_program_version 'i3' '^i3' '3' ) desktop_environment='i3' - elif [[ -n $( grep -is 'WINDOWMAKER' <<< "$xprop_root" ) ]];then + elif [[ -z ${xprop_root/*windowmaker*/} ]];then version=$( get_program_version 'wmaker' '^Window[[:space:]]*Maker' 'NF' ) if [[ -n $version ]];then version="$version " fi desktop_environment="WindowMaker" - elif [[ -n $( grep -is '^_WM2' <<< "$xprop_root" ) ]];then + # need to check starts line because it's so short + elif [[ -n $( grep -s '^_wm2' <<< "$xprop_root" ) ]];then # note; there isn't actually a wm2 version available but error handling should cover it and return null # maybe one day they will add it? version=$( get_program_version 'wm2' '^wm2' 'NF' ) @@ -4743,7 +5647,7 @@ get_desktop_environment() version="$version " fi desktop_environment="WM2" - elif [[ -n $( grep -is 'herbstluftwm' <<< "$xprop_root" ) ]];then + elif [[ -z "${xprop_root/*herbstluftwm*/}" ]];then version=$( get_program_version 'herbstluftwm' '^herbstluftwm' 'NF' ) if [[ -n $version ]];then version="$version " @@ -4752,41 +5656,48 @@ get_desktop_environment() fi fi # a few manual hacks for things that don't id with xprop, these are just good guesses - # note that gawk is going to exit after first occurance of search string, so no need for extra + # note that gawk is going to exit after first occurrence of search string, so no need for extra + # http://www.xwinman.org/ for more possible wm if [[ -z $desktop_environment ]];then - if [[ -n $( grep -is 'fvwm-crystal' <<< "$Ps_aux_Data" ) ]];then + if [[ -z "${Ps_aux_Data/*fvwm-crystal*/}" ]];then version=$( get_program_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM-Crystal' - elif [[ -n $( grep -is 'fvwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*fvwm*/}" ]];then version=$( get_program_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM' - elif [[ -n $( grep -is 'pekwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*pekwm*/}" ]];then version=$( get_program_version 'pekwm' '^pekwm' '3' ) desktop_environment='pekwm' - elif [[ -n $( grep -is 'awesome' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*awesome*/}" ]];then version=$( get_program_version 'awesome' '^awesome' '2' ) desktop_environment='Awesome' - elif [[ -n $( grep -is 'scrotwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*scrotwm*/}" ]];then version=$( get_program_version 'scrotwm' '^welcome.*scrotwm' '4' ) desktop_environment='Scrotwm' # no --version for this one - elif [[ -n $( grep -is 'spectrwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*spectrwm*/}" ]];then version=$( get_program_version 'spectrwm' '^spectrwm.*welcome.*spectrwm' '5' ) desktop_environment='Spectrwm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)twm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( grep -Es '([[:space:]]|/)twm' <<< "$Ps_aux_Data" ) ]];then desktop_environment='Twm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( grep -Es '([[:space:]]|/)dwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_program_version 'dwm' '^dwm' '1' ) desktop_environment='dwm' - elif [[ -n $( grep -is 'wmii2' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*wmii2*/}" ]];then version=$( get_program_version 'wmii2' '^wmii2' '1' ) desktop_environment='wmii2' # note: in debian at least, wmii is actuall wmii3 - elif [[ -n $( grep -is 'wmii' <<< "$Ps_aux_Data" ) ]];then + elif [[ -z "${Ps_aux_Data/*wmii*/}" ]];then version=$( get_program_version 'wmii' '^wmii' '1' ) desktop_environment='wmii' - elif [[ -n $( grep -Eis '([[:space:]]|/)jwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( grep -Es '([[:space:]]|/)jwm' <<< "$Ps_aux_Data" ) ]];then version=$( get_program_version 'jwm' '^jwm' '2' ) desktop_environment='JWM' + elif [[ -z "${Ps_aux_Data/*sawfish*/}" ]];then + version=$( get_program_version 'sawfish' '^sawfish' '3' ) + desktop_environment='Sawfish' + elif [[ -z "${Ps_aux_Data/*afterstep*/}" ]];then + version=$( get_program_version 'afterstep' '^afterstep' '3' ) + desktop_environment='AfterStep' fi fi fi @@ -4794,6 +5705,7 @@ get_desktop_environment() if [[ -n $version ]];then version=" $version" fi + log_function_data "desktop_environment version: $desktop_environment$version" echo "$desktop_environment$version" eval $LOGFE } @@ -4806,7 +5718,8 @@ get_program_version() # mate-about -v = MATE Desktop Environment 1.4.0 case $1 in - dwm|jwm|mate-about|wmii|wmii2) + # legacy fluxbox had no --version, and current -v works + dwm|fluxbox|jwm|mate-about|wmii|wmii2) get_version='-v' ;; epoch) @@ -4832,7 +5745,7 @@ get_program_version() version_data="$( $1 $get_version 2>/dev/null )" ;; esac - + log_function_data "version data: $version_data" if [[ -n $version_data ]];then version=$( gawk ' BEGIN { @@ -4846,6 +5759,7 @@ get_program_version() exit # quit after first match prints }' <<< "$version_data" ) fi + log_function_data "program version: $version" echo $version } @@ -4858,7 +5772,7 @@ get_desktop_extra_data() desktops="" separator="" } - /(gnome-shell|gnome-panel|kicker|lxpanel|mate-panel|plasma-desktop|xfce4-panel)$/ { + /(gnome-shell|gnome-panel|kicker|lxpanel|mate-panel|plasma-desktop|plasma-netbook|xfce4-panel)$/ { # only one entry per type, can be multiple if ( desktops !~ $NF ) { desktops = desktops separator $NF @@ -4869,6 +5783,7 @@ get_desktop_extra_data() print desktops } ' ) + log_function_data "de_data: $de_data" echo $de_data eval $LOGFE @@ -4939,11 +5854,207 @@ get_de_gtk_data() fi fi fi + log_function_data "toolkit: $toolkit" echo $toolkit eval $LOGFE } +get_device_data() +{ + eval $LOGFS + + local device='un-determined' + local chasis_id='' dmi_device='' + + # first: linked version + if [[ -e /sys/class/dmi/id/chassis_type ]];then + chasis_id=$(cat /sys/class/dmi/id/chassis_type) + elif [[ -e /sys/devices/virtual/dmi/id/chassis_type ]];then + chasis_id=$(cat /sys/devices/virtual/dmi/id/chassis_type) + fi + # src: http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf + # https://www.404techsupport.com/2012/03/pizza-box-lunch-box-and-other-pc-case-form-factors-identified-by-wmi/ + if [[ $chasis_id != '' ]];then + case $chasis_id in + 1) + device=$(get_device_vm) + ;; + 2) + device='unknown' + ;; + # note: 13 is all-in-one which we take as a mac type system + 3|4|6|7|13|15|24) + device='desktop' + ;; + # 5 - pizza box was a 1 U desktop enclosure, but some old laptops also id this way + 5) + device='pizza-box' + ;; + # note: lenovo T420 shows as 10, notebook, but it's not a notebook + 9|10|16) + device='laptop' + ;; + 14) + device='notebook' + ;; + 8|11) + device='portable' + ;; + 17|23|25) + device='server' + ;; + 27|28|29) + device='blade' + ;; + 12) + device='docking-station' + ;; + 18) + device='expansion-chassis' + ;; + 19) + device='sub-chassis' + ;; + 20) + device='bus-expansion' + ;; + 21) + device='peripheral' + ;; + 22) + device='RAID' + ;; + 26) + device='compact-PCI' + ;; + esac + else + if ! type -p dmidecode &>/dev/null;then + device='dmidecode-missing' + elif [[ $B_ROOT == 'false' ]];then + device='dmidecode-use-root' + else + get_dmidecode_data + if [[ -n $DMIDECODE_DATA ]];then + if [[ $DMIDECODE_DATA == 'dmidecode-error-'* ]];then + device='dmidecode-no-info' + else + dmi_device=$( gawk ' + BEGIN { + IGNORECASE=1 + device="test" + } + /^Chassis Information/ { + device= $1 + while (getline && !/^$/ ) { + if ( $1 ~ /^Type/ ) { + sub(/Type:\s*/,"",$0) + device = $0 + break + } + } + } + END { + print device + }' <<< "$DMIDECODE_DATA" ) + if [[ -n $dmi_device ]];then + device=$dmi_device + fi + if [[ $device == 'Other' ]];then + device=$(get_device_vm) + fi + fi + fi + fi + fi + echo $device + + eval $LOGFE +} + +get_device_vm() +{ + eval $LOGFS + + local vm='other-vm?' vm_data='' vm_test='' + + # https://www.freedesktop.org/software/systemd/man/systemd-detect-virt.html + # note: returns bosh for qemu-kvm so if that's the result, let the other tests + # run + if type -p systemd-detect-virt &>/dev/null;then + vm_test=$(systemd-detect-virt 2>/dev/null | sed 's/none//' ) + if [[ -n $vm_test && $vm_test != 'none' ]];then + vm=$vm_test + fi + fi + # some simple to detect linux vm id's + if [[ $vm == 'other-vm?' || $vm == 'bochs' ]];then + if [[ -e /proc/vz ]];then + vm='openvz' + elif [[ -e /proc/xen ]];then + vm='xen' + elif [[ -e /dev/vzfs ]];then + vm='virtuozzo' + elif type -p lsmod &>/dev/null;then + vm_data="$( lsmod 2>/dev/null )" + if [[ -n $( grep -i 'kqemu' <<< "$vm_data" ) ]];then + vm='kqemu' + elif [[ -n $( grep -i 'kvm' <<< "$vm_data" ) ]];then + vm='kvm' + elif [[ -n $( grep -i 'qemu' <<< "$vm_data" ) ]];then + vm='qemu' + fi + vm_data='' + fi + 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 + if [[ -e /dev/disk/by-id ]];then + vm_data=$vm_data$(ls -l /dev/disk/by-id 2>/dev/null ) + fi + if [[ -n $( grep -iEs 'innotek|vbox|virtualbox' <<< $vm_data ) ]];then + vm='virtualbox' + elif [[ -n $( grep -is 'vmware' <<< $vm_data ) ]];then + vm='vmware' + elif [[ -n $( grep -is 'qemu' <<< $vm_data ) ]];then + vm='qemu-or-kvm' + elif [[ -n $( grep -s 'Virtual HD' <<< $vm_data ) ]];then + vm='hyper-v' + elif [[ -e /proc/cpuinfo && -n $( grep -is '^flags.*hypervisor' /proc/cpuinfo ) ]];then + vm='virtual-machine' + elif [[ -e /dev/vda || -e /dev/vdb || -e /dev/xvda || -e /dev/xvdb ]];then + vm='virtual-machine' + fi + fi + # this may catch some BSD and fringe Linux cases + if [[ $vm == 'other-vm?' && $B_ROOT == 'true' ]];then + if [[ -n $DMIDECODE_DATA && $DMIDECODE_DATA != 'dmidecode-error-'* ]];then + product_name=$(dmidecode -s system-product-name 2>/dev/null ) + system_manufacturer=$( dmidecode -s system-manufacturer 2>/dev/null ) + if [[ $product_name == 'VMware'* ]];then + vm='vmware' + elif [[ $product_name == 'VirtualBox'* ]];then + vm='virtualbox' + elif [[ $product_name == 'KVM'* ]];then + vm='kvm' + elif [[ $product_name == 'Bochs'* ]];then + vm='qemu' + elif [[ $system_manufacturer == 'Xen' ]];then + vm='xen' + elif [[ -n $( grep -i 'hypervisor' <<< "$DMIDECODE_DATA" ) ]];then + vm='virtual-machine' + fi + fi + fi + + echo $vm + + eval $LOGFE +} # see which dm has started if any get_display_manager() @@ -4959,8 +6070,11 @@ get_display_manager() for dm_id in $dm_id_list do # note: ${dm_id%.*}/$dm_id will create a dir name out of the dm id, then test if pid is in that - if [[ -f /run/$dm_id || -f /run/${dm_id%.*}/$dm_id || -f /var/run/$dm_id || \ - -f /var/run/${dm_id%.*}/$dm_id ]];then + # note: sddm, in an effort to be unique and special, do not use a pid/lock file, but rather a random + # string inside a directory called /run/sddm/ so assuming the existence of the pid inside a directory named + # from the dm. Hopefully this change will not have negative results. + if [[ -f /run/$dm_id || -d /run/${dm_id%.*}/ || -f /var/run/$dm_id || \ + -d /var/run/${dm_id%.*}/ ]];then # just on the off chance that two dms are running, good info to have in that case, if possible dm=$dm$separator${dm_id%.*} separator=',' @@ -4969,7 +6083,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 @@ -4985,7 +6099,7 @@ get_display_manager() get_distro_data() { eval $LOGFS - local i='' j='' distro='' distro_file='' a_distro_glob='' a_temp='' + local i='' j='' distro='' distro_file='' a_distro_glob='' a_temp='' b_osr='false' # may need modification if archbsd / debian can be id'ed with /etc files if [[ -n $BSD_TYPE ]];then @@ -5016,7 +6130,7 @@ get_distro_data() shopt -u nullglob a_temp=${a_distro_glob[@]} - log_function_data "A_GLX_DATA: $a_temp" + log_function_data "a_distro_glob: $a_temp" if [[ ${#a_distro_glob[@]} -eq 1 ]];then distro_file="$a_distro_glob" @@ -5058,22 +6172,26 @@ get_distro_data() distro=$( get_distro_lsb_os_release_data 'lsb-file' ) elif [[ $distro_file == 'os-release' ]];then distro=$( get_distro_lsb_os_release_data 'os-release-file' ) + b_osr='true' # then if the distro id file was found and it's not in the exluded primary distro file list, read it elif [[ -n $distro_file && -s /etc/$distro_file && " $DISTROS_EXCLUDE_LIST " != *" $distro_file "* ]];then # new opensuse uses os-release, but older ones may have a similar syntax, so just use the first line if [[ $distro_file == 'SuSE-release' ]];then # leaving off extra data since all new suse have it, in os-release, this file has line breaks, like os-release # but in case we want it, it's: CODENAME = Mantis | VERSION = 12.2 - # for now, just take first occurance, which should be the first line, which does not use a variable type format + # for now, just take first occurrence, which should be the first line, which does not use a variable type format distro=$( grep -i -m 1 'suse' /etc/$distro_file ) else distro=$( remove_erroneous_chars "/etc/$distro_file" ) fi # otherwise try the default debian/ubuntu /etc/issue file elif [[ -f /etc/issue ]];then - # lsb gives more manageable and accurate output than issue, but mint should use issue for now + # os-release/lsb gives more manageable and accurate output than issue, but mint should use issue for now # some bashism, boolean must be in parenthesis to work correctly, ie [[ $(boolean) ]] not [[ $boolean ]] - if [[ $B_LSB_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then + if [[ $B_OS_RELEASE_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then + distro=$( get_distro_lsb_os_release_data 'os-release-file' ) + b_osr='true' + elif [[ $B_LSB_FILE == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then distro=$( get_distro_lsb_os_release_data 'lsb-file' ) else distro=$( gawk ' @@ -5082,7 +6200,7 @@ get_distro_data() } { gsub(/\\[a-z]/, "") - gsub(/,/, " ") + gsub(/'"$BAN_LIST_ARRAY"'/, " ") gsub(/^ +| +$/, "") gsub(/ [ \t]+/, " ") print @@ -5096,20 +6214,28 @@ get_distro_data() fi fi fi - + # a final check. If a long value, before assigning the debugger output, if os-release + # exists then let's use that if it wasn't tried already. Maybe that will be better. if [[ ${#distro} -gt 80 ]] && [[ $B_HANDLE_CORRUPT_DATA != 'true' ]];then - distro="${RED}/etc/$distro_file corrupted, use -% to override${NORMAL}" + if [[ $B_OS_RELEASE_FILE == 'true' && $b_osr == 'false' ]];then + distro=$( get_distro_lsb_os_release_data 'os-release-file' ) + fi + if [[ ${#distro} -gt 80 ]];then + distro="${RED}/etc/$distro_file corrupted, use -% to override${NORMAL}" + fi fi ## note: would like to actually understand the method even if it's not used # : ${distro:=Unknown distro o_O} ## test for /etc/lsb-release as a backup in case of failure, in cases where > one version/release file ## were found but the above resulted in null distro value - if [[ -z $distro ]] && [[ $B_LSB_FILE == 'true' ]];then - distro=$( get_distro_lsb_os_release_data 'lsb-file' ) - fi + # Because os-release is now more common, we'll test for it first. if [[ -z $distro ]] && [[ $B_OS_RELEASE_FILE == 'true' ]];then distro=$( get_distro_lsb_os_release_data 'os-release-file' ) fi + if [[ -z $distro ]] && [[ $B_LSB_FILE == 'true' ]];then + distro=$( get_distro_lsb_os_release_data 'lsb-file' ) + fi + # now some final null tries if [[ -z $distro ]];then # if the file was null but present, which can happen in some cases, then use the file name itself to @@ -5243,7 +6369,7 @@ get_distro_lsb_os_release_data() } # note: adding the spacing directly to variable to make sure distro output is null if not found /^PRETTY_NAME/ { - if ( $2 != "n/a" ) { + if ( $2 != "n/a" ) { prettyName = $2 } } @@ -5261,7 +6387,8 @@ get_distro_lsb_os_release_data() } } END { - if ( prettyName != "" ) { + # NOTE: tumbleweed has pretty name but pretty name does not have version id + if ( prettyName != "" && regularName !~ /tumbleweed/ ) { distroName = prettyName } else if ( regularName != "" ) { @@ -5309,7 +6436,7 @@ get_dmidecode_data() fi # these tests first, because bsd error messages like this (note how many : are in the string) # inxi: line 4928: /usr/local/sbin/dmidecode: Permission denied - if [[ ${#dmiData} -lt 100 ]];then + if [[ ${#dmiData} -lt 200 ]];then if [[ -z ${dmiData/*Permission denied*/} ]];then # if [[ -n $( grep -i 'Permission denied' <<< "$dmiData" ) ]];then DMIDECODE_DATA='dmidecode-error-requires-root' @@ -5342,7 +6469,7 @@ get_dmidecode_data() cutExtraTab="true" } gsub(/'"$BAN_LIST_NORMAL"'/, "", twoData) - gsub(/,/, " ", twoData) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", twoData) # clean out Handle line # sub(/^Handle.*/,"", $0) sub(/^[[:space:]]*Inactive.*/,"",twoData) @@ -5353,9 +6480,9 @@ get_dmidecode_data() # To Be Filled By O.E.M. # strip out starting white space so that the following stuff will clear properly sub(/^[[:space:]]+/, "", twoData) - sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*|^0x[0]+$|\[Empty\]||^\.\.$/, "", twoData) + sub(/^Base Board .*|^Chassis .*|empty|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*|^0x[0]+$|\[Empty\]||Default string|^\.\.$/, "", twoData) sub(/.*(AssetTagNum|Manufacturer| Or Motherboard|PartNum.*|SerNum).*/, "", twoData) - gsub(/bios|acpi/, "", twoData) + gsub(/\ybios\y|\yacpi\y/, "", twoData) # note: biostar sub(/http:\/\/www.abit.com.tw\//, "Abit", twoData) # for double indented values replace with ~ so later can test for it, we are trusting that @@ -5413,14 +6540,14 @@ get_dmesg_boot_data() dmsg_boot_data="$( cat $FILE_DMESG_BOOT 2>/dev/null | gawk ' { sub(/[[:space:]]*=[[:space:]]*|:[[:space:]]*/,":", $0) - gsub(/,/," ", $0) + gsub(/'"$BAN_LIST_ARRAY"'/," ", $0) gsub(/\"/, "", $0) gsub(/[[:space:]][[:space:]]/, " ", $0) 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 } @@ -5582,6 +6709,8 @@ get_graphics_card_data() IGNORECASE=1 busId="" trueCard="" + card="" + driver="" } # not using 3D controller yet, needs research: |3D controller |display controller # note: this is strange, but all of these can be either a separate or the same @@ -5589,16 +6718,27 @@ get_graphics_card_data() # cards are either the same or different. We want only the .0 version as a valid # card. .1 would be for example: Display Adapter with bus id x:xx.1, not the right one /vga compatible controller|3D controller|Display controller/ { + driver="" gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF) - gsub(/,/, " ", $NF) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF) + if ( '$COLS_INNER' < 100 ){ + sub(/Core Processor Family/,"Core", $NF) + } gsub(/^ +| +$/, "", $NF) gsub(/ [ \t]+/, " ", $NF) - busId=gensub(/^([0-9a-f:\.]+) (.+)$/,"\\1","",$1) - trueCard=gensub(/(.*)\.([0-9]+)$/,"\\2","",busId) - if ( trueCard == 0 ) { - print $NF "," busId + card=$NF + busId=gensub(/^([0-9a-f:\.]+) (.+)$/,"\\1",1,$1) + trueCard=gensub(/(.*)\.([0-9]+)$/,"\\2",1,busId) + while ( getline && !/^$/) { + if ( $1 ~ /Kernel driver in use/ ){ + driver=$2 + } } - }' <<< "$Lspci_v_Data" ) ) + if ( trueCard == 0 ) { + print card "," busId "," driver + # print card "," busId "," driver > "/dev/tty" + } + }' <<< "$LSPCI_V_DATA" ) ) IFS="$ORIGINAL_IFS" # for (( i=0; i < ${#A_GRAPHICS_CARD_DATA[@]}; i++ )) # do @@ -5606,7 +6746,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 1 cases of detections I guess + # if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + if [[ $B_SHOW_DISPLAY_DATA == 'true' ]];then + IFS='^' + # NOTE: glxinfo -B is not always available, unforunately + A_GLX_DATA=( $( eval glxinfo $DISPLAY_OPT 2>/dev/null | gawk -F ': ' ' + # handle > 1 cases of detections function join( arr, sep ) { s="" i=flag=0 @@ -5703,6 +6842,12 @@ get_graphics_glx_data() BEGIN { IGNORECASE=1 + compatVersion="" + # create empty arrays + split("", a) + split("", b) + split("", c) + split("", d) } /opengl renderer/ { gsub(/'"$BAN_LIST_NORMAL"'/, "", $2) @@ -5725,16 +6870,37 @@ get_graphics_glx_data() # /opengl version/ && ( f || $2 !~ /mesa/ ) { /opengl version/ { # fglrx started appearing with this extra string, does not appear to communicate anything of value - sub(/Compatibility Profile Context/, "- CPC", $2 ) + sub(/(Compatibility Profile Context|\(Compatibility Profile\))/, "", $2 ) gsub(/ [ \t]+/, " ", $2) # get rid of the created white spaces gsub(/^ +| +$/, "", $2) $2 && b[$2] + # note: this is going to be off if ever multi opengl versions appear, never seen one + compatVersion=gensub(/^([^ \t]+)[ \t].*/,"\\1","g",$2) + } + /opengl core profile version/ { + gsub(/'"$BAN_LIST_NORMAL"'/, "", $2) + # fglrx started appearing with this extra string, does not appear to communicate anything of value + sub(/(Core Profile Context|\(Core Profile\))/, "", $2 ) + gsub(/ [ \t]+/, " ", $2) # get rid of the created white spaces + gsub(/^ +| +$/, "", $2) + $2 && d[$2] } /direct rendering/ { $2 && c[$2] } + # if -B was always available, we could skip this, but it is not + /GLX Visuals/ { + exit + } END { - printf( "%s\n%s\n%s\n", join( a, ", " ), join( b, ", " ), join( c, ", " ) ) + dr = join( c, ", " ) + oglr = join( a, ", " ) + oglv = join( b, ", " ) + oglcpv = join( d, ", " ) + # output processing done in print functions, important! do not use \n IFS + # because Bash treats an empty value surrounded by \n\n as nothing, not an empty array key! + # this came up re oglcpv being empty and compatVersion being used instead + printf( "%s^%s^%s^%s^%s", oglr, oglv, dr, oglcpv, compatVersion ) }' ) ) IFS="$ORIGINAL_IFS" @@ -5747,20 +6913,22 @@ get_graphics_glx_data() } ## return screen resolution / tty resolution +## args: $1 - reg/tty get_graphics_res_data() { eval $LOGFS - local screen_resolution='' xdpy_data='' screens_count=0 tty_session='' - - if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + local screen_resolution='' xdpy_data='' screens_count=0 tty_session='' option=$1 + + # if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + if [[ $B_SHOW_DISPLAY_DATA == 'true' && $option != 'tty' ]];then # Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in # 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0 - xdpy_data="$( xdpyinfo )" + xdpy_data="$( xdpyinfo $DISPLAY_OPT 2>/dev/null )" xdpy_count=$( grep -c 'dimensions' <<< "$xdpy_data" ) # we get a bit more info from xrandr than xdpyinfo, but xrandr fails to handle # multiple screens from different video cards if [[ $xdpy_count -eq 1 ]];then - screen_resolution=$( xrandr | gawk ' + screen_resolution=$( xrandr $DISPLAY_OPT 2>/dev/null | gawk ' /\*/ { res[++m] = gensub(/^.* ([0-9]+) ?x ?([0-9]+)[_ ].* ([0-9\.]+)\*.*$/,"\\1x\\2@\\3hz","g",$0) } @@ -5796,6 +6964,16 @@ get_graphics_res_data() screen_resolution=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{ print $2"x"$1 }' ) + # really old systems may not support the above method + if [[ -z $screen_resolution ]];then + screen_resolution=$( stty -a | gawk -F ';' ' + /^speed/ { + gsub(/[[:space:]]*(rows|columns)[[:space:]]*/,"",$0) + gsub(/[[:space:]]*/,"",$2) + gsub(/[[:space:]]*/,"",$3) + print $3"x"$2 + }' ) + fi # note: this works fine for all systems but keeping the above for now since # the above is probably more accurate for linux systems. else @@ -5825,16 +7003,28 @@ get_graphics_res_data() get_graphics_display_server_data() { eval $LOGFS - local vendor='' version='' a_temp='' xdpy_info='' a_display_vendor_working='' - - if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + local vendor='' vendor_version='' a_temp='' xdpy_info='' a_display_vendor_working='' + # note: this may not always be set, it won't be out of X, for example + local server="$XDG_SESSION_TYPE" compositor='' compositor_version='' + + if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then + compositor="$(get_graphics_display_compositor)" compositor_version='' + fi + + if [[ $server == '' ]];then + if [[ -n "$WAYLAND_DISPLAY" ]];then + server='wayland' + fi + fi + # if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + if [[ $B_SHOW_DISPLAY_DATA == 'true' ]];then # X vendor and version detection. # new method added since radeon and X.org and the disappearance of version : ...etc # Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2 # A failover mechanism is in place. (if $version is empty, the release number is parsed instead) # xdpy_info="$( xdpyinfo )" IFS="," - a_display_vendor_working=( $( xdpyinfo | gawk -F': +' ' + a_display_vendor_working=( $( xdpyinfo $DISPLAY_OPT 2>/dev/null | gawk -F': +' ' BEGIN { IGNORECASE=1 vendorString="" @@ -5842,8 +7032,8 @@ get_graphics_display_server_data() vendorRelease="" } /vendor string/ { - gsub(/the|inc|foundation|project|corporation/, "", $2) - gsub(/,/, " ", $2) + gsub(/\ythe\y|\yinc\y|foundation|project|corporation/, "", $2) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $2) gsub(/^ +| +$/, "", $2) gsub(/ [ \t]+/, " ", $2) vendorString = $2 @@ -5856,19 +7046,22 @@ get_graphics_display_server_data() gsub(/0+/, ".", $2) vendorRelease = $2 } + /(supported pixmap|keycode range|number of extensions|^screen)/ { + exit # we are done with the info we want, no reason to read the rest + } END { print vendorString "," version "," vendorRelease }' ) ) vendor=${a_display_vendor_working[0]} - version=${a_display_vendor_working[1]} + vendor_version=${a_display_vendor_working[1]} # this gives better output than the failure last case, which would only show: # for example: X.org: 1.9 instead of: X.org: 1.9.0 - if [[ -z $version ]];then - version=$( get_graphics_display_server_version ) + if [[ -z $vendor_version ]];then + vendor_version=$( get_graphics_display_x_version ) fi - if [[ -z $version ]];then - version=${a_display_vendor_working[2]} + if [[ -z $vendor_version ]];then + vendor_version=${a_display_vendor_working[2]} fi # some distros, like fedora, report themselves as the xorg vendor, so quick check @@ -5878,22 +7071,88 @@ get_graphics_display_server_data() fi IFS="$ORIGINAL_IFS" A_DISPLAY_SERVER_DATA[0]="$vendor" - A_DISPLAY_SERVER_DATA[1]="$version" + A_DISPLAY_SERVER_DATA[1]="$vendor_version" + A_DISPLAY_SERVER_DATA[2]="$server" + A_DISPLAY_SERVER_DATA[3]="$compositor" + A_DISPLAY_SERVER_DATA[4]="$compositor_version" else - version=$( get_graphics_display_server_version ) - if [[ -n $version ]];then + vendor_version=$( get_graphics_display_x_version ) + if [[ -n $vendor_version ]];then vendor='X.org' A_DISPLAY_SERVER_DATA[0]="$vendor" - A_DISPLAY_SERVER_DATA[1]="$version" + A_DISPLAY_SERVER_DATA[1]="$vendor_version" + A_DISPLAY_SERVER_DATA[2]="$server" + A_DISPLAY_SERVER_DATA[3]="$compositor" + A_DISPLAY_SERVER_DATA[4]="$compositor_version" fi fi a_temp=${A_DISPLAY_SERVER_DATA[@]} log_function_data "A_DISPLAY_SERVER_DATA: $a_temp" eval $LOGFE } +get_graphics_display_compositor() +{ + eval $LOGFS + local compositor='' + + if [[ -z "${Ps_aux_Data/*mutter*/}" ]];then + compositor='mutter' + elif [[ -z "${Ps_aux_Data/*gnome-shell*/}" ]];then + compositor='gnome-shell' + elif [[ -z "${Ps_aux_Data/*kwin*/}" ]];then + compositor='kwin' + elif [[ -z "${Ps_aux_Data/*moblin*/}" ]];then + compositor='moblin' + elif [[ -z "${Ps_aux_Data/*kmscon*/}" ]];then + compositor='kmscon' + elif [[ -z "${Ps_aux_Data/*sway*/}" ]];then + compositor='sway' + elif [[ -z "${Ps_aux_Data/*grefson*/}" ]];then + compositor='grefson' + elif [[ -z "${Ps_aux_Data/*westford*/}" ]];then + compositor='westford' + elif [[ -z "${Ps_aux_Data/*rustland*/}" ]];then + compositor='rustland' + elif [[ -z "${Ps_aux_Data/*fireplace*/}" ]];then + compositor='fireplace' + elif [[ -z "${Ps_aux_Data/*wayhouse*/}" ]];then + compositor='wayhouse' + elif [[ -z "${Ps_aux_Data/*weston*/}" ]];then + compositor='weston' + elif [[ -z "${Ps_aux_Data/*compton*/}" ]];then + compositor='compton' + elif [[ -z "${Ps_aux_Data/*compiz*/}" ]];then + compositor='compiz' + elif [[ -z "${Ps_aux_Data/*swc*/}" ]];then + compositor='swc' + elif [[ -z "${Ps_aux_Data/*dwc*/}" ]];then + compositor='dwc' + fi + + log_function_data "compositor: $compositor" + echo $compositor + eval $LOGFE +} +# $1 - compositor +get_graphics_display_wayland_version() +{ + eval $LOGFS + + local version='' + + case $1 in + mutter) + : + ;; + esac + log_function_data "version: $version" + echo $version + + eval $LOGFE +} # if other tests fail, try this one, this works for root, out of X also -get_graphics_display_server_version() +get_graphics_display_x_version() { eval $LOGFS local version='' x_data='' @@ -5984,6 +7243,7 @@ get_hdd_data_basic() fi # echo ss: $swap_size hdd_data="$( eval $df_string )" + # eval $df_string | awk 'BEGIN{tot=0} !/total/ {tot+=$4} END{print tot}' log_function_data 'raw' "hdd_data:\n$hdd_data" hdd_used=$( echo "$hdd_data" | gawk -v bsdType="$BSD_TYPE" -v swapSize="$swap_size" ' @@ -6007,7 +7267,7 @@ get_hdd_data_basic() # note that linux 3.2.45-grsec-9th types kernels have this type of partition name: /dev/xvdc (no number, letter) # note: btrfs does not seem to use partition integers, just the primary /dev/sdx identifier # df can also show /dev/disk/(by-label|by-uuid etc) - /^\/dev\/(disk\/|mapper\/|[hsv]d[a-z][0-9]*|dm[-]?[0-9]+|ada[0-9]+p[0-9]+.*|(ad|sd|wd)[0-9]+[a-z]|md[0-9]+|[aw]d[0-9]+s.*|xvd[a-z])|^ROOT/ { + /^\/dev\/(disk\/|mapper\/|[hsv]d[a-z]+[0-9]*|dm[-]?[0-9]+|(ada|mmcblk|nvme[0-9]+n)[0-9]+p[0-9]+.*|(ad|sd|wd)[0-9]+[a-z]|md[0-9]+|[aw]d[0-9]+s.*|xvd[a-z]+)|^ROOT/ { # this handles the case where the first item is too long # and makes df wrap output to next line, so here we advance # it to the next line for that single case. Using df -P should @@ -6066,9 +7326,9 @@ get_hdd_data_basic() if [[ $B_PARTITIONS_FILE == 'true' ]];then A_HDD_DATA=( $( gawk -v hddUsed=$hdd_used ' - /[hsv]d[a-z]$/ { + /([hsv]d[a-z]+|(ada|mmcblk|nvme[0-9]+n)[0-9]+)$/ { driveSize = $(NF - 1)*1024/1000**3 - gsub(/,/, " ", driveSize) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", driveSize) gsub(/^ +| +$/, "", driveSize) printf( $NF",%.1fGB,,\n", driveSize ) } @@ -6078,7 +7338,7 @@ get_hdd_data_basic() # } # special case from this data: 8 0 156290904 sda # note: vm has 252/253/254 known starter, grsec has 202 - $1 ~ /^(3|8|22|33|202|252|253|254)$/ && $NF ~ /[hsv]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { + $1 ~ /^(3|8|22|33|202|252|253|254)$/ && $NF ~ /[hsv]d[a-z]+$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { size += $3 } END { @@ -6173,7 +7433,7 @@ get_hard_drive_data_advanced() #c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i] ) # the vendor: string is useless, and is a bug, ATA is not a vendor for example c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/, "\\2", "g", a[i] ) - gsub(/,/, " ", c) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", c) gsub(/^ +| +$/, "", c) gsub(/ [ \t]+/, " ", c) #print a[i] @@ -6288,7 +7548,7 @@ get_hard_drive_data_bsd() local a_temp='' - if [[ -n $Dmesg_Boot_Data ]];then + if [[ -n $DMESG_BOOT_DATA ]];then IFS=$'\n' A_HDD_DATA=( $( gawk -v hddUsed="$1" -F ':' ' BEGIN { @@ -6296,9 +7556,8 @@ get_hard_drive_data_bsd() size=0 bSetSize="false" } - - $1 ~ /^(ad|ada|sd|wd)[0-9]+(|[[:space:]]at.*)$/ { - diskId=gensub(/^((ad|ada|sd|wd)[0-9]+)[^0-9].*/,"\\1",1,$1) + $1 ~ /^(ad|ada|mmcblk|nvme[0-9]+n|sd|wd)[0-9]+(|[[:space:]]at.*)$/ { + diskId=gensub(/^((ad|ada|mmcblk|nvme[0-9]+n|sd|wd)[0-9]+)[^0-9].*/,"\\1",1,$1) # note: /var/run/dmesg.boot may repeat items since it is not created # fresh every boot, this way, only the last items will be used per disk id if (aIds[diskId] == "" ) { @@ -6375,7 +7634,7 @@ get_hard_drive_data_bsd() else { print "NA,-,,.." # print an empty array, this will be further handled in the print out function } - }' <<< "$Dmesg_Boot_Data" ) ) + }' <<< "$DMESG_BOOT_DATA" ) ) IFS="$ORIGINAL_IFS" fi @@ -6415,7 +7674,7 @@ get_hdd_temp_data() { eval $LOGFS local hdd_temp='' sudo_command='' - + if [[ $B_HDDTEMP_TESTED != 'true' ]];then B_HDDTEMP_TESTED='true' HDDTEMP_PATH=$( type -p hddtemp ) @@ -6539,6 +7798,24 @@ get_init_data() eval $LOGFE } +# note: useless because this is just absurdly inaccurate, too bad... +get_install_date() +{ + eval $LOGFS + + local installed='' + + if ls -al --time-style '+FORMAT %Y-%m-%d' /usr 2>/dev/null;then + installed=$(ls -al --time-style '+FORMAT %Y-%m-%d' / | awk '/lost\+found/ {print $7;exit}' ) +# elif +# : + fi + + echo $installed + + eval $LOGFE +} + get_kernel_compiler_version() { # note that we use gawk to get the last part because beta, alpha, git versions can be non-numeric @@ -6600,7 +7877,7 @@ get_kernel_version() fi log_function_data "kernel_version: $kernel_version - ksplice_kernel_version: $ksplice_kernel_version" - echo $kernel_version + CURRENT_KERNEL=$kernel_version eval $LOGFE } @@ -6618,9 +7895,12 @@ get_lspci_data() print }' )" fi - - echo "$lspci_data" log_function_data 'raw' "lspci_data $1:\n$lspci_data" + if [[ $1 == 'v' ]];then + LSPCI_V_DATA="$lspci_data" + elif [[ $1 == 'n' ]];then + LSPCI_N_DATA="$lspci_data" + fi eval $LOGFE } @@ -6636,7 +7916,7 @@ get_lspci_chip_id() if ( $3 != "" ) { print $3 } - }' <<< "$Lspci_n_Data" ) + }' <<< "$LSPCI_N_DATA" ) echo $chip_id @@ -6647,7 +7927,7 @@ get_machine_data() { eval $LOGFS local a_temp='' separator='' id_file='' file_data='' array_string='' - local id_dir='/sys/class/dmi/id/' dmi_data='' + local id_dir='/sys/class/dmi/id/' dmi_data='' firmware_type='BIOS' local machine_files=" sys_vendor product_name product_version product_serial product_uuid board_vendor board_name board_version board_serial @@ -6659,6 +7939,11 @@ get_machine_data() " fi if [[ -d $id_dir && $B_FORCE_DMIDECODE == 'false' ]];then + if [[ -d /sys/firmware/efi ]];then + firmware_type='UEFI' + elif [[ -n $(ls /sys/firmware/acpi/tables/UEFI* 2>/dev/null ) ]];then + firmware_type='UEFI [Legacy]' + fi for id_file in $machine_files do file_data='' @@ -6669,14 +7954,14 @@ get_machine_data() } { gsub(/'"$BAN_LIST_NORMAL"'/, "", $0) - gsub(/,/, " ", $0) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0) # yes, there is a typo in a user data set, unknow # Base Board Version|Base Board Serial Number # Chassis Manufacturer|Chassis Version|Chassis Serial Number # System manufacturer|System Product Name|System Version # To Be Filled By O.E.M. - sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|none|^To be filled.*/, "", $0) - gsub(/bios|acpi/, "", $0) + sub(/^Base Board .*|^Chassis .*|.*O\.E\.M\..*|.*OEM.*|^Not .*|^System .*|.*unknow.*|.*N\/A.*|Default string|none|^To be filled.*/, "", $0) + gsub(/\ybios\y|\yacpi\y/, "", $0) # note: biostar sub(/http:\/\/www.abit.com.tw\//, "Abit", $0) gsub(/^ +| +$/, "", $0) gsub(/ [ \t]+/, " ", $0) @@ -6686,6 +7971,15 @@ get_machine_data() array_string="$array_string$separator$file_data" separator=',' done + if [[ $array_string != '' ]];then + # note: dmidecode has two more data types possible, so always add 2 more + if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then + array_string="$array_string,," + else + array_string="$array_string,,,,,," + fi + array_string="$array_string,$firmware_type" + fi else get_dmidecode_data if [[ -n $DMIDECODE_DATA ]];then @@ -6700,15 +7994,16 @@ get_machine_data() baseboardProductName="" baseboardSerialNumber="" baseboardVersion="" - biosReleaseDate="" - biosRevision="" # only available from dmidecode - biosRomSize="" # only available from dmidecode - biosVendor="" - biosVersion="" chassisManufacturer="" chassisSerialNumber="" chassisType="" chassisVersion="" + firmwareReleaseDate="" + firmwareRevision="" # only available from dmidecode + firmwareRomSize="" # only available from dmidecode + firmwareType="BIOS" + firmwareVendor="" + firmwareVersion="" systemManufacturer="" systemProductName="" systemVersion="" @@ -6724,13 +8019,14 @@ get_machine_data() } /^Bios Information/ { while ( getline && !/^$/ ) { - if ( $1 ~ /^Release Date/ ) { biosReleaseDate=$2 } - if ( $1 ~ /^BIOS Revision/ ) { biosRevision=$2 } - if ( $1 ~ /^ROM Size/ ) { biosRomSize=$2 } - if ( $1 ~ /^Vendor/ ) { biosVendor=$2 } - if ( $1 ~ /^Version/ ) { biosVersion=$2 } + if ( $1 ~ /^Release Date/ ) { firmwareReleaseDate=$2 } + if ( $1 ~ /^BIOS Revision/ ) { firmwareRevision=$2 } + if ( $1 ~ /^ROM Size/ ) { firmwareRomSize=$2 } + if ( $1 ~ /^Vendor/ ) { firmwareVendor=$2 } + if ( $1 ~ /^Version/ ) { firmwareVersion=$2 } + if ( $1 ~ /^UEFI is supported/ ) { firmwareType="UEFI" } } - testString=biosReleaseDate biosRevision biosRomSize biosVendor biosVersion + testString=firmwareReleaseDate firmwareRevision firmwareRomSize firmwareVendor firmwareVersion if ( testString != "" ) { bItemFound="true" } @@ -6785,10 +8081,10 @@ get_machine_data() if ( bItemFound == "true" ) { fullString = systemManufacturer "," systemProductName "," systemVersion "," systemSerialNumber fullString = fullString "," systemUuid "," baseboardManufacturer "," baseboardProductName - fullString = fullString "," baseboardVersion "," baseboardSerialNumber "," biosVendor - fullString = fullString "," biosVersion "," biosReleaseDate "," chassisManufacturer + fullString = fullString "," baseboardVersion "," baseboardSerialNumber "," firmwareVendor + fullString = fullString "," firmwareVersion "," firmwareReleaseDate "," chassisManufacturer fullString = fullString "," chassisType "," chassisVersion "," chassisSerialNumber - fullString = fullString "," biosRevision "," biosRomSize + fullString = fullString "," firmwareRevision "," firmwareRomSize "," firmwareType print fullString } @@ -6801,8 +8097,8 @@ get_machine_data() A_MACHINE_DATA=( $array_string ) IFS="$ORIGINAL_IFS" # echo ${A_MACHINE_DATA[5]} - a_temp=( ${A_MACHINE_DATA[@]} ) - # echo ${#a_temp[@]} + a_temp=${A_MACHINE_DATA[@]} + # echo $a_temp log_function_data "A_MACHINE_DATA: $a_temp" eval $LOGFE } @@ -6825,7 +8121,7 @@ get_memory_data() printf("%.1f/%.1fMB\n", used/1024, tot/1024) }' $FILE_MEMINFO ) log_function_data 'cat' "$FILE_MEMINFO" - elif [[ $B_SYSCTL == 'true' && -n $Sysctl_a_Data ]];then + elif [[ $B_SYSCTL == 'true' && -n $SYSCTL_A_DATA ]];then local gawk_fs=': ' # darwin sysctl is broken and uses both : and = and repeats these items if [[ $BSD_VERSION == 'openbsd' ]];then @@ -6876,7 +8172,7 @@ get_memory_data() }' ) fi # for dragonfly, we will use free mem, not used because free is 0 - memory=$( grep -i 'mem' <<< "$Sysctl_a_Data" | gawk -v usedMemory="$used_memory" -F "$gawk_fs" ' + memory=$( grep -i 'mem' <<< "$SYSCTL_A_DATA" | gawk -v usedMemory="$used_memory" -F "$gawk_fs" ' BEGIN { realMemory="" freeMemory="" @@ -6924,8 +8220,8 @@ get_memory_data() } }' ) fi - echo "$memory" log_function_data "memory: $memory" + MEMORY="$memory" eval $LOGFE } @@ -6946,7 +8242,7 @@ get_module_version_number() IGNORECASE=1 } /^version/ { - gsub(/,/, " ", $2) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $2) gsub(/^ +| +$/, "", $2) gsub(/ [ \t]+/, " ", $2) print $2 @@ -6969,7 +8265,7 @@ get_networking_data() IFS=$'\n' A_NETWORK_DATA=( $( - echo "$Lspci_v_Data" | gawk ' + echo "$LSPCI_V_DATA" | gawk ' # NOTE: see version 2.1.28 or earlier for old logic if for some reason it is needed again # that used a modified string made from nic name for index, why, I have no idea, makes no sense and leads # to wrong ordered output as well. get_audio_data uses the old logic for now too. @@ -6983,12 +8279,15 @@ get_networking_data() #gsub(/davicom semiconductor/, "Davicom", aNic[counter]) # The doublequotes are necessary because of the pipes in the variable. gsub(/'"$BAN_LIST_NORMAL"'/, "", aNic[counter]) - gsub(/,/, " ", aNic[counter]) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", aNic[counter]) + if ( '$COLS_INNER' < 100 ){ + sub(/PCI Express/,"PCIE", aNic[counter]) + } gsub(/^ +| +$/, "", aNic[counter]) gsub(/ [ \t]+/, " ", aNic[counter]) aPciBusId[counter] = gensub(/(^[0-9a-f:\.]+) [^:]+: .+$/,"\\1","g",$0) while ( getline && !/^$/ ) { - gsub(/,/, "", $0) + gsub(/'"$BAN_LIST_ARRAY"'/, "", $0) if ( /^[[:space:]]*I\/O/ ) { aPorts[counter] = aPorts[counter] $4 " " } @@ -7253,7 +8552,7 @@ get_networking_usb_data() } /'"$USB_NETWORK_SEARCH"'/ && !/bluetooth| hub|keyboard|mouse|printer| ps2|reader|scan|storage/ { string="" - gsub( /,/, " ", $0 ) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 ) gsub(/'"$BAN_LIST_NORMAL"'/, "", $0) gsub(/ [ \t]+/, " ", $0) #sub(/realtek semiconductor/, "Realtek", $0) @@ -7290,36 +8589,51 @@ get_networking_usb_data() get_networking_wan_ip_data() { eval $LOGFS - local ip='' ip_data='' downloader_error=0 - + local ip='' ip_data='' downloader_error=0 ua='' b_ipv4_good=true no_check_ssl='' + # get ip using wget redirect to stdout. This is a clean, text only IP output url, # single line only, ending in the ip address. May have to modify this in the future # to handle ipv4 and ipv6 addresses but should not be necessary. # awk has bad regex handling so checking it with grep -E instead # ip=$( echo 2001:0db8:85a3:0000:0000:8a2e:0370:7334 | gawk --re-interval ' # ip=$( wget -q -O - $WAN_IP_URL | gawk --re-interval ' - case $DOWNLOADER in - curl) - ip_data="$( curl -y $DL_TIMEOUT -s $WAN_IP_URL )" || downloader_error=$? - ;; - fetch) - ip_data="$( fetch -T $DL_TIMEOUT -q -o - $WAN_IP_URL )" || downloader_error=$? - ;; - ftp) - ip_data="$( ftp -o - $WAN_IP_URL 2>/dev/null )" || downloader_error=$? - ;; - wget) - ip_data="$( wget -T $DL_TIMEOUT -q -O - $WAN_IP_URL )" || downloader_error=$? - ;; - no-downloader) - downloader_error=1 - ;; - esac - ip=$( gawk --re-interval ' - { - #gsub("\n","",$2") - print $NF - }' <<< "$ip_data" ) + # this generates a direct dns based ipv4 ip address, but if opendns.com goes down, the fall + # note: consistently slower than domain based: dig +short +time=1 +tries=1 myip.opendns.com. A @208.67.222.222 + # backs will still work. + if [[ -n $DNSTOOL ]];then + ip=$( dig +short +time=1 +tries=1 myip.opendns.com @resolver1.opendns.com 2>/dev/null) + fi + if [[ $ip == '' ]];then + case $DOWNLOADER in + curl) + if [[ -n $( grep 'smxi.org' <<< $WAN_IP_URL ) ]];then + ua="-A s-tools/inxi-ip" + fi + ip_data="$( curl $NO_SSL_OPT $ua -y $DL_TIMEOUT -s $WAN_IP_URL )" || downloader_error=$? + ;; + fetch) + ip_data="$( fetch $NO_SSL_OPT -T $DL_TIMEOUT -q -o - $WAN_IP_URL )" || downloader_error=$? + ;; + ftp) + ip_data="$( ftp $NO_SSL_OPT -o - $WAN_IP_URL 2>/dev/null )" || downloader_error=$? + ;; + wget) + if [[ -n $( grep 'smxi.org' <<< $WAN_IP_URL ) ]];then + ua="-U s-tools/inxi-ip" + fi + ip_data="$( wget $NO_SSL_OPT $ua -T $DL_TIMEOUT -q -O - $WAN_IP_URL )" || downloader_error=$? + ;; + no-downloader) + downloader_error=1 + ;; + esac + ip=$( gawk --re-interval ' + { + #gsub("\n","",$2") + print $NF + }' <<< "$ip_data" ) + fi + # validate the data if [[ -z $ip ]];then ip='None Detected!' @@ -7361,15 +8675,18 @@ get_networking_local_ip_data() fi fi if [[ -z $ip_tool_command ]];then - A_INTERFACES_DATA=( "Interfaces program 'ip' missing. Please check: $SCRIPT_NAME --recommends" ) + A_INTERFACES_DATA=( "Interfaces program 'ip' missing. Please check: $SELF_NAME --recommends" ) elif [[ -n "$ip_tool_data" ]];then IFS=$'\n' # $ip_tool_command A_INTERFACES_DATA=( $( gawk -v ipTool=$ip_tool -v bsdType=$BSD_TYPE ' BEGIN { IGNORECASE=1 + addExtV6 = "" + addIpV6 = "" interface="" - ifIp="" + ipExtV6="" + ifIpV4="" ifIpV6="" ifMask="" } @@ -7382,55 +8699,116 @@ get_networking_local_ip_data() /^[a-zA-Z]+[0-9]/ { # not clear on why inet is coming through, but this gets rid of it # as first line item. - gsub(/,/, " ", $0) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0) gsub(/^ +| +$/, "", $0) gsub(/ [ \t]+/, " ", $0) interface = $1 - # prep this this for ip addr: eth0: - sub(/:/, "", interface) - ifIp="" + # prep this this for ip addr: eth0: but NOT eth0:1 + sub(/:$/, "", interface) + ifIpV4="" ifIpV6="" ifMask="" + ipExtV6="" aInterfaces[interface]++ - + while (getline && !/^$/ ) { + addIpV6 = "" + addExtV6 = "" if ( ipTool == "ifconfig" ) { if (/inet addr:/) { - ifIp = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 ) + ifIpV4 = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 ) if (/mask:/) { ifMask = gensub( /mask:([0-9\.]+)/, "\\1", "g", $NF ) } } if (/inet6 addr:/) { - ifIpV6 = $3 + # ^fe80: + if ( $2 ~ /^fe80/) { + addIpV6 = $2 + } + else if ( $0 ~ // || $0 ~ /Scope:Global/ ) { + addExtV6 = "sg~" $2 + } + # ^fec0: + else if ( $0 ~ // || $0 ~ /Scope:Site/ || $2 ~ /^fec0/ || $2 ~ /^fc00/) { + addExtV6 = "ss~" $2 + } + else { + addExtV6 = "su~" $2 + } } if ( bsdType == "bsd" ) { if ( $1 == "inet" ) { - ifIp = $2 + ifIpV4 = $2 if ( $3 == "netmask" ) { ifMask = $4 } } - if ( $0 ~ /inet6.*%/ ) { + # bsds end ip with %em1 (% + interface name) + if ( $0 ~ /inet6.*%/ ){ sub(/%.*/,"",$2) - ifIpV6 = $2 + if ( $2 ~ /^fe80/ ) { + addIpV6 = $2 + } + else if ( $2 ~ /^fec0/ || $2 ~ /^fc00/ ) { + addExtV6 = "ss~" $2 + } + else { + addExtV6 = "sg~" $2 + } } } } else if ( ipTool == "ip" ) { if ( $1 == "inet" ) { - ifIp = $2 + ifIpV4 = $2 } - if ( $1 == "inet6" ) { - ifIpV6 = $2 + if ( $1 == "inet6" ){ + # filter out deprecated IPv6 privacy addresses + if ( $0 ~ / temporary deprecated/) { + addExtV6 = "" + } + else if ( $0 ~ /scope global temporary/) { + addExtV6 = "st~" $2 + } + else if ( $0 ~ /scope global/) { + addExtV6 = "sg~" $2 + } + # ^fe80: + else if ( $2 ~ /^fe80/ || $0 ~ /scope link/) { + addIpV6 = $2 + } + # ^fec0: + else if ( $2 ~ /^fec0/ || $2 ~ /^fc00/ || $0 ~ /scope site/) { + addExtV6 = "ss~" $2 + } + else { + addExtV6 = "su~" $2 + } + } + } + if ( addIpV6 != "" ) { + if ( ifIpV6 == "" ) { + ifIpV6 = addIpV6 + } + else { + ifIpV6 = ifIpV6 "^" addIpV6 + } + } + if (addExtV6 != "" ){ + if ( ipExtV6 == "" ){ + ipExtV6 = addExtV6 + } + else { + ipExtV6 = ipExtV6 "^" addExtV6 } } } # slice off the digits that are sometimes tacked to the end of the address, # like: /64 or /24 - sub(/\/[0-9]+/, "", ifIp) - sub(/\/[0-9]+/, "", ifIpV6) - ipAddresses[interface] = ifIp "," ifMask "," ifIpV6 + sub(/\/[0-9]+/, "", ifIpV4) + gsub(/\/[0-9]+/, "", ifIpV6) # + ipAddresses[interface] = ifIpV4 "," ifMask "," ifIpV6 "," ipExtV6 } END { j=0 @@ -7459,7 +8837,6 @@ get_networking_local_ip_data() } # get_networking_local_ip_data;exit -# get_networking_local_ip_data;exit get_optical_drive_data() { eval $LOGFS @@ -7467,7 +8844,7 @@ get_optical_drive_data() local a_temp='' sys_uevent_path='' proc_cdrom='' link_list='' local separator='' linked='' working_disk='' disk='' item_string='' proc_info_string='' local dev_disks_full='' - dev_disks_full="$( ls /dev/dvd* /dev/cd* /dev/scd* /dev/sr* 2>/dev/null | grep -vE 'random' )" + dev_disks_full="$( ls /dev/dvd* /dev/cd* /dev/scd* /dev/sr* /dev/fd[0-9] 2>/dev/null | grep -vE 'random' )" ## Not using this now because newer kernel is NOT linking all optical drives. Some, but not all # Some systems don't support xargs -L plus the unlinked optical drive unit make this not a good option # get the actual disk dev location, first try default which is easier to run, need to preserve line breaks @@ -7566,7 +8943,7 @@ get_optical_drive_data() { gsub(/'"$BAN_LIST_NORMAL"'/, "", $0) sub(/TSSTcorp/, "TSST ", $0) # seen more than one of these weird ones - gsub(/,/, " ", $0) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0) gsub(/^[[:space:]]*|[[:space:]]*$/, "", $0) gsub(/ [[:space:]]+/, " ", $0) print $0 @@ -7648,7 +9025,7 @@ get_optical_drive_data_bsd() local a_temp='' - if [[ -n $Dmesg_Boot_Data ]];then + if [[ -n $DMESG_BOOT_DATA ]];then IFS=$'\n' A_OPTICAL_DRIVE_DATA=( $( gawk -F ':' ' BEGIN { @@ -7696,7 +9073,7 @@ get_optical_drive_data_bsd() for ( key in aIds ) { print aDisks[aIds[key], "id"] ",,," aDisks[aIds[key], "model"] "," aDisks[aIds[key], "rev"] "," aDisks[aIds[key], "speed"] ",,,,,,,," } - }' <<< "$Dmesg_Boot_Data" ) ) + }' <<< "$DMESG_BOOT_DATA" ) ) IFS="$ORIGINAL_IFS" fi @@ -7711,7 +9088,7 @@ get_partition_data() { eval $LOGFS - local a_partition_working='' dev_item='' a_temp='' dev_working_item='' + local a_part_working='' dev_item='' a_temp='' dev_working_item='' local swap_data='' df_string='' main_partition_data='' fs_type='' local mount_data='' dev_bsd_item='' #local excluded_file_types='--exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660' @@ -7732,6 +9109,7 @@ get_partition_data() df_string='df -h' fi fi + main_partition_data="$( eval $df_string )" # set dev disk label/mapper/uuid data globals get_partition_dev_data 'label' @@ -7746,9 +9124,9 @@ get_partition_data() if [[ $( grep -cs '[[:space:]]/$' <<< "$main_partition_data" ) -gt 1 ]];then main_partition_data="$( grep -vs '^rootfs' <<< "$main_partition_data" )" fi + # echo "$main_partition_data" log_function_data 'raw' "main_partition_data_post_rootfs:\n$main_partition_data\n\nswap_data:\n$swap_data" IFS=$'\n' - # sample line: /dev/sda2 ext3 15G 8.9G 4.9G 65% /home # $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used ## note: by subtracting from the last field number NF, we avoid a subtle issue with LVM df output, where if ## the first field is too long, it will occupy its own line, this way we are getting only the needed data @@ -7762,8 +9140,9 @@ get_partition_data() # skipping these file systems because bsds do not support df --exclude-type= # note that using $1 to handle older bsd df, which do not support -T. This will not be reliable but we will see ( bsdType != "" ) { - # skip if non disk/partition, or if raid primary id, which will not have a / in it - if ( $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|iso9660|linprocfs|procfs|squashfs|sysfs|tmpfs|type|unionfs)$/ || + # skip if non disk/partition, or if raid primary id, which will not have a / in it. + # Note: kfreebsd uses /sys, not sysfs, is this a bug or expected behavior? + if ( $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|iso9660|linprocfs|procfs|squashfs|\/sys|sysfs|tmpfs|type|unionfs)$/ || ( $1 ~ /^([^\/]+)$/ && $1 !~ /^ROOT/ ) ) { # note use next, not getline or it does not work right next @@ -7791,7 +9170,7 @@ get_partition_data() } # this handles yet another fredforfaen special case where a mounted drive # has the search string in its name - $NF ~ /^\/$|^\/boot$|^\/var$|^\/home$|^\/tmp$|^\/usr$/ { + $NF ~ /^\/$|^\/boot$|^\/var$|^\/var\/tmp$|^\/var\/log$|^\/home$|^\/opt$|^\/tmp$|^\/usr$/ { # note, older df in bsd do not have file system column if ( NF == "7" && $(NF - 1) ~ /[0-9]+%/ ) { fileSystem=$(NF - 5) @@ -7809,7 +9188,7 @@ get_partition_data() } # skip all these, including the first, header line. Use the --exclude-type # to handle new filesystems types we do not want listed here - $NF !~ /^\/$|^\/boot$|^\/var$|^\/home$|^\/tmp$|^\/usr$|^filesystem/ { + $NF !~ /^\/$|^\/boot$|^\/var$|^\/var\/tmp$|^\/var\/log$|^\/home$|^\/opt$|^\/tmp$|^\/usr$|^filesystem/ { # this is to avoid file systems with spaces in their names, that will make # the test show the wrong data in each of the fields, if no x%, then do not use # using 3 cases, first default, standard, 2nd, 3rd, handles one and two spaces in name @@ -7849,7 +9228,6 @@ get_partition_data() print $(NF - 2) " " $(NF - 1) " " $NF "," $(NF - 6) "," $(NF - 5) "," $(NF - 3) ",secondary," fileSystem "," devBase } }' ) - # now add the swap partition data, don't want to show swap files, just partitions, # though this can include /dev/ramzswap0. Note: you can also use /proc/swaps for this # data, it's the same exact output as swapon -s @@ -7891,11 +9269,11 @@ get_partition_data() for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do IFS="," - a_partition_working=( ${A_PARTITION_DATA[i]} ) + a_part_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" - dev_item=${a_partition_working[6]} # reset each loop - fs_type=${a_partition_working[5]} + dev_item=${a_part_working[6]} # reset each loop + fs_type=${a_part_working[5]} # older bsds have df minus -T so can't get fs type easily, try using mount instead if [[ $BSD_TYPE == 'bsd' ]] && [[ -z $fs_type && -n $dev_item ]];then dev_bsd_item=$( sed -e 's/non-dev-//' -e 's|/|\\/|g' <<< "$dev_item" ) @@ -7912,7 +9290,7 @@ get_partition_data() } else { # for openbsd: /dev/wd0f on /usr type ffs (local, nodev) - gsub( /^.*type[[:space:]]+|[[:space:]]*$/, "", $1 ) + gsub(/^.*type[[:space:]]+|[[:space:]]*$/, "", $1 ) fileSystem=$1 } print fileSystem @@ -7947,12 +9325,12 @@ get_partition_data() if [[ -n $dev_item ]];then # assemble everything we could get for dev/h/dx, label, and uuid IFS="," - A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","$fs_type","$dev_item + A_PARTITION_DATA[i]=${a_part_working[0]}","${a_part_working[1]}","${a_part_working[2]}","${a_part_working[3]}","${a_part_working[4]}","$fs_type","$dev_item IFS="$ORIGINAL_IFS" fi done a_temp=${A_PARTITION_DATA[@]} - # echo $a_temp + # echo $a_temp;exit log_function_data "2: A_PARTITION_DATA:\n$a_temp" if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then get_partition_data_advanced @@ -7964,7 +9342,7 @@ get_partition_data() get_partition_data_advanced() { eval $LOGFS - local a_partition_working='' dev_partition_data='' + local a_part_working='' dev_partition_data='' local dev_item='' dev_label='' dev_uuid='' a_temp='' local mount_point='' # set dev disk label/mapper/uuid data globals @@ -7976,13 +9354,13 @@ get_partition_data_advanced() for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do IFS="," - a_partition_working=( ${A_PARTITION_DATA[i]} ) + a_part_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" # note: for swap this will already be set - if [[ -z ${a_partition_working[6]} ]];then + if [[ -z ${a_part_working[6]} ]];then - mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} ) + mount_point=$( sed 's|/|\\/|g' <<< ${a_part_working[0]} ) #echo mount_point $mount_point dev_partition_data=$( gawk ' BEGIN { @@ -7991,7 +9369,7 @@ get_partition_data_advanced() partTemp = "" } # trying to handle space in name -# gsub( /\\040/, " ", $0 ) +# gsub(/\\040/, " ", $0 ) /[ \t]'$mount_point'[ \t]/ && $1 != "rootfs" { # initialize the variables label = "" @@ -8014,7 +9392,7 @@ get_partition_data_advanced() # if this works, great, otherwise, just set this to null values partTemp="'$( readlink /dev/root 2>/dev/null )'" if ( partTemp != "" ) { - if ( partTemp ~ /[hsv]d[a-z][0-9]{1,2}/ ) { + if ( partTemp ~ /[hsv]d[a-z]+[0-9]{1,2}/ ) { partition=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, partTemp ) } else if ( partTemp ~ /by-uuid/ ) { @@ -8038,21 +9416,21 @@ get_partition_data_advanced() # assemble everything we could get for dev/h/dx, label, and uuid IFS="," - A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","${a_partition_working[5]}","$dev_partition_data + A_PARTITION_DATA[i]=${a_part_working[0]}","${a_part_working[1]}","${a_part_working[2]}","${a_part_working[3]}","${a_part_working[4]}","${a_part_working[5]}","$dev_partition_data IFS="$ORIGINAL_IFS" fi ## now we're ready to proceed filling in the data IFS="," - a_partition_working=( ${A_PARTITION_DATA[i]} ) + a_part_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" # get the mapper actual dev item first, in case it's mapped - dev_item=$( get_dev_processed_item "${a_partition_working[6]}" ) + dev_item=$( get_dev_processed_item "${a_part_working[6]}" ) # make sure not to slice off rest if it's a network mounted file system if [[ -n $dev_item && -z $( grep -E '(^//|:/)' <<< $dev_item ) ]];then dev_item=${dev_item##*/} ## needed to avoid error in case name still has / in it fi - dev_label=${a_partition_working[7]} - dev_uuid=${a_partition_working[8]} + dev_label=${a_part_working[7]} + dev_uuid=${a_part_working[8]} # then if dev data/uuid is incomplete, try to get missing piece # it's more likely we'll get a uuid than a label. But this should get the # dev item set no matter what, so then we can get the rest of any missing data @@ -8068,7 +9446,7 @@ get_partition_data_advanced() elif [[ -n $DEV_DISK_LABEL && -n $dev_label ]];then dev_item=$( echo "$DEV_DISK_LABEL" | gawk ' # first we need to change space x20 in by-label back to a real space - #gsub( /x20/, " ", $0 ) + #gsub(/x20/, " ", $0 ) # then we can see if the string is there $0 ~ /[ \t]'$dev_label'[ \t]/ { item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF ) @@ -8098,7 +9476,7 @@ get_partition_data_advanced() # assemble everything we could get for dev/h/dx, label, and uuid IFS="," - A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","${a_partition_working[5]}","$dev_item","$dev_label","$dev_uuid + A_PARTITION_DATA[i]=${a_part_working[0]}","${a_part_working[1]}","${a_part_working[2]}","${a_part_working[3]}","${a_part_working[4]}","${a_part_working[5]}","$dev_item","$dev_label","$dev_uuid IFS="$ORIGINAL_IFS" done log_function_data 'cat' "$FILE_MOUNTS" @@ -8117,16 +9495,16 @@ get_partition_data_advanced_bsd() { eval $LOGFS local gpart_data="$( gpart list 2>/dev/null )" - local a_partition_working='' label_uuid='' dev_item='' + local a_part_working='' label_uuid='' dev_item='' if [[ -n $gpart_data ]];then for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do IFS="," - a_partition_working=( ${A_PARTITION_DATA[i]} ) + a_part_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" # no need to use the rest of the name if it's not a straight /dev/item - dev_item=${a_partition_working[6]##*/} + dev_item=${a_part_working[6]##*/} label_uuid=$( gawk -F ':' ' BEGIN { @@ -8151,7 +9529,7 @@ get_partition_data_advanced_bsd() # assemble everything we could get for dev/h/dx, label, and uuid IFS="," - A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","${a_partition_working[5]}","${a_partition_working[6]}","$label_uuid + A_PARTITION_DATA[i]=${a_part_working[0]}","${a_part_working[1]}","${a_part_working[2]}","${a_part_working[3]}","${a_part_working[4]}","${a_part_working[5]}","${a_part_working[6]}","$label_uuid IFS="$ORIGINAL_IFS" done fi @@ -8239,16 +9617,13 @@ get_dev_processed_item() get_patch_version_string() { - local patch_version_number=$( sed 's/^[0]*//' <<< $SCRIPT_PATCH_NUMBER ) + SELF_PATCH=${SELF_PATCH##*[0]} # strip leading zero(s) - if [[ -n $patch_version_number ]];then - patch_version_number="-$patch_version_number" + if [[ -n $SELF_PATCH ]];then + SELF_PATCH="-$SELF_PATCH" # for cases where it was for example: 00-bsd cleaned to --bsd trim out one - - if [[ -n $( grep '\--' <<< $patch_version_number ) ]];then - patch_version_number=$( sed 's/--/-/' <<< $patch_version_number ) - fi + SELF_PATCH="${SELF_PATCH/--/-}" fi - echo $patch_version_number } get_pciconf_data() @@ -8376,7 +9751,7 @@ get_pciconf_card_data() A_AUDIO_DATA[j]=$array_string ;; display) - array_string="$device_string,${a_temp[4]},${a_temp[5]}" + array_string="$device_string,${a_temp[4]},${a_temp[5]},${a_temp[3]}" A_GRAPHICS_CARD_DATA[j]=$array_string ;; network) @@ -8464,7 +9839,7 @@ get_ps_tcm_data() IFS=$'\n' # note that inxi can use a lot of cpu, and can actually show up here as the script runs - A_PS_DATA=( $( echo "$ps_data" | grep -Ev "($SCRIPT_NAME|%CPU|[[:space:]]ps[[:space:]])" | $head_tail -n $PS_COUNT | gawk ' + A_PS_DATA=( $( echo "$ps_data" | grep -Ev "($SELF_NAME|%CPU|[[:space:]]ps[[:space:]])" | $head_tail -n $PS_COUNT | gawk ' BEGIN { IGNORECASE=1 appName="" @@ -8547,7 +9922,6 @@ get_raid_data() IGNORECASE=1 RS="\n" } - /^personalities/ { KernelRaidSupport = gensub(/personalities[[:space:]]*:[[:space:]]*(.*)/, "\\1", 1, $0) # clean off the brackets @@ -8587,7 +9961,7 @@ get_raid_data() uData = "" while ( !/^[[:space:]]*$/ ) { - gsub(/,/, " ", $0 ) + gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 ) gsub(/[[:space:]]+/, " ", $0 ) if ( $0 ~ /^md/ ) { device = gensub(/(md.*)[[:space:]]?:/, "\\1", "1", $1 ) @@ -9392,7 +10766,7 @@ get_repo_data() local bsd_pkg_dir='/usr/local/etc/pkg/repos/' slackpkg_file='/etc/slackpkg/mirrors' local netbsd_file='/usr/pkg/etc/pkgin/repositories.conf' freebsd_file='/etc/freebsd-update.conf' local freebsd_pkg_file='/etc/pkg/FreeBSD.conf' slackpkg_plus_file='/etc/slackpkg/slackpkgplus.conf' - local portage_repo_dir='/etc/portage/repos.conf/' + local portage_repo_dir='/etc/portage/repos.conf/' apk_file='/etc/apk/repositories' # apt - debian, buntus, also sometimes some yum/rpm repos may create apt repos here as well if [[ -f $apt_file || -d $apt_file.d ]];then @@ -9457,7 +10831,7 @@ get_repo_data() urlData="" repoTitle="" } - gsub( /\[|\]/, "", $1 ) # strip out the brackets + gsub(/\[|\]/, "", $1 ) # strip out the brackets repoTitle = $1 " ~ " } /^(mirrorlist|baseurl)/ { @@ -9610,7 +10984,7 @@ get_repo_data() urlData="" repoTitle="" } - gsub( /\[|\]/, "", $1 ) # strip out the brackets + gsub(/\[|\]/, "", $1 ) # strip out the brackets repoTitle = $1 " ~ " } /^(sync-uri)/ { @@ -9717,6 +11091,21 @@ get_repo_data() done <<< "$REPO_DATA" # echo and execute the line breaks inserted REPO_DATA="$( echo -e $repo_data_working )" + # alpine linux + elif [[ -f $apk_file ]];then + # note, only one file, but loop it in case more are added in future + for repo_file in $apk_file + do + if [[ -n $1 ]];then + cat $repo_file &> $1/repo-data_${repo_file//\//-}.txt + fi + repo_data_working="$( gawk -v repoFile="$repo_file" ' + !/^[[:space:]]*$|^[[:space:]]*#/ { + print "APK repo^" repoFile "^" $0 + }' $repo_file )" + get_repo_builder "$repo_data_working" + done + repo_data_working='' elif [[ -f $ports_conf || -f $freebsd_file || -d $bsd_pkg_dir ]];then if [[ -f $ports_conf ]];then if [[ -n $1 ]];then @@ -9788,7 +11177,7 @@ get_repo_data() repoUrl="" enabled="" while ( getline && $0 !~ /^[[:space:]]*$/ ) { - gsub(/,/,"",$0) + gsub(/'"$BAN_LIST_ARRAY"'/,"",$0) gsub(/({|}|^[[:space:]]+|[[:space:]]+$)/,"",$1) gsub(/({|}|^[[:space:]]+|[[:space:]]+$)/,"",$2) if ( $1 == "url" ) { @@ -10398,8 +11787,10 @@ get_sysctl_data() sysctl_data="$( sysctl -$1 )" fi fi - # log_function_data "sysctl_data: $sysctl_data" - echo "$sysctl_data" + if [[ $1 == 'a' ]];then + SYSCTL_A_DATA="$sysctl_data" + fi + log_function_data "sysctl_data: $sysctl_data" eval $LOGFE } @@ -10451,8 +11842,8 @@ get_unmounted_partition_data() if [[ $B_RAID_SET != 'true' ]];then get_raid_data fi - # sr0 type cd drives are showing up now as unmounted partitions - mounted_partitions="scd[0-9]+|sr[0-9]+|cdrom[0-9]*|cdrw[0-9]*|dvd[0-9]*|dvdrw[0-9]*" + # sr0 type cd drives are showing up now as unmounted partitions. + mounted_partitions="scd[0-9]+|sr[0-9]+|cdrom[0-9]*|cdrw[0-9]*|dvd[0-9]*|dvdrw[0-9]*|fd[0-9]|ram[0-9]*" # create list for slicing out the mounted partitions for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do @@ -10460,7 +11851,8 @@ get_unmounted_partition_data() 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]}" + # escape '/' for remote mounts, the path would be: [domain|ip]:/path/in/remote + mounted_partitions="$mounted_partitions$separator${a_unmounted_working[6]//\//\\/}" fi done # now we need to exclude the mdraid partitions from the unmounted partition output as well @@ -10475,18 +11867,18 @@ get_unmounted_partition_data() mounted_partitions="$mounted_partitions$separator$raid_partitions" fi done - - A_UNMOUNTED_PARTITION_DATA=( $( grep -Ev '[[:space:]]('$mounted_partitions')$' $FILE_PARTITIONS | gawk ' + # grep -Ev '[[:space:]]('$mounted_partitions')$' $FILE_PARTITIONS | + A_UNMOUNTED_PARTITION_DATA=( $( gawk ' BEGIN { IGNORECASE=1 } # note that size 1 means it is a logical extended partition container # lvm might have dm-1 type syntax # need to exclude loop type file systems, squashfs for example - /[a-z][0-9]+$|dm-[0-9]+$/ && $3 != 1 && $NF !~ /loop/ { + /[a-z][0-9]+$|dm-[0-9]+$/ && $3 != 1 && $NF !~ /loop/ && $NF !~ /'$mounted_partitions'/ { size = sprintf( "%.2f", $3*1024/1000**3 ) print $4 "," size "G" - }' ) ) + }' $FILE_PARTITIONS ) ) for (( i=0; i < ${#A_UNMOUNTED_PARTITION_DATA[@]}; i++ )) do @@ -10561,8 +11953,8 @@ get_uptime() print a }' )" fi - echo "$uptime_value" log_function_data "uptime_value: $uptime_value" + UP_TIME="$uptime_value" eval $LOGFE } @@ -10590,16 +11982,16 @@ get_weather_data() if [[ $b_test_loc != 'true' ]];then case $DOWNLOADER in curl) - location_data="$( curl -y $DL_TIMEOUT -s $location_site )" || downloader_error=$? + location_data="$( curl $NO_SSL_OPT -y $DL_TIMEOUT -s $location_site )" || downloader_error=$? ;; fetch) - location_data="$( fetch -T $DL_TIMEOUT -q -o - $location_site )" || downloader_error=$? + location_data="$( fetch $NO_SSL_OPT -T $DL_TIMEOUT -q -o - $location_site )" || downloader_error=$? ;; ftp) - location_data="$( ftp -o - $location_site 2>/dev/null )" || downloader_error=$? + location_data="$( ftp $NO_SSL_OPT -o - $location_site 2>/dev/null )" || downloader_error=$? ;; wget) - location_data="$( wget -t 1 -T $DL_TIMEOUT -q -O - $location_site )" || downloader_error=$? + location_data="$( wget $NO_SSL_OPT -t 1 -T $DL_TIMEOUT -q -O - $location_site )" || downloader_error=$? ;; no-downloader) downloader_error=100 @@ -10727,16 +12119,16 @@ get_weather_data() if [[ $b_test_weather != 'true' ]];then case $DOWNLOADER in curl) - weather_data="$( curl -y $DL_TIMEOUT -s $weather_feed"$location" )" || downloader_error=$? + weather_data="$( curl $NO_SSL_OPT -y $DL_TIMEOUT -s $weather_feed"$location" )" || downloader_error=$? ;; fetch) - weather_data="$( fetch -T $DL_TIMEOUT -q -o - $weather_feed"$location" )" || downloader_error=$? + weather_data="$( fetch $NO_SSL_OPT -T $DL_TIMEOUT -q -o - $weather_feed"$location" )" || downloader_error=$? ;; ftp) - weather_data="$( ftp -o - $weather_feed"$location" 2>/dev/null )" || downloader_error=$? + weather_data="$( ftp $NO_SSL_OPT -o - $weather_feed"$location" 2>/dev/null )" || downloader_error=$? ;; wget) - weather_data="$( wget -t 1 -T $DL_TIMEOUT -q -O - $weather_feed"$location" )" || downloader_error=$? + weather_data="$( wget $NO_SSL_OPT -t 1 -T $DL_TIMEOUT -q -O - $weather_feed"$location" )" || downloader_error=$? ;; no-downloader) downloader_error=100 @@ -10901,8 +12293,9 @@ calculate_line_length() # ansi:  irc: \x0312 # note: using special trick for bsd sed, tr - NOTE irc sed must use " double quote string=$( sed -e 's/'$ESC'\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g' -e "s/\\\x0[0-9]\{1,3\}//g" <<< $string ) - count=${#string} - echo $count + #echo $string + LINE_LENGTH=${#string} + # echo ${#string} } ## multiply the core count by the data to be calculated, bmips, cache @@ -11004,21 +12397,18 @@ print_it_out() { eval $LOGFS # note that print_it_out passes local variable values on to its children, - # and in some cases, their children, with Lspci_v_Data - local Lspci_v_Data='' Lspci_n_Data='' # only for verbose - local Sysctl_a_Data='' Dmesg_Boot_Data='' + # and in some cases, their children, if variable syntax: Xxxx_Yyyy if [[ -n $BSD_TYPE ]];then - Sysctl_a_Data="$( get_sysctl_data 'a' )" - Dmesg_Boot_Data="$( get_dmesg_boot_data )" + get_sysctl_data 'a' # set: SYSCTL_A_DATA + get_dmesg_boot_data # set: DMESG_BOOT_DATA fi - if [[ $B_SHOW_SHORT_OUTPUT == 'true' ]];then print_short_data else - Lspci_v_Data="$( get_lspci_data 'v' )" + get_lspci_data 'v' # set: LSPCI_V_DATA if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then - Lspci_n_Data="$( get_lspci_data 'n' )" + get_lspci_data 'n' # set: LSPCI_N_DATA fi if [[ $B_SHOW_SYSTEM == 'true' ]];then print_system_data @@ -11026,6 +12416,9 @@ print_it_out() if [[ $B_SHOW_MACHINE == 'true' ]];then print_machine_data fi + if [[ $B_SHOW_BATTERY == 'true' ]];then + print_battery_data + fi if [[ $B_SHOW_BASIC_CPU == 'true' || $B_SHOW_CPU == 'true' ]];then print_cpu_data fi @@ -11083,15 +12476,19 @@ print_it_out() print_short_data() { eval $LOGFS - local current_kernel=$( get_kernel_version ) local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 )) local short_data='' i='' b_background_black='false' - local memory=$( get_memory_data ) - local up_time="$( get_uptime )" - if [[ -z $up_time ]];then - up_time='N/A - missing uptime?' + if [[ -z $UP_TIME ]];then + UP_TIME='N/A - missing uptime?' fi - + get_uptime + get_kernel_version + get_memory_data + get_patch_version_string + # load A_CPU_DATA + get_cpu_data + # load A_HDD_DATA + get_hdd_data_basic # set A_CPU_CORE_DATA get_cpu_core_count local cpc_plural='' cpu_count_print='' model_plural='' current_max_clock='' @@ -11105,13 +12502,11 @@ print_short_data() if [[ -z $BSD_TYPE || -n $cpu_type ]];then cpu_type=" ($cpu_type)" fi - if [[ $BSD_TYPE == 'bsd' ]];then kernel_os="${C1}OS${C2}$SEP1$( uname -rsp )" else - kernel_os="${C1}Kernel${C2}$SEP1$current_kernel" + kernel_os="${C1}Kernel${C2}$SEP1$CURRENT_KERNEL" fi - if [[ $cpu_physical_count -gt 1 ]];then cpc_plural='(s)' model_plural='s' @@ -11125,9 +12520,7 @@ print_short_data() cpu_data_string="$cpu_count_print$cpu_core_count core" fi # local cpu_core_count=${A_CPU_CORE_DATA[0]} - - # load A_HDD_DATA - get_hdd_data_basic + ## note: if hdd_model is declared prior to use, whatever string you want inserted will ## be inserted first. In this case, it's desirable to print out (x) before each disk found. local a_hdd_data_count=$(( ${#A_HDD_DATA[@]} - 1 )) @@ -11136,15 +12529,12 @@ print_short_data() IFS="$ORIGINAL_IFS" local hdd_capacity=${a_hdd_basic_working[0]} local hdd_used=${a_hdd_basic_working[1]} - - # load A_CPU_DATA - get_cpu_data - + IFS="," local a_cpu_working=(${A_CPU_DATA[0]}) # this gets that weird min/max final array item, which almost never contains any data of use local current_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 )) - local a_cpu_speeds=(${A_CPU_DATA[$current_max_clock_nu]}) + local a_cpu_info=(${A_CPU_DATA[$current_max_clock_nu]}) IFS="$ORIGINAL_IFS" local cpu_model="${a_cpu_working[0]}" ## assemble data for output @@ -11160,19 +12550,19 @@ print_short_data() # model from # index: 0 speed ; 1 min ; 2 max # this handles bsd types which always should show N/A unless we get a way to get min / max data - if [[ "${a_cpu_speeds[0]}" == 'N/A' && ${a_cpu_working[1]} != '' ]];then + if [[ "${a_cpu_info[0]}" == 'N/A' && ${a_cpu_working[1]} != '' ]];then current_max_clock="${a_cpu_working[1]} MHz" else - if [[ ${a_cpu_speeds[2]} != 0 ]];then - if [[ ${a_cpu_speeds[0]} == ${a_cpu_speeds[2]} ]];then - current_max_clock="${a_cpu_speeds[0]} MHz (max)" + if [[ ${a_cpu_info[2]} != 0 ]];then + if [[ ${a_cpu_info[0]} == ${a_cpu_info[2]} ]];then + current_max_clock="${a_cpu_info[0]} MHz (max)" else - current_max_clock="${a_cpu_speeds[0]}/${a_cpu_speeds[2]} MHz" + current_max_clock="${a_cpu_info[0]}/${a_cpu_info[2]} MHz" speed_starter='speed/max' fi fi fi - local patch_version_number=$( get_patch_version_string ) + #set_color_scheme 12 if [[ $B_IRC == 'true' ]];then @@ -11197,12 +12587,12 @@ print_short_data() #C1="${C1},1"; C2="${C2},1"; CN="${CN},1" fi fi - short_data="${C1}CPU$cpc_plural${C2}$SEP1$cpu_data_string $cpu_model$model_plural$cpu_type ${C1}$speed_starter${C2}$SEP1$current_max_clock$SEP2$kernel_os$SEP2${C1}Up${C2}$SEP1$up_time$SEP2${C1}Mem${C2}$SEP1$memory$SEP2${C1}HDD${C2}$SEP1$hdd_capacity($hdd_used)$SEP2${C1}Procs${C2}$SEP1$processes$SEP2" + short_data="${C1}CPU$cpc_plural${C2}$SEP1$cpu_data_string $cpu_model$model_plural$cpu_type ${C1}$speed_starter${C2}$SEP1$current_max_clock$SEP2$kernel_os$SEP2${C1}Up${C2}$SEP1$UP_TIME$SEP2${C1}Mem${C2}$SEP1$MEMORY$SEP2${C1}HDD${C2}$SEP1$hdd_capacity($hdd_used)$SEP2${C1}Procs${C2}$SEP1$processes$SEP2" if [[ $SHOW_IRC -gt 0 ]];then short_data="$short_data${C1}Client${C2}$SEP1$IRC_CLIENT$IRC_CLIENT_VERSION$SEP2" fi - short_data="$short_data${C1}$SCRIPT_NAME${C2}$SEP1$SCRIPT_VERSION_NUMBER$patch_version_number$SEP2${CN}" + short_data="$short_data${C1}$SELF_NAME${C2}$SEP1$SELF_VERSION$SELF_PATCH$SEP2${CN}" if [[ $SCHEME -gt 0 ]];then short_data="$short_data $NORMAL" fi @@ -11325,19 +12715,21 @@ print_audio_data() fi # only print alsa on last line if short enough, otherwise print on its own line if [[ $i -eq 0 ]];then - if [[ -n $alsa_data && $( calculate_line_length "$card_string$audio_data$alsa_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$card_string$audio_data$alsa_data" + if [[ -n $alsa_data && $LINE_LENGTH -lt $COLS_INNER ]];then audio_data="$audio_data$alsa_data" alsa_data='' fi fi if [[ -n $audio_data ]];then - if [[ $( calculate_line_length "$card_string$audio_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$card_string$audio_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then print_data=$( create_print_line "$line_starter" "$card_string$audio_data" ) print_screen_output "$print_data" # print the line else # keep the driver on the same line no matter what, looks weird alone on its own line - if [[ $( calculate_line_length "$card_string$audio_data" ) -gt $COLS_INNER ]];then + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then print_data=$( create_print_line "$line_starter" "$card_string" ) print_screen_output "$print_data" line_starter=' ' @@ -11353,7 +12745,8 @@ print_audio_data() done fi if [[ -n $alsa_data ]];then - if [[ $( calculate_line_length "${alsa_data/ALSA/Advanced Linux Sound Architecture}" ) -lt $COLS_INNER ]];then + calculate_line_length "${alsa_data/ALSA/Advanced Linux Sound Architecture}" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then # alsa_data=$( sed 's/ALSA/Advanced Linux Sound Architecture/' <<< $alsa_data ) alsa_data=${alsa_data/ALSA/Advanced Linux Sound Architecture} fi @@ -11363,17 +12756,201 @@ print_audio_data() eval $LOGFE } +print_battery_data() +{ + eval $LOGFS + local line_starter='Battery' print_data='' + get_battery_data + if [[ -n ${A_BATTERY_DATA[@]} ]];then + local battery_data='' battery_string='' + local present='' chemistry='' cycles='' voltage_min_design='' voltage_now='' + local power_now='' capacity='' capacity_level='' model='' company='' serial='' + local of_orig='' model='' condition='' power='' + + # echo ${A_BATTERY_DATA[@]} + for (( i=0; i< ${#A_BATTERY_DATA[@]}; i++ )) + do + battery_data='' + print_data='' + battery_string='' + charge='' + model='' + condition='' + voltage='' + name='' + status='' + present='' + chemistry='' + cycles='' + voltage_min_design='' + voltage_now='' + power_now='' + capacity='' + capacity_level='' + of_orig='' + model='' + company='' + serial='' + location='' # dmidecode only + IFS="," + a_battery_working=( ${A_BATTERY_DATA[i]} ) + IFS="$ORIGINAL_IFS" + bat_id="$(( $i + 1 ))" + + if [[ -n ${a_battery_working[10]} ]];then + charge="${a_battery_working[10]} Wh " + fi + if [[ -n ${a_battery_working[11]} ]];then + charge="$charge${a_battery_working[11]} " + fi + if [[ $charge == '' ]];then + charge='N/A ' + fi + charge="${C1}charge$SEP3${C2} $charge" + if [[ -n ${a_battery_working[9]} ]];then + condition="${a_battery_working[9]}" + else + condition='NA' + fi + if [[ -n ${a_battery_working[8]} ]];then + condition="$condition/${a_battery_working[8]} Wh " + else + condition="$condition/NA Wh " + fi + if [[ -n ${a_battery_working[13]} ]];then + condition="$condition(${a_battery_working[13]}) " + fi + if [[ $condition == '' ]];then + condition='N/A ' + fi + condition="${C1}condition$SEP3${C2} $condition" + if [[ $B_EXTRA_DATA == 'true' ]];then + if [[ -n ${a_battery_working[15]} ]];then + model="${a_battery_working[15]} " + fi + if [[ -n ${a_battery_working[14]} ]];then + model="$model${a_battery_working[14]} " + fi + if [[ $model == '' ]];then + model='N/A ' + fi + model="${C1}model$SEP3${C2} $model" + + if [[ -n ${a_battery_working[1]} ]];then + status="${a_battery_working[1]} " + else + status="N/A " + fi + status="${C1}status$SEP3${C2} $status" + fi + if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then + if [[ -n ${a_battery_working[16]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + serial=$FILTER_STRING + else + serial="${a_battery_working[16]} " + fi + else + serial='N/A ' + fi + serial="${C1}serial$SEP3${C2} $serial" + if [[ -n ${a_battery_working[6]} ]];then + voltage="${a_battery_working[6]}" + fi + if [[ -n ${a_battery_working[5]} ]];then + if [[ $voltage == '' ]];then + voltage='NA' + fi + voltage="$voltage/${a_battery_working[5]} " + fi + if [[ $voltage == '' ]];then + voltage='NA ' + fi + voltage="${C1}volts$SEP3${C2} $voltage" + fi + if [[ $B_EXTRA_EXTRA_EXTRA_DATA == 'true' ]];then + if [[ -n ${a_battery_working[3]} ]];then + chemistry="${a_battery_working[3]} " + fi + if [[ -n ${a_battery_working[4]} ]];then + cycles="${C1}cycles$SEP3${C2} ${a_battery_working[4]} " + fi + # location is dmidecode only + if [[ -n ${a_battery_working[17]} ]];then + location="${C1}loc$SEP3${C2} ${a_battery_working[17]} " + fi + fi + if [[ -n ${a_battery_working[15]} ]];then + battery_string="${C1}${a_battery_working[0]}$SEP3${C2} $charge$condition" + battery_data="$model$chemistry$serial$status$cycles$location" + fi + + if [[ ${A_BATTERY_DATA[0]} == 'dmidecode-error-'* ]];then + error_string=$( print_dmidecode_error 'bat' "${A_BATTERY_DATA[0]}" ) + battery_string=${C2}$error_string + battery_data='' + voltage='' + fi + + if [[ -n $battery_string ]];then + calculate_line_length "$battery_string$voltage$battery_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then + #echo one + print_data=$( create_print_line "$line_starter" "$battery_string$voltage$battery_data" ) + print_screen_output "$print_data" + # print the line + else + # keep the driver on the same line no matter what, looks weird alone on its own line + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + calculate_line_length "$battery_string$voltage" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + print_data=$( create_print_line "$line_starter" "$battery_string" ) + print_screen_output "$print_data" + line_starter=' ' + battery_string='' + print_data=$( create_print_line "$line_starter" "$voltage" ) + print_screen_output "$print_data" + voltage='' + else + print_data=$( create_print_line "$line_starter" "$battery_string$voltage" ) + print_screen_output "$print_data" + line_starter=' ' + voltage='' + battery_string='' + fi + #echo two + if [[ $battery_data != '' ]];then + print_data=$( create_print_line "$line_starter" "$battery_data" ) + print_screen_output "$print_data" + fi + else + #echo three + print_data=$( create_print_line "$line_starter" "$battery_string$voltage$battery_data" ) + print_screen_output "$print_data" + fi + fi + line_starter=' ' + fi + done + elif [[ $B_SHOW_BATTERY_FORCED == 'true' ]];then + print_data=$( create_print_line "$line_starter" "No battery data found in /sys or dmidecode. Is one present?" ) + print_screen_output "$print_data" + fi + eval $LOGFE +} + print_cpu_data() { eval $LOGFS - local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data='' a_cpu_speeds='' + local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data='' a_cpu_info='' local bmip_data='' cpu_cache='' cpu_vendor='' cpu_flags='' flag_feature='flags' local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error='' max_speed='' local cpc_plural='' cpu_count_print='' model_plural='' cpu_data_string='' local cpu_physical_count='' cpu_core_count='' cpu_core_alpha='' cpu_type='' local cpu_2_data='' working_cpu='' temp1='' per_cpu_cores='' current_max_clock_nu='' local line_starter="CPU:" multi_cpu_starter="${C1}clock speeds$SEP3${C2} " - local speed_starter='speed' + local speed_starter='speed' arch_data='' arm=' (ARM)' rev='' arch_cache='' cache_data='' + local flags_bmip='' ##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\"" # Array A_CPU_DATA always has one extra element: max clockfreq found. @@ -11384,9 +12961,26 @@ print_cpu_data() IFS="," a_cpu_working=(${A_CPU_DATA[0]}) current_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 )) - a_cpu_speeds=(${A_CPU_DATA[$current_max_clock_nu]}) + a_cpu_info=(${A_CPU_DATA[$current_max_clock_nu]}) IFS="$ORIGINAL_IFS" - + + if [[ $B_EXTRA_DATA == 'true' ]];then + if [[ ${a_cpu_info[3]} != '' ]];then + get_cpu_architecture "${a_cpu_info[3]}" "${a_cpu_info[4]}" "${a_cpu_info[5]}" + # note: arm model names usually say what revision it is + if [[ ${a_cpu_info[3]} != 'arm' && "${a_cpu_info[6]}" != '' ]];then + if [[ -n "${ARCH/*rev*/}" ]];then + rev=" rev.${a_cpu_info[6]}" + fi + fi + fi + if [[ $ARCH == '' ]];then + ARCH='N/A' + else + arm='' # note: to avoid redundant output, only show this without -x option + fi + arch_data="${C1}arch$SEP3${C2} $ARCH$rev " + fi # Strange (and also some expected) behavior encountered. If print_screen_output() uses $1 # as the parameter to output to the screen, then passing " ${ARR[@]} " # will output only and first element of ARR. That "@" splits in elements and "*" _doesn't_, @@ -11396,7 +12990,7 @@ print_cpu_data() ## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------" # unless all these are null, process whatever you have if [[ -n ${a_cpu_working[0]} || -n ${a_cpu_working[1]} || -n ${a_cpu_working[2]} || -n ${a_cpu_working[3]} ]];then - cpu_model="${a_cpu_working[0]}" + cpu_model="${a_cpu_working[0]}"; ## assemble data for output cpu_clock="${a_cpu_working[1]}" cpu_vendor=${a_cpu_working[5]} @@ -11415,7 +13009,7 @@ print_cpu_data() line_starter="CPU$cpc_plural:" if [[ -z $BSD_TYPE ]];then cpu_data_string="$cpu_count_print$cpu_core_alpha core" - cpu_data="${C1}$cpu_data_string${C2} ${a_cpu_working[0]}$model_plural ($cpu_type)" + cpu_data="${C1}$cpu_data_string${C2} $cpu_model$model_plural ($cpu_type) " else if [[ $cpu_physical_count -gt 1 ]];then per_cpu_cores=$(($cpu_core_count/$cpu_physical_count)) @@ -11426,7 +13020,7 @@ print_cpu_data() if [[ -n $cpu_type ]];then cpu_type=" ($cpu_type)" fi - cpu_data="$cpu_data_string${C1}model$SEP3${C2} ${a_cpu_working[0]}$cpu_type" + cpu_data="$cpu_data_string${C1}model$SEP3${C2} $cpu_model$cpu_type " fi if [[ $B_SHOW_CPU == 'true' ]];then # update for multicore, bogomips x core count. @@ -11450,6 +13044,7 @@ print_cpu_data() else bmip_data="${C1}bmips$SEP3${C2} $bmip_data " fi + fi ## note: this handles how intel reports L2, total instead of per core like AMD does # note that we need to multiply by number of actual cpus here to get true cache size @@ -11480,10 +13075,11 @@ print_cpu_data() fi # arm cpus do not have flags or cache if [[ ${a_cpu_working[6]} != 'true' ]];then - cpu_data="$cpu_data${C2} ${C1}cache$SEP3${C2} $cpu_cache" - cpu_2_data="$cpu_flags$bmip_data" + cpu_data="$cpu_data${C2}" + cache_data="${C1}cache$SEP3${C2} $cpu_cache " + flags_bmip="$cpu_flags$bmip_data" else - cpu_data="$cpu_data${C2} (ARM)$bmip_data" + cpu_data="$cpu_data${C2}$arm $bmip_data" fi fi # we don't this printing out extra line unless > 1 cpu core @@ -11492,30 +13088,36 @@ print_cpu_data() else if [[ -z ${a_cpu_working[1]} ]];then if [[ -z ${cpu_data/*ARM*/} ]];then - temp1=' (ARM)' + temp1="$arm" fi a_cpu_working[1]="N/A$temp1" else a_cpu_working[1]="${a_cpu_working[1]%.*} MHz" fi # this handles bsd case unless we get a way to get max/min cpu speeds - if [[ ${a_cpu_speeds[0]} != 'N/A' && ${a_cpu_speeds[2]} != 0 ]];then + if [[ ${a_cpu_info[0]} != 'N/A' && ${a_cpu_info[2]} != 0 ]];then if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${#A_CPU_DATA[@]} -eq 2 && - $B_SHOW_CPU == 'true' && ${a_cpu_speeds[1]} != 0 ]];then - a_cpu_working[1]="${a_cpu_speeds[0]}/${a_cpu_speeds[1]}/${a_cpu_speeds[2]} MHz" + $B_SHOW_CPU == 'true' && ${a_cpu_info[1]} != 0 ]];then + a_cpu_working[1]="${a_cpu_info[0]}/${a_cpu_info[1]}/${a_cpu_info[2]} MHz" speed_starter='speed/min/max' else - if [[ ${a_cpu_speeds[0]} == ${a_cpu_speeds[2]} ]];then - a_cpu_working[1]="${a_cpu_speeds[0]} MHz (max)" + if [[ ${a_cpu_info[0]} == ${a_cpu_info[2]} ]];then + a_cpu_working[1]="${a_cpu_info[0]} MHz (max)" else - a_cpu_working[1]="${a_cpu_speeds[0]}/${a_cpu_speeds[2]} MHz" + a_cpu_working[1]="${a_cpu_info[0]}/${a_cpu_info[2]} MHz" speed_starter='speed/max' fi fi fi cpu_clock_speed="${C1}$speed_starter$SEP3${C2} ${a_cpu_working[1]}" fi - cpu_2_data="$cpu_2_data$cpu_clock_speed" + if [[ $B_CPU_FLAGS_FULL == 'true' ]];then + cpu_2_data="" + arch_cache="$arch_data$cache_data$bmip_data" + else + cpu_2_data="$flags_bmip$cpu_clock_speed" + arch_cache="$arch_data$cache_data" + fi else if [[ $BSD_TYPE == 'bsd' && $B_ROOT != 'true' ]];then cpu_null_error=' No permissions for sysctl use?' @@ -11528,24 +13130,47 @@ print_cpu_data() # echo icols: $COLS_INNER # echo tc: $TERM_COLUMNS # echo :${cpu_2_data}: - if [[ -n $cpu_2_data && $( calculate_line_length "$cpu_data $cpu_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$cpu_data $arch_cache" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + #echo one cpu_data=$( create_print_line "$line_starter" "$cpu_data" ) - line_starter=' ' print_screen_output "$cpu_data" - cpu_data=$( create_print_line " " "$cpu_2_data" ) + cpu_data=$( create_print_line " " "$arch_cache" ) + print_screen_output "$cpu_data" + line_starter=' ' + cpu_data='' + arch_cache='' + fi + calculate_line_length "$cpu_data$arch_cache$cpu_2_data" + if [[ -n $cpu_2_data && $LINE_LENGTH -gt $COLS_INNER ]];then + #echo two + calculate_line_length "$cpu_data$arch_cache" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + cpu_data=$( create_print_line "$line_starter" "$cpu_data" ) + print_screen_output "$cpu_data" + else + cpu_data=$( create_print_line "$line_starter" "$cpu_data$arch_cache" ) + print_screen_output "$cpu_data" + arch_cache='' + fi + line_starter=' ' + cpu_data=$( create_print_line " " "$arch_cache$cpu_2_data" ) print_screen_output "$cpu_data" else - cpu_data=$( create_print_line "$line_starter" "$cpu_data" ) - print_screen_output "$cpu_data $cpu_2_data" + #echo three + if [[ -n "$cpu_data$arch_cache$cpu_2_data" ]];then + cpu_data=$( create_print_line "$line_starter" "$cpu_data$arch_cache$cpu_2_data" ) + print_screen_output "$cpu_data" + fi fi # we don't do this printing out extra line unless > 1 cpu core # note the numbering, the last array item is the min/max/not found for cpu speeds if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then - if [[ ${a_cpu_speeds[2]} != 0 ]];then - if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${a_cpu_speeds[1]} != 0 ]];then - max_speed="${C1}min/max$SEP3${C2} ${a_cpu_speeds[1]}/${a_cpu_speeds[2]} MHz " + if [[ ${a_cpu_info[2]} != 0 ]];then + if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${a_cpu_info[1]} != 0 ]];then + max_speed="${C1}min/max$SEP3${C2} ${a_cpu_info[1]}/${a_cpu_info[2]} MHz " else - max_speed="${C1}max$SEP3${C2} ${a_cpu_speeds[2]} MHz " + max_speed="${C1}max$SEP3${C2} ${a_cpu_info[2]} MHz " fi fi for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ )) @@ -11562,8 +13187,8 @@ print_cpu_data() # echo $(calculate_line_length "$multi_cpu_starter$SEP3 $cpu_multi_clock_data" ) working_cpu="$max_speed${C1}$(( i + 1 ))$SEP3${C2} ${a_cpu_working[1]%.*} MHz " max_speed='' - if [[ -n $cpu_multi_clock_data && \ - $( calculate_line_length "$multi_cpu_starter$cpu_multi_clock_data$working_cpu" ) -gt $COLS_INNER ]];then + calculate_line_length "$multi_cpu_starter$cpu_multi_clock_data$working_cpu" + if [[ -n $cpu_multi_clock_data && $LINE_LENGTH -gt $COLS_INNER ]];then cpu_multi_clock_data=$( create_print_line " " "$multi_cpu_starter$cpu_multi_clock_data" ) print_screen_output "$cpu_multi_clock_data" multi_cpu_starter='' @@ -11637,31 +13262,35 @@ print_cpu_flags_full() eval $LOGFE } -# args: $1 - type [sys/default]; $2 - get_dmidecode_data error return +# args: $1 - type [sys/bat/default]; $2 - get_dmidecode_data error return print_dmidecode_error() { eval $LOGFS local error_message='Unknown dmidecode error.' local sysDmiError='Using ' - if [[ $1 == 'sys' ]];then + if [[ $1 == 'sys' || $1 == 'bat' ]];then if [[ $B_FORCE_DMIDECODE == 'true' ]];then sysDmiError='Forcing ' # dragonfly has /sys, but it's empty - elif [[ $BSD_TYPE == '' || -d /sys/devices ]];then + elif [[ $1 == 'sys' ]] && [[ $BSD_TYPE == '' || -d /sys/devices ]];then sysDmiError='No /sys/class/dmi; using ' + #elif [[ $1 == 'bat' ]] && [[ $BSD_TYPE == '' || -d /sys/devices ]];then + # sysDmiError='No /sys/ battery; using ' else sysDmiError='Using ' fi fi if [[ $2 == 'dmidecode-error-requires-root' ]];then - error_message="${sysDmiError}dmidecode: you must be root to run dmidecode" + error_message="${sysDmiError}dmidecode: root required for dmidecode" elif [[ $2 == 'dmidecode-error-not-installed' ]];then error_message="${sysDmiError}dmidecode: dmidecode is not installed." elif [[ $2 == 'dmidecode-error-no-smbios-dmi-data' ]];then - error_message="${sysDmiError}dmidecode: no smbios data available. Old system?" + error_message="${sysDmiError}dmidecode: no smbios data. Old system?" + elif [[ $2 == 'dmidecode-error-no-battery-data' ]];then + error_message="${sysDmiError}dmidecode: no battery data." elif [[ $2 == 'dmidecode-error-unknown-error' ]];then - error_message="${sysDmiError}dmidecode: unknown error occured" + error_message="${sysDmiError}dmidecode: unknown error occurred" fi echo $error_message eval $LOGFE @@ -11671,25 +13300,32 @@ print_graphics_data() { eval $LOGFS local graphics_data='' card_id='' i='' root_alert='' root_x_string='' a_graphics_working='' - local b_is_mesa='false' display_full_string='' card_bus_id='' card_data='' - local res_tty='Resolution' xorg_data='' display_vendor_string='' chip_id='' + local b_is_mesa='false' display_full_string='' card_bus_id='' card_data='' + local res_tty='Resolution' xorg_data='' display_server_string='' chip_id='' sep_pci='' local spacer='' driver='' driver_string='' driver_plural='' direct_render_string='' - local separator_loaded='' separator_unloaded='' separator_failed='' - local loaded='' unloaded='' failed='' display_server_string='' - local line_starter='Graphics:' part_1_data='' part_2_data='' - local screen_resolution="$( get_graphics_res_data )" + local sep_loaded='' sep_unloaded='' sep_failed='' b_pci_driver='false' res_string='' + local loaded='' unloaded='' failed='' display_server_string='' b_force_tty='false' + local line_starter='Graphics:' part_1_data='' part_2_data='' b_advanced='true' + local screen_resolution="$( get_graphics_res_data 'reg' )" # set A_DISPLAY_SERVER_DATA get_graphics_display_server_data + local display_vendor=${A_DISPLAY_SERVER_DATA[0]} local display_version=${A_DISPLAY_SERVER_DATA[1]} + local display_server=${A_DISPLAY_SERVER_DATA[2]} + local compositor=${A_DISPLAY_SERVER_DATA[3]} compositor_string='' + # set A_GLX_DATA get_graphics_glx_data + # oglr, oglv, dr, oglcpv, compatVersion local glx_renderer="${A_GLX_DATA[0]}" local glx_version="${A_GLX_DATA[1]}" # this can contain a long No case debugging message, so it's being sliced off # note: using grep -ioE '(No|Yes)' <<< ${A_GLX_DATA[2]} did not work in Arch, no idea why - local glx_direct_render=$( gawk '{print $1}' <<< "${A_GLX_DATA[2]}" ) + local direct_rendering=$( gawk '{print $1}' <<< "${A_GLX_DATA[2]}" ) + local glx_core_version="${A_GLX_DATA[3]}" + local glx_compat_version_nu="${A_GLX_DATA[4]}" # set A_GRAPHICS_CARD_DATA if [[ $BSD_TYPE == 'bsd' ]];then @@ -11708,7 +13344,8 @@ print_graphics_data() get_graphics_driver if [[ ${#A_GRAPHIC_DRIVERS[@]} -eq 0 ]];then - driver=' N/A' + driver='' + b_pci_driver='true' else for (( i=0; i < ${#A_GRAPHIC_DRIVERS[@]}; i++ )) do @@ -11717,16 +13354,16 @@ print_graphics_data() IFS="$ORIGINAL_IFS" case ${a_graphics_working[1]} in loaded) - loaded="$loaded$separator_loaded${a_graphics_working[0]}" - separator_loaded=',' + loaded="$loaded$sep_loaded${a_graphics_working[0]}" + sep_loaded=',' ;; unloaded) - unloaded="$unloaded$separator_unloaded${a_graphics_working[0]}" - separator_unloaded=',' + unloaded="$unloaded$sep_unloaded${a_graphics_working[0]}" + sep_unloaded=',' ;; failed) - failed="$failed$separator_failed${a_graphics_working[0]}" - separator_failed=',' + failed="$failed$sep_failed${a_graphics_working[0]}" + sep_failed=',' ;; esac done @@ -11742,35 +13379,51 @@ print_graphics_data() fi # sometimes for some reason there is no driver found but the array is started if [[ -z $driver ]];then - driver=' N/A' + b_pci_driver='true' fi if [[ ${#A_GRAPHIC_DRIVERS[@]} -gt 1 ]];then driver_plural='s' fi # some basic error handling: if [[ -z $screen_resolution ]];then - screen_resolution='N/A' + screen_resolution="$( get_graphics_res_data 'tty' )" + if [[ -z $screen_resolution ]];then + screen_resolution='N/A' + else + b_force_tty='true' + fi fi # note: fix this, we may find a display server that has no version - if [[ -z $display_vendor || -z $display_version ]];then - display_vendor_string="N/A" + if [[ -z "${display_vendor// }" || -z "${display_version// }" ]];then + display_server_string="N/A " else - display_vendor_string="$display_vendor $display_version" + # note: sometimes display vendor has leading whitespace + display_server_string="${display_vendor##*[ ]} $display_version " fi - display_server_string="${C1}Display Server${SEP3}${C2} $display_vendor_string " - driver_string="${C1}driver$driver_plural$SEP3${C2}$driver " - - if [[ $B_ROOT == 'true' ]];then + if [[ $display_server != '' ]];then + display_server_string="$display_server ($display_server_string) " + fi + + if [[ $B_EXTRA_EXTRA_DATA == '' && $compositor != '' ]] &&\ + [[ $display_server == 'wayland' || $display_server == 'mir' ]];then + compositor_string="${C1}compositor$SEP3${C2} $compositor " + fi + + if [[ $glx_renderer == '' && $B_ROOT == 'true' ]];then root_x_string='for root ' - if [[ $B_IRC == 'false' || $B_CONSOLE_IRC == 'true' ]];then - res_tty='tty size' - fi + b_advanced='false' +# if [[ $B_IRC == 'false' || $B_CONSOLE_IRC == 'true' ]];then +# res_tty='tty size' +# fi fi if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then root_x_string="${root_x_string}out of X" res_tty='tty size' fi - + # || -n ${screen_resolution/*@*/} + if [[ $b_force_tty == 'true' || $B_SHOW_DISPLAY_DATA != 'true' || $B_RUNNING_IN_DISPLAY != 'true' ]];then + res_tty='tty size' + fi if [[ -n $root_x_string ]];then root_x_string="${C1}Advanced Data$SEP3${C2} N/A $root_x_string" fi @@ -11783,6 +13436,15 @@ print_graphics_data() IFS="$ORIGINAL_IFS" card_bus_id='' card_data=${a_graphics_working[0]} + if [[ $b_pci_driver == 'true' && ${a_graphics_working[2]} != '' ]];then + if [[ $sep_pci == ',' ]];then + driver_plural='s' + else + driver=' ' # front pad to match other matches + fi + driver=$driver$sep_pci${a_graphics_working[2]} + sep_pci=',' + fi if [[ $B_EXTRA_DATA == 'true' ]];then if [[ -n ${a_graphics_working[1]} ]];then card_bus_id="${a_graphics_working[1]}" @@ -11811,7 +13473,8 @@ print_graphics_data() part_2_data="$card_bus_id$chip_id" if [[ ${#A_GRAPHICS_CARD_DATA[@]} -gt 1 ]];then - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -11833,7 +13496,8 @@ print_graphics_data() fi # Print cards if not dual card system if [[ -n $part_1_data$part_2_data ]];then - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -11846,19 +13510,43 @@ print_graphics_data() fi line_starter=' ' graphics_data='' - - part_1_data="$display_server_string$driver_string" - part_2_data="${C1}$res_tty$SEP3${C2} $screen_resolution $root_x_string" - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) && \ - $( calculate_line_length "$part_1_data $part_2_data" ) -gt $COLS_INNER ]];then - graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) + if [[ $driver == '' ]];then + driver=' N/A' + fi + res_string="${C1}$res_tty$SEP3${C2} $screen_resolution " + display_server_string="${C1}Display Server${SEP3}${C2} $display_server_string$compositor_string" + driver_string="${C1}driver$driver_plural$SEP3${C2}$driver " + part_2_data="$res_string$root_x_string" + calculate_line_length "$display_server_string$driver_string$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + calculate_line_length "$display_server_string$driver_string" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + #echo one + graphics_data=$( create_print_line "$line_starter" "$display_server_string" ) + print_screen_output "$graphics_data" + graphics_data=$( create_print_line " " "$driver_string" ) + print_screen_output "$graphics_data" + else + #echo two + graphics_data=$( create_print_line "$line_starter" "$display_server_string$driver_string" ) + print_screen_output "$graphics_data" + fi + line_starter=' ' + display_server_string='' + driver_string='' + else + #echo three + graphics_data=$( create_print_line "$line_starter" "$display_server_string$driver_string$part_2_data" ) print_screen_output "$graphics_data" line_starter=' ' - part_1_data='' - graphics_data=$part_2_data + display_server_string='' + driver_string='' + part_2_data='' fi - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) ]];then - graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) + graphics_data=$display_server_string$driver_string$part_2_data + if [[ -n "${graphics_data// }" ]];then + #echo four + graphics_data=$( create_print_line "$line_starter" "$display_server_string$driver_string$part_2_data" ) print_screen_output "$graphics_data" line_starter=' ' fi @@ -11868,23 +13556,36 @@ print_graphics_data() ## note: if glx render or display_version have no content, then mesa is true # if [[ $B_SHOW_DISPLAY_DATA == 'true' ]] && [[ $b_is_mesa != 'true' ]];then - if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + # if [[ $B_SHOW_DISPLAY_DATA == 'true' && $B_ROOT != 'true' ]];then + if [[ $B_SHOW_DISPLAY_DATA == 'true' && $b_advanced == 'true' ]];then if [[ -z $glx_renderer ]];then glx_renderer='N/A' fi - if [[ -z $glx_version ]];then + if [[ -z $glx_version ]];then glx_version='N/A' + else + # non free drivers once filtered and cleaned show the same for core and compat + if [[ -n $glx_core_version && $glx_core_version != $glx_version ]];then + glx_version=$glx_core_version + if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then + if [[ $glx_compat_version_nu != '' ]];then + glx_version="$glx_version (compat-v$SEP3 $glx_compat_version_nu)" + fi + fi + fi fi - if [[ -z $glx_direct_render ]];then - glx_direct_render='N/A' + + if [[ -z $direct_rendering ]];then + direct_rendering='N/A' fi if [[ $B_HANDLE_CORRUPT_DATA == 'true' || $B_EXTRA_DATA == 'true' ]];then - direct_render_string=" ${C1}Direct Rendering$SEP3${C2} $glx_direct_render" + direct_render_string=" ${C1}Direct Render$SEP3${C2} $direct_rendering" fi - part_1_data="${C1}GLX Renderer$SEP3${C2} $glx_renderer " - part_2_data="${C1}GLX Version$SEP3${C2} $glx_version$direct_render_string" + part_1_data="${C1}OpenGL$SEP3 renderer$SEP3${C2} $glx_renderer " + part_2_data="${C1}version$SEP3${C2} $glx_version$direct_render_string" # echo $line_starter - if [[ $( calculate_line_length "$part_1_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" part_1_data='' @@ -11928,7 +13629,7 @@ print_hard_disk_data() get_hard_drive_data_advanced # temporary message to indicate not yet supported - if [[ $BSD_TYPE == 'bsd' && -z $Dmesg_Boot_Data ]];then + if [[ $BSD_TYPE == 'bsd' && -z $DMESG_BOOT_DATA ]];then hdd_data=$bsd_error hdd_data=$( create_print_line "$Line_Starter" "$hdd_data" ) print_screen_output "$hdd_data" @@ -11951,17 +13652,22 @@ print_hard_disk_data() hdd_temp_data=${a_hdd_working[5]} # error handling is done in get data function if [[ -n $hdd_temp_data ]];then - hdd_temp_data=" ${C1}temp$SEP3${C2} ${hdd_temp_data}C" + hdd_temp_data="${C1}temp$SEP3${C2} ${hdd_temp_data}C " else hdd_temp_data='' fi fi if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then - hdd_serial=${a_hdd_working[4]} - if [[ -z $hdd_serial ]];then + if [[ -n ${a_hdd_working[4]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + hdd_serial=$FILTER_STRING + else + hdd_serial=${a_hdd_working[4]} + fi + else hdd_serial='N/A' fi - hdd_serial=" ${C1}serial$SEP3${C2} $hdd_serial" + hdd_serial="${C1}serial$SEP3${C2} $hdd_serial " fi dev_data="$dev_string${a_hdd_working[0]} " fi @@ -11972,61 +13678,92 @@ print_hard_disk_data() fi # echo "loop: $i" hdd_name="${C1}model$SEP3${C2} $hdd_name_temp" - hdd_string="${C1}ID-$((i+1))$SEP3${C2} $usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data" + hdd_string="${C1}ID-$((i+1))$SEP3${C2} $usb_data$dev_data$hdd_name$size_data" part_1_data="$hdd_model$hdd_string " - + part_2_data="$hdd_serial$hdd_temp_data" + ## Forcing the capacity to print on its own row, and the first drive on its own + ## then each disk prints on its own line, or two lines, depending on console/output width if [[ $i -eq 0 ]];then - if [[ $( calculate_line_length "$row_starter$part_1_data" ) -gt $COLS_INNER ]];then + #if [[ $( calculate_line_length "$row_starter$part_1_data" ) -gt 80 ]];then + if [[ -n $row_starter ]];then hdd_data=$( create_print_line "$Line_Starter" "$row_starter" ) print_screen_output "$hdd_data" #echo 0 Line_Starter=' ' row_starter='' + fi + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then hdd_data=$( create_print_line "$Line_Starter" "$part_1_data" ) print_screen_output "$hdd_data" part_1_data='' - #echo 1 + hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) + print_screen_output "$hdd_data" + part_2_data='' else - hdd_data=$( create_print_line "$Line_Starter" "$row_starter$part_1_data" ) + hdd_data=$( create_print_line "$Line_Starter" "$part_1_data$part_2_data" ) print_screen_output "$hdd_data" - Line_Starter=' ' - row_starter='' part_1_data='' - #echo 2 - fi - fi - if [[ $( calculate_line_length "$row_starter$part_2_data$part_1_data" ) -gt $COLS_INNER ]];then - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_2_data ) ]];then - hdd_data=$( create_print_line "$Line_Starter" "$row_starter$part_2_data" ) - print_screen_output "$hdd_data" - #echo 3 - Line_Starter=' ' - row_starter='' part_2_data='' fi - hdd_data=$( create_print_line "$Line_Starter" "$row_starter$part_1_data" ) - print_screen_output "$hdd_data" - part_1_data='' - #echo 4 - elif [[ -n $part_2_data && \ - $( calculate_line_length "$row_starter$part_2_data$part_1_data" ) -le $COLS_INNER ]];then - hdd_data=$( create_print_line "$Line_Starter" "$row_starter$part_2_data$part_1_data" ) - print_screen_output "$hdd_data" - #echo 3 - Line_Starter=' ' - row_starter='' - part_1_data='' - part_2_data='' + #echo 1 + #else + # hdd_data=$( create_print_line "$Line_Starter" "$row_starter$part_1_data" ) + # print_screen_output "$hdd_data" + # Line_Starter=' ' + # row_starter='' + # part_1_data='' + #echo 2 + #fi else - part_2_data=$part_1_data + calculate_line_length "$part_1_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + hdd_data=$( create_print_line "$Line_Starter" "$part_1_data" ) + print_screen_output "$hdd_data" + part_1_data='' + hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) + print_screen_output "$hdd_data" + part_2_data='' + else + hdd_data=$( create_print_line "$Line_Starter" "$part_1_data$part_2_data" ) + print_screen_output "$hdd_data" + part_1_data='' + part_2_data='' + fi fi + # calculate_line_length "$part_2_data$part_1_data" +# if [[ $LINE_LENGTH -gt $COLS_INNER ]];then +# if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_2_data ) ]];then +# hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) +# print_screen_output "$hdd_data" +# #echo 3 +# Line_Starter=' ' +# #row_starter='' +# part_2_data='' +# fi +# hdd_data=$( create_print_line "$Line_Starter" "$part_1_data" ) +# print_screen_output "$hdd_data" +# part_1_data='' +# #echo 4 +# elif [[ -n $part_2_data && \ +# $( calculate_line_length "$part_2_data$part_1_data" ) -le $COLS_INNER ]];then +# hdd_data=$( create_print_line "$Line_Starter" "$part_2_data$part_1_data" ) +# print_screen_output "$hdd_data" +# #echo 3 +# Line_Starter=' ' +# #row_starter='' +# part_1_data='' +# part_2_data='' +# else +# part_2_data=$part_1_data +# fi done # then print any leftover items - if [[ -n $part_2_data ]];then - hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) - print_screen_output "$hdd_data" - #echo 5 - fi +# if [[ -n $part_2_data ]];then +# hdd_data=$( create_print_line "$Line_Starter" "$part_2_data" ) +# print_screen_output "$hdd_data" +# #echo 5 +# fi fi else hdd_data="$row_starter" @@ -12048,17 +13785,17 @@ print_info_data() local info_data='' line_starter='Info:' runlvl_default='' runlvl='' runlvl_title='runlevel' local init_data='' init_type='' init_version='' rc_type='' rc_version='' local client_data='' shell_data='' shell_parent='' tty_session='' - local memory="$( get_memory_data )" local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 )) - local up_time="$( get_uptime )" - if [[ -z $up_time ]];then - up_time='N/A - missing uptime?' + if [[ -z $UP_TIME ]];then + UP_TIME='N/A - missing uptime?' fi - local patch_version_number=$( get_patch_version_string ) + get_memory_data + get_uptime + get_patch_version_string local gcc_installed='' gcc_others='' closing_data='' - if [[ -z $memory ]];then - memory='N/A' + if [[ -z $MEMORY ]];then + MEMORY='N/A' fi if [[ $B_EXTRA_DATA == 'true' ]];then @@ -12098,8 +13835,8 @@ print_info_data() fi # Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch! - # long_last=$( echo -ne "${C1}Processes$SEP3${C2} $processes${CN} | ${C1}Uptime$SEP3${C2} $up_time${CN} | ${C1}Memory$SEP3${C2} $MEM${CN}" ) - info_data="${C1}Processes$SEP3${C2} $processes ${C1}Uptime$SEP3${C2} $up_time ${C1}Memory$SEP3${C2} $memory " + # long_last=$( echo -ne "${C1}Processes$SEP3${C2} $processes${CN} | ${C1}Uptime$SEP3${C2} $UP_TIME${CN} | ${C1}Memory$SEP3${C2} $MEM${CN}" ) + info_data="${C1}Processes$SEP3${C2} $processes ${C1}Uptime$SEP3${C2} $UP_TIME ${C1}Memory$SEP3${C2} $MEMORY " # this only triggers if no X data is present or if extra data switch is on if [[ $B_SHOW_DISPLAY_DATA != 'true' || $B_EXTRA_DATA == 'true' ]];then @@ -12142,9 +13879,10 @@ print_info_data() client_data="${C1}Client$SEP3${C2} $IRC_CLIENT$IRC_CLIENT_VERSION " fi # info_data="$info_data" - closing_data="$client_data${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number" + closing_data="$client_data${C1}$SELF_NAME$SEP3${C2} $SELF_VERSION$SELF_PATCH" # sometimes gcc is very long, and default runlevel can be long with systemd, so create a gcc-less line first - if [[ $( calculate_line_length "$info_data$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + calculate_line_length "$info_data$init_data$gcc_installed" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then # info_data=$info_data info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -12153,7 +13891,8 @@ print_info_data() line_starter=' ' #echo 1 fi - if [[ $( calculate_line_length "$init_data$gcc_installed" ) -gt $COLS_INNER ]];then + calculate_line_length "$init_data$gcc_installed" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then info_data=$init_data info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -12162,7 +13901,8 @@ print_info_data() line_starter=' ' #echo 2 fi - if [[ $( calculate_line_length "$info_data$init_data$gcc_installed$closing_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$info_data$init_data$gcc_installed$closing_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then info_data=$info_data$init_data$gcc_installed info_data=$( create_print_line "$line_starter" "$info_data" ) print_screen_output "$info_data" @@ -12187,13 +13927,14 @@ print_machine_data() { eval $LOGFS - local system_line='' mobo_line='' bios_line='' chassis_line='' + local system_line='' mobo_line='' bios_line='' chassis_line='' #firmware_type='BIOS' local mobo_vendor='' mobo_model='' mobo_version='' mobo_serial='' local bios_vendor='' bios_version='' bios_date='' bios_rom='' error_string='' local system_vendor='' product_name='' product_version='' product_serial='' product_uuid='' local chassis_vendor='' chassis_type='' chassis_version='' chassis_serial='' local b_skip_system='false' b_skip_chassis='false' local sysDmiNull='No /sys/class/dmi machine data: try newer kernel, or install dmidecode' + local device=$(get_device_data) # set A_MACHINE_DATA get_machine_data @@ -12201,9 +13942,11 @@ print_machine_data() ## keys for machine data are: # 0-sys_vendor 1-product_name 2-product_version 3-product_serial 4-product_uuid # 5-board_vendor 6-board_name 7-board_version 8-board_serial - # 9-bios_vendor 10-bios_version 11-bios_date + # 9-bios_vendor 10-bios_version 11-bios_date ## with extra data: # 12-chassis_vendor 13-chassis_type 14-chassis_version 15-chassis_serial + ## unused: 16-firmware_revision 17-firmware_romsize + # # a null array always has a count of 1 if [[ ${#A_MACHINE_DATA[@]} -gt 1 ]];then # note: in some case a mobo/version will match a product name/version, do not print those @@ -12212,7 +13955,7 @@ print_machine_data() if [[ -z ${A_MACHINE_DATA[0]} ]];then b_skip_system='true' else - if [[ $B_PORTABLE != 'true' ]];then + if [[ $B_POSSIBLE_PORTABLE != 'true' ]];then # ibm / ibm can be true; dell / quantum is false, so in other words, only do this # in case where the vendor is the same and the version is the same and not null, # otherwise the version information is going to be different in all cases I think @@ -12240,14 +13983,25 @@ print_machine_data() if [[ -n ${A_MACHINE_DATA[14]} ]];then chassis_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[14]}" fi - if [[ -n ${A_MACHINE_DATA[15]} && $B_OUTPUT_FILTER != 'true' ]];then - chassis_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[15]}" + if [[ -n ${A_MACHINE_DATA[15]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + chassis_serial=$FILTER_STRING + else + chassis_serial=${A_MACHINE_DATA[15]} + fi + else + chassis_serial='N/A' fi + chassis_serial=" ${C1}serial$SEP3${C2} $chassis_serial" if [[ -n "$chassis_vendor$chassis_type$chassis_version$chassis_serial" ]];then chassis_line="${C1}Chassis$SEP3${C2}$chassis_vendor$chassis_type$chassis_version$chassis_serial" fi fi fi + # echo ${A_MACHINE_DATA[@]} + if [[ -n ${A_MACHINE_DATA[18]} ]];then + firmware_type=${A_MACHINE_DATA[18]} + fi if [[ -n ${A_MACHINE_DATA[5]} ]];then mobo_vendor=${A_MACHINE_DATA[5]} else @@ -12261,9 +14015,16 @@ print_machine_data() if [[ -n ${A_MACHINE_DATA[7]} ]];then mobo_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[7]}" fi - if [[ -n ${A_MACHINE_DATA[8]} && $B_OUTPUT_FILTER != 'true' ]];then - mobo_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[8]}" + if [[ -n ${A_MACHINE_DATA[8]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + mobo_serial=$FILTER_STRING + else + mobo_serial=${A_MACHINE_DATA[8]} + fi + else + mobo_serial='N/A' fi + mobo_serial=" ${C1}serial$SEP3${C2} $mobo_serial" if [[ -n ${A_MACHINE_DATA[9]} ]];then bios_vendor=${A_MACHINE_DATA[9]} else @@ -12286,20 +14047,18 @@ print_machine_data() bios_rom=" ${C1}rom size$SEP3${C2} ${A_MACHINE_DATA[17]}" fi mobo_line="${C1}Mobo$SEP3${C2} $mobo_vendor ${C1}model$SEP3${C2} $mobo_model$mobo_version$mobo_serial" - bios_line="${C1}Bios$SEP3${C2} $bios_vendor ${C1}v$SEP3${C2} $bios_version ${C1}date$SEP3${C2} $bios_date$bios_rom" - if [[ $( calculate_line_length "$mobo_line$bios_line" ) -lt $COLS_INNER ]];then + bios_line="${C1}$firmware_type$SEP3${C2} $bios_vendor ${C1}v$SEP3${C2} $bios_version ${C1}date$SEP3${C2} $bios_date$bios_rom" + calculate_line_length "$mobo_line$bios_line" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then mobo_line="$mobo_line $bios_line" bios_line='' fi if [[ $b_skip_system == 'true' ]];then - system_line=$mobo_line + system_line="${C1}Device$SEP3${C2} $device $mobo_line" mobo_line='' else # this has already been tested for above so we know it's not null system_vendor=${A_MACHINE_DATA[0]} - if [[ $B_PORTABLE == 'true' ]];then - system_vendor="$system_vendor (portable)" - fi if [[ -n ${A_MACHINE_DATA[1]} ]];then product_name=${A_MACHINE_DATA[1]} else @@ -12308,11 +14067,19 @@ print_machine_data() if [[ -n ${A_MACHINE_DATA[2]} ]];then product_version=" ${C1}v$SEP3${C2} ${A_MACHINE_DATA[2]}" fi - if [[ -n ${A_MACHINE_DATA[3]} && $B_OUTPUT_FILTER != 'true' ]];then - product_serial=" ${C1}serial$SEP3${C2} ${A_MACHINE_DATA[3]} " + if [[ -n ${A_MACHINE_DATA[3]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + product_serial=$FILTER_STRING + else + product_serial=${A_MACHINE_DATA[3]} + fi + else + product_serial='N/A' fi - system_line="${C1}System$SEP3${C2} $system_vendor ${C1}product$SEP3${C2} $product_name$product_version$product_serial" - if [[ -n $chassis_line && $( calculate_line_length "$system_line$chassis_line" ) -lt $COLS_INNER ]];then + product_serial=" ${C1}serial$SEP3${C2} $product_serial " + system_line="${C1}Device$SEP3${C2} $device ${C1}System$SEP3${C2} $system_vendor ${C1}product$SEP3${C2} $product_name$product_version$product_serial" + calculate_line_length "$system_line$chassis_line" + if [[ -n $chassis_line && $LINE_LENGTH -lt $COLS_INNER ]];then system_line="$system_line $chassis_line" chassis_line='' fi @@ -12358,7 +14125,12 @@ print_module_version() if [[ -z $( grep -E '^snd' <<< $modules ) ]];then prefix='snd_' # sound modules start with snd_ fi - modules=$( tr '[A-Z]' '[a-z]' <<< "$modules" ) + + if (( "$BASH" >= 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 @@ -12472,13 +14244,15 @@ print_networking_data() card_string="${C1}Card$card_id$SEP3${C2} ${a_network_working[0]} " card_data="$driver_data$port_data" part_2_data="$pci_bus_id$chip_id" - if [[ $( calculate_line_length "$card_string$card_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$card_string$card_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line "$line_starter" "$card_string" ) line_starter=' ' card_string='' print_screen_output "$network_data" fi - if [[ $( calculate_line_length "$card_string$card_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$card_string$card_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line "$line_starter" "$card_string$card_data" ) print_screen_output "$network_data" line_starter=' ' @@ -12525,7 +14299,7 @@ print_network_advanced_data() if [[ -n ${a_network_working[6]} ]];then oper_state=${a_network_working[6]} fi - # no print out for wifi since it doesn't have duplex/speed data availabe + # no print out for wifi since it doesn't have duplex/speed data available # note that some cards show 'unknown' for state, so only testing explicitly # for 'down' string in that to skip showing speed/duplex if [[ $b_is_wifi != 'true' && $oper_state != 'down' ]];then @@ -12552,7 +14326,8 @@ print_network_advanced_data() fi network_data="${C1}IF$SEP3${C2} $if_id ${C1}state$SEP3${C2} $oper_state $speed_string$duplex_string" part_2_data="${C1}mac$SEP3${C2} $mac_id" - if [[ $( calculate_line_length "$network_data$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$network_data$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then network_data=$( create_print_line " " "$network_data" ) print_screen_output "$network_data" network_data='' @@ -12569,6 +14344,7 @@ print_network_advanced_data() print_networking_ip_data() { eval $LOGFS + # $ip should be IPv4 local ip=$( get_networking_wan_ip_data ) local wan_ip_data='' a_interfaces_working='' interfaces='' i=0 local if_id='' if_ip='' if_ipv6='' if_ipv6_string='' full_string='' if_string='' @@ -12600,60 +14376,85 @@ print_networking_ip_data() if [[ -n ${a_interfaces_working[1]} ]];then if [[ $B_OUTPUT_FILTER == 'true' ]];then if_ip=$FILTER_STRING + # we could filter each ipv6 extra address, but that can lead to + # a LOT of pointless output depending on the ip tool used and how + # many deprecated addresses there are, so just delete the values + a_interfaces_working[4]='' else if_ip=${a_interfaces_working[1]} fi fi - if_ip_string=" ${C1}ip$SEP3${C2} $if_ip" - if [[ $B_EXTRA_DATA == 'true' ]];then - if [[ -n ${a_interfaces_working[3]} ]];then - if [[ $B_OUTPUT_FILTER == 'true' ]];then - if_ipv6=$FILTER_STRING - else - if_ipv6=${a_interfaces_working[3]} - fi + if_ip_string=" ${C1}ip-v4$SEP3${C2} $if_ip" + # this is now going to always show as IPv6 starts to really be used globally + if [[ -n ${a_interfaces_working[3]} ]];then + if [[ $B_OUTPUT_FILTER == 'true' ]];then + if_ipv6=$FILTER_STRING + else + # may be more than one address here; get them all as one string + # but this is only the LINK scope, not Site or Global or Temporary + if_ipv6=${a_interfaces_working[3]/^/, } fi - if_ipv6_string=" ${C1}ip-v6$SEP3${C2} $if_ipv6" fi + if_ipv6_string=" ${C1}ip-v6-link$SEP3${C2} $if_ipv6" fi if [[ -n ${a_interfaces_working[0]} ]];then if_id=${a_interfaces_working[0]} fi if_string="${C1}IF$SEP3${C2} $if_id$if_ip_string$if_ipv6_string " - # first line, print wan on its own line if too long + # first line, print wan on its own line, then the next item if [[ $i -eq 0 ]];then - if [[ $( calculate_line_length "$wan_ip_data$if_string" ) -gt $COLS_INNER ]];then - full_string=$( create_print_line " " "$wan_ip_data" ) - print_screen_output "$full_string" - wan_ip_data='' - full_string=$( create_print_line " " "$if_string" ) - print_screen_output "$full_string" - if_string='' - else - full_string=$( create_print_line " " "$wan_ip_data$if_string" ) - print_screen_output "$full_string" - wan_ip_data='' - if_string='' - fi - else - if [[ $( calculate_line_length "$if_string_holding$if_string" ) -gt $COLS_INNER ]];then - if [[ -n $if_string_holding ]];then - full_string=$( create_print_line " " "$if_string_holding" ) - print_screen_output "$full_string" - fi - if_string_holding="$if_string" - else - if_string_holding="$if_string_holding$if_string" - fi + full_string=$( create_print_line " " "$wan_ip_data" ) + print_screen_output "$full_string" + wan_ip_data='' + fi + full_string=$( create_print_line " " "$if_string" ) + print_screen_output "$full_string" + if_string='' + if [[ ${a_interfaces_working[4]} != '' && $B_EXTRA_DATA == 'true' ]];then + IFS="^" + a_ipv6_ext=(${a_interfaces_working[4]}) + IFS="$ORIGINAL_IFS" + for (( j=0; j < ${#a_ipv6_ext[@]}; j++ )) + do + print_ipv6_ext_line "${a_ipv6_ext[j]}" + done fi ((i++)) done - # then print out anything not printed already - if [[ -n $if_string_holding ]];then - full_string=$( create_print_line " " "$if_string_holding" ) - print_screen_output "$full_string" + eval $LOGFE +} +print_ipv6_ext_line() +{ + eval $LOGFS + + local full_string='' ip_starter='' ip_data='' ip='' + + case $1 in + sg~*) + ip_starter="ip-v6-global" + ip=${1/sg~/} + ;; + ss~*) + ip_starter="ip-v6-site" + ip=${1/ss~/} + ;; + st~*) + ip_starter="ip-v6-temporary" + ip=${1/st~/} + ;; + su~*) + ip_starter="ip-v6-unknown" + ip=${1/su~/} + ;; + esac + if [[ $B_OUTPUT_FILTER == 'true' ]];then + ip=$FILTER_STRING fi + ip_data="${C1}$ip_starter$SEP3${C2} $ip" + full_string=$( create_print_line " " "$ip_data" ) + print_screen_output "$full_string" + eval $LOGFE } @@ -12663,6 +14464,7 @@ print_optical_drive_data() local a_drives='' drive_data='' counter='' dev_string='/dev/' speed_string='x' local drive_id='' drive_links='' vendor='' speed='' multisession='' mcn='' audio='' local dvd='' state='' rw_support='' rev='' separator='' drive_string='' part_2_data='' + local drive_type='Optical' fd_counter=0 opt_counter=0 b_floppy='false' if [[ -z $BSD_TYPE ]];then get_optical_drive_data else @@ -12698,57 +14500,73 @@ print_optical_drive_data() drive_string="No optical drives detected." B_SHOW_FULL_OPTICAL='false' else - if [[ ${#A_OPTICAL_DRIVE_DATA[@]} -gt 1 ]];then - counter="-$(( i + 1 ))" + if [[ -n ${a_drives[0]/fd*/} ]];then + opt_counter=$(( $opt_counter + 1 )) + counter="-$opt_counter" + drive_type='Optical' + b_floppy='false' + else + fd_counter=$(( $fd_counter + 1 )) + counter="-$fd_counter" + drive_type='Floppy' + b_floppy='true' fi if [[ -z ${a_drives[0]} ]];then drive_id='N/A' else drive_id="$dev_string${a_drives[0]}" fi - drive_links=$( sed 's/~/,/g' <<< ${a_drives[1]} ) - if [[ -z $drive_links ]];then - drive_links='N/A' - fi - if [[ -n ${a_drives[2]} ]];then - vendor=${a_drives[2]} - if [[ -n ${a_drives[3]} ]];then - vendor="$vendor ${a_drives[3]}" + if [[ $b_floppy == 'false' ]];then + drive_links=$( sed 's/~/,/g' <<< ${a_drives[1]} ) + if [[ -z $drive_links ]];then + drive_links='N/A' fi - fi - if [[ -z $vendor ]];then - if [[ -n ${a_drives[3]} ]];then - vendor=${a_drives[3]} - else - vendor='N/A' + if [[ -n ${a_drives[2]} ]];then + vendor=${a_drives[2]} + if [[ -n ${a_drives[3]} ]];then + vendor="$vendor ${a_drives[3]}" + fi fi - fi - if [[ $B_EXTRA_DATA == 'true' ]];then - if [[ -n ${a_drives[4]} ]];then - rev=${a_drives[4]} - else - rev='N/A' + if [[ -z $vendor ]];then + if [[ -n ${a_drives[3]} ]];then + vendor=${a_drives[3]} + else + vendor='N/A' + fi fi - rev="${C1}rev$SEP3${C2} $rev " + if [[ $B_EXTRA_DATA == 'true' ]];then + if [[ -n ${a_drives[4]} ]];then + rev=${a_drives[4]} + else + rev='N/A' + fi + rev="${C1}rev$SEP3${C2} $rev " + fi + drive_string="$drive_id ${C1}model$SEP3${C2} $vendor " + part_2_data="$rev${C1}dev-links$SEP3${C2} $drive_links" + else + drive_string="$drive_id" + part_2_data='' fi - drive_string="$drive_id ${C1}model$SEP3${C2} $vendor " - part_2_data="$rev${C1}dev-links$SEP3${C2} $drive_links" fi - drive_data="${C1}Optical${counter}$SEP3${C2} $drive_string" - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + drive_data="${C1}$drive_type${counter}$SEP3${C2} $drive_string" + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' drive_data='' part_2_data='' else - if [[ $( calculate_line_length "$drive_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$drive_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data" ) print_screen_output "$drive_data" Line_Starter=' ' drive_data='' fi - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' @@ -12776,7 +14594,7 @@ print_optical_drive_data() # 12 - dvdr # 13 - dvdram # 14 - state - if [[ $B_SHOW_FULL_OPTICAL == 'true' ]];then + if [[ $B_SHOW_FULL_OPTICAL == 'true' && $b_floppy == 'false' ]];then if [[ -z ${a_drives[5]} ]];then speed='N/A' else @@ -12834,7 +14652,8 @@ print_optical_drive_data() fi drive_data="${C1}Features: speed$SEP3${C2} $speed $multisession" part_2_data="$audio${C1}dvd$SEP3${C2} $dvd ${C1}rw$SEP3${C2} $rw_support $state" - if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then + calculate_line_length "$drive_data$part_2_data" + if [[ $LINE_LENGTH -lt $COLS_INNER ]];then drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data" ) print_screen_output "$drive_data" Line_Starter=' ' @@ -12856,11 +14675,11 @@ print_optical_drive_data() print_partition_data() { eval $LOGFS - local a_partition_working='' partition_used='' partition_data='' - local counter=0 i=0 part_id=0 a_partition_data='' line_starter='' - local partitionIdClean='' part_dev='' full_dev='' part_label='' full_label='' + local a_part_working='' part_used='' partition_data='' + local counter=0 i=0 part_id=0 a_part_data='' line_starter='' + local part_id_clean='' part_dev='' full_dev='' part_label='' full_label='' local part_uuid='' full_uuid='' dev_remote='' full_fs='' - local b_non_dev='false' holder='' + local b_non_dev='false' holder='' id_size_used='' label_uuid='' fs_dev='' # set A_PARTITION_DATA get_partition_data @@ -12868,33 +14687,33 @@ print_partition_data() for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do IFS="," - a_partition_working=(${A_PARTITION_DATA[i]}) + a_part_working=(${A_PARTITION_DATA[i]}) IFS="$ORIGINAL_IFS" full_label='' full_uuid='' - if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_partition_working[4]} == 'main' ]];then - if [[ -n ${a_partition_working[2]} ]];then - partition_used="${C1}used$SEP3${C2} ${a_partition_working[2]} (${a_partition_working[3]}) " + if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_part_working[4]} == 'main' ]];then + if [[ -n ${a_part_working[2]} ]];then + part_used="${C1}used$SEP3${C2} ${a_part_working[2]} (${a_part_working[3]}) " else - partition_used='' # reset partition used to null + part_used='' # reset partition used to null fi - if [[ -n ${a_partition_working[5]} ]];then - full_fs="${a_partition_working[5]}" + if [[ -n ${a_part_working[5]} ]];then + full_fs="${a_part_working[5]}" else full_fs='N/A' # reset partition fs type fi full_fs="${C1}fs$SEP3${C2} $full_fs " - if [[ -n ${a_partition_working[6]} ]];then - if [[ -z $( grep -E '(^//|:/|non-dev)' <<< ${a_partition_working[6]} ) ]];then - part_dev="/dev/${a_partition_working[6]}" + if [[ -n ${a_part_working[6]} ]];then + if [[ -z $( grep -E '(^//|:/|non-dev)' <<< ${a_part_working[6]} ) ]];then + part_dev="/dev/${a_part_working[6]}" dev_remote='dev' - elif [[ -n $( grep '^non-dev' <<< ${a_partition_working[6]} ) ]];then - holder=$( sed 's/non-dev-//' <<< ${a_partition_working[6]} ) + elif [[ -n $( grep '^non-dev' <<< ${a_part_working[6]} ) ]];then + holder=$( sed 's/non-dev-//' <<< ${a_part_working[6]} ) part_dev="$holder" dev_remote='raid' else - part_dev="${a_partition_working[6]}" + part_dev="${a_part_working[6]}" dev_remote='remote' fi else @@ -12904,16 +14723,16 @@ print_partition_data() full_dev="${C1}$dev_remote$SEP3${C2} $part_dev " if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then if [[ $B_SHOW_LABELS == 'true' && $dev_remote != 'remote' ]];then - if [[ -n ${a_partition_working[7]} ]];then - part_label="${a_partition_working[7]}" + if [[ -n ${a_part_working[7]} ]];then + part_label="${a_part_working[7]}" else part_label='N/A' fi full_label="${C1}label$SEP3${C2} $part_label " fi if [[ $B_SHOW_UUIDS == 'true' && $dev_remote != 'remote' ]];then - if [[ -n ${a_partition_working[8]} ]];then - part_uuid="${a_partition_working[8]}" + if [[ -n ${a_part_working[8]} ]];then + part_uuid="${a_part_working[8]}" else part_uuid='N/A' fi @@ -12922,25 +14741,42 @@ print_partition_data() fi # don't show user names in output if [[ $B_OUTPUT_FILTER == 'true' ]];then - partitionIdClean=$( sed $SED_RX "s|/home/([^/]+)/(.*)|/home/$FILTER_STRING/\2|" <<< ${a_partition_working[0]} ) + part_id_clean=$( sed $SED_RX "s|/home/([^/]+)/(.*)|/home/$FILTER_STRING/\2|" <<< ${a_part_working[0]} ) else - partitionIdClean=${a_partition_working[0]} + part_id_clean=${a_part_working[0]} fi - id_size_fs="${C1}ID-$((part_id+1))$SEP3${C2} $partitionIdClean ${C1}size$SEP3${C2} ${a_partition_working[1]} $partition_used$full_fs$full_dev" + id_size_used="${C1}ID-$((part_id+1))$SEP3${C2} $part_id_clean ${C1}size$SEP3${C2} ${a_part_working[1]} $part_used" + fs_dev="$full_fs$full_dev" label_uuid="$full_label$full_uuid" - # label/uuid always print one per line, so only wrap if it's very long - if [[ $B_SHOW_UUIDS == 'true' || $B_SHOW_LABELS == 'true' ]] && \ - [[ $( calculate_line_length "${a_partition_data[$counter]}$id_size_fs$label_uuid" ) -gt $COLS_INNER ]];then - a_partition_data[$counter]="$id_size_fs" + calculate_line_length "${a_part_data[$counter]}$id_size_used$fs_dev" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + a_part_data[$counter]="$id_size_used" ((counter++)) - a_partition_data[$counter]="$label_uuid" - else - if [[ $( calculate_line_length "${a_partition_data[$counter]}$id_size_fs$label_uuid" ) -gt $COLS_INNER ]];then - a_partition_data[$counter]="${a_partition_data[$counter]}" - ((counter++)) - a_partition_data[$counter]="$id_size_fs$label_uuid" + calculate_line_length "$fs_dev$label_uuid" + if [[ $LINE_LENGTH -le $COLS_INNER ]];then + a_part_data[$counter]="$fs_dev$label_uuid" + label_uuid='' else - a_partition_data[$counter]="${a_partition_data[$counter]}$id_size_fs$label_uuid" + a_part_data[$counter]="$fs_dev" + fi + ((counter++)) + id_size_used='' + fs_dev='' + fi + # label/uuid always print one per line, so only wrap if it's very long + calculate_line_length "${a_part_data[$counter]}$id_size_used$fs_dev$label_uuid" + if [[ $B_SHOW_UUIDS == 'true' || $B_SHOW_LABELS == 'true' ]] && \ + [[ $LINE_LENGTH -gt $COLS_INNER ]];then + a_part_data[$counter]="$id_size_used$fs_dev" + ((counter++)) + a_part_data[$counter]="$label_uuid" + else + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + a_part_data[$counter]="${a_part_data[$counter]}" + ((counter++)) + a_part_data[$counter]="$id_size_used$fs_dev$label_uuid" + else + a_part_data[$counter]="${a_part_data[$counter]}$id_size_used$fs_dev$label_uuid" fi fi ((counter++)) @@ -12948,15 +14784,15 @@ print_partition_data() fi done # print out all lines, line starter on first line - for (( i=0; i < ${#a_partition_data[@]};i++ )) + for (( i=0; i < ${#a_part_data[@]};i++ )) do if [[ $i -eq 0 ]];then line_starter='Partition:' else line_starter=' ' fi - if [[ -n ${a_partition_data[$i]} ]];then - partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" ) + if [[ -n ${a_part_data[$i]} ]];then + partition_data=$( create_print_line "$line_starter" "${a_part_data[$i]}" ) print_screen_output "$partition_data" fi done @@ -12966,8 +14802,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' @@ -13003,17 +14838,32 @@ 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='' + 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" fi + # important: ${C2} $PS_COUNT must have space after ${C2} for irc output or the number vanishes case $1 in cpu) - line_start_data="${C1}CPU - % used - top ${C2} $PS_COUNT ${C1}active$throttled " + 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 + get_memory_data + memory_info=" - ${C1}Used/Total$SEP3${C2} $MEMORY" + fi + fi + line_start_data="${C1}CPU$SEP3 % used$extra_text$memory_info${C1} - top${C2} $PS_COUNT ${C1}active$throttled" ;; mem) - line_start_data="${C1}Memory - MB / % used - top ${C2} $PS_COUNT ${C1}active$throttled" + if [[ $B_EXTRA_DATA == 'true' ]];then + extra_text=" ${C1}- CPU$SEP3 % used" + fi + if [[ $B_SHOW_INFO == 'false' ]];then + get_memory_data + memory_info=" - ${C1}Used/Total$SEP3${C2} $MEMORY" + fi + line_start_data="${C1}Memory$SEP3 MB / % used$memory_info$extra_text${C1} - top${C2} $PS_COUNT ${C1}active$throttled" ;; esac @@ -13380,7 +15230,7 @@ print_ram_data() local manufacturer='' part_nu='' serial_nu='' device_speed='' configured_speed='' bus_width= local data_width='' total_width='' device_type='' device_type_detail='' bank='' slot='' form_factor='' local device_size='' array_use='' location='' error_correction='' max_capacity='' nu_of_devices='' - local max_module_size='' module_voltage='' bank_connection='' + local max_module_size='' module_voltage='' bank_connection='' memory_info='' get_ram_data #echo ${#A_MEMORY_DATA[@]} @@ -13390,6 +15240,10 @@ print_ram_data() error_string=$( print_dmidecode_error 'default' "${A_MEMORY_DATA[0]}" ) memory_line="${C2}$error_string" else + if [[ $B_SHOW_INFO == 'false' && $B_SHOW_PS_MEM_DATA == 'false' ]];then + get_memory_data + memory_info="${C1}Used/Total$SEP3${C2} $MEMORY" + fi for (( i=0;i<${#A_MEMORY_DATA[@]};i++ )) do IFS=',' @@ -13407,6 +15261,12 @@ print_ram_data() max_module_size='' module_voltage='' bank_connection='' + if [[ -n $memory_info ]];then + memory_line=$( create_print_line "$line_starter" "$memory_info" ) + print_screen_output "$memory_line" + line_starter='' + memory_info='' + fi # memory-array,0x0012,System Board,8 GB,4,System Memory,None,max size,moudule voltage if [[ ${a_memory_item[0]} == 'memory-array' ]];then if [[ -n ${a_memory_item[4]} ]];then @@ -13436,7 +15296,8 @@ print_ram_data() fi memory_line="${C1}Array-$array_counter capacity$SEP3${C2} $max_capacity ${C1}devices$SEP3${C2} $nu_of_devices ${C1}EC$SEP3${C2} $error_correction " line_2="$max_module_size$module_voltage" - if [[ -n $line_2 && $( calculate_line_length "$memory_line$line_2" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_2" + if [[ -n $line_2 && $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_2" @@ -13531,12 +15392,15 @@ print_ram_data() fi manufacturer="${C1}manufacturer$SEP3${C2} $manufacturer " if [[ -n ${a_memory_item[14]} ]];then - serial_nu=${a_memory_item[14]} + if [[ $B_OUTPUT_FILTER == 'true' ]];then + serial_nu=$FILTER_STRING + else + serial_nu=${a_memory_item[14]} + fi else serial_nu='N/A' fi serial_nu="${C1}serial$SEP3${C2} $serial_nu " - if [[ $device_size != 'N/A' && -n ${a_memory_item[16]} ]];then bank_connection=" ${a_memory_item[16]}" fi @@ -13559,7 +15423,8 @@ print_ram_data() fi fi memory_line="${C1}Device-$device_counter$SEP3${C2} $locator ${C1}size$SEP3${C2} $device_size$bank_connection $device_speed" - if [[ $( calculate_line_length "$memory_line$device_type" ) -le $COLS_INNER ]];then + calculate_line_length "$memory_line$device_type" + if [[ $LINE_LENGTH -le $COLS_INNER ]];then memory_line="$memory_line$device_type" device_type='' fi @@ -13567,12 +15432,14 @@ print_ram_data() line_2="$device_type$bus_width" # echo $( calculate_line_length "$memory_line" ) # echo $( calculate_line_length "$memory_line$line_2" ) - if [[ $( calculate_line_length "$memory_line$line_2$line_3" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_2$line_3" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_2" line_starter=' ' - if [[ -n $memory_line && -n $line_3 && $( calculate_line_length "$memory_line$line_3" ) -gt $COLS_INNER ]];then + calculate_line_length "$memory_line$line_3" + if [[ -n $memory_line && -n $line_3 && $LINE_LENGTH -gt $COLS_INNER ]];then memory_line=$( create_print_line "$line_starter" "$memory_line" ) print_screen_output "$memory_line" memory_line="$line_3" @@ -13662,7 +15529,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 @@ -13819,15 +15686,14 @@ print_system_data() local system_data='' bits='' desktop_environment='' dm_data='' de_extra_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 host_name=$HOSTNAME bit_comp='' 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 ) @@ -13841,8 +15707,13 @@ print_system_data() de_extra_data=" ${C1}info$SEP3${C2} $de_extra_data" fi fi - else + fi + # handle separately since some systems will have no root desktop data + if [[ $B_RUNNING_IN_DISPLAY == 'false' ]] || [[ $desktop_environment == 'N/A' && $B_ROOT == 'true' ]];then tty_session=$( get_tty_number ) + if [[ $desktop_environment == 'N/A' ]];then + de_extra_data='' + fi if [[ -z $tty_session && $B_CONSOLE_IRC == 'true' ]];then tty_session=$( get_tty_console_irc ) fi @@ -13869,7 +15740,7 @@ print_system_data() if [[ $B_EXTRA_DATA == 'true' ]];then compiler_string=$( get_kernel_compiler_version ) if [[ -n $compiler_string ]];then - compiler_string=" ${C1}${compiler_string%^*}$SEP3${C2} ${compiler_string#*^}" + compiler_string="${C1}${compiler_string%^*}$SEP3${C2} ${compiler_string#*^} " fi fi # check for 64 bit first @@ -13878,7 +15749,8 @@ print_system_data() else bits="32" fi - bits=" ($bits bit$compiler_string)" + bits="${C1}bits$SEP3${C2} $bits " + if [[ $B_SHOW_HOST == 'true' ]];then if [[ -z $HOSTNAME ]];then if [[ -n $( type p hostname ) ]];then @@ -13890,26 +15762,43 @@ 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_comp="$bits$compiler_string" de_string="${C1}$desktop_type$SEP3${C2} $desktop_environment$de_extra_data$dm_data " distro_string="${C1}$distro_os$SEP3${C2} $distro " - - if [[ $( calculate_line_length "$host_kernel_string$de_string" ) -gt $COLS_INNER ]];then - system_data=$( create_print_line "$line_starter" "$host_kernel_string" ) - print_screen_output "$system_data" + calculate_line_length "$host_kernel_string$bits_comp$de_string" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + calculate_line_length "$host_kernel_string$bits_comp" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + #echo one + system_data=$( create_print_line "$line_starter" "$host_kernel_string" ) + print_screen_output "$system_data" + system_data=$( create_print_line " " "$bits_comp" ) + print_screen_output "$system_data" + else + #echo two + system_data=$( create_print_line "$line_starter" "$host_kernel_string$bits_comp" ) + print_screen_output "$system_data" + + fi host_kernel_string='' + bits_comp='' line_starter=' ' fi - if [[ $( calculate_line_length "$host_kernel_string$de_string$distro_string" ) -gt $COLS_INNER ]];then - system_data=$( create_print_line "$line_starter" "$host_kernel_string$de_string" ) + calculate_line_length "$host_kernel_string$bits_comp$de_string$distro_string" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then + #echo three + system_data=$( create_print_line "$line_starter" "$host_kernel_string$bits_comp$de_string" ) print_screen_output "$system_data" host_kernel_string='' de_string='' + bits_comp='' line_starter=' ' fi - system_data="$host_kernel_string$de_string$distro_string" + system_data="$host_kernel_string$bits_comp$de_string$distro_string" if [[ -n $system_data ]];then - system_data="$host_kernel_string$de_string$distro_string" + #echo four + system_data="$host_kernel_string$bits_comp$de_string$distro_string" system_data=$( create_print_line "$line_starter" "$system_data" ) print_screen_output "$system_data" fi @@ -13923,7 +15812,7 @@ print_unmounted_partition_data() 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.' - local line_starter='Unmounted:' part_2_data='' + local line_starter='Unmounted:' part_2_data='' if [[ -z ${A_PARTITION_DATA} ]];then get_partition_data @@ -13970,10 +15859,11 @@ print_unmounted_partition_data() if [[ $BSD_TYPE == 'bsd' ]];then full_string=$bsd_unsupported else - full_string="$full_dev$full_size" - part_2_data="$full_fs$full_label$full_uuid" + full_string="$full_dev$full_size$full_fs" + part_2_data="$full_label$full_uuid" fi - if [[ $( calculate_line_length "$full_string$part_2_data" ) -gt $COLS_INNER ]];then + calculate_line_length "$full_string$part_2_data" + if [[ $LINE_LENGTH -gt $COLS_INNER ]];then unmounted_data=$( create_print_line "$line_starter" "$full_string" ) print_screen_output "$unmounted_data" line_starter=' ' @@ -14090,7 +15980,8 @@ print_weather_data() country=" $openP${a_location[5]}$closeP" fi if [[ -n ${a_weather[10]} ]];then - altitude=" ${C1}Altitude$SEP3${C2} ${a_weather[10]}" + # note: bug in source data uses ft for meters, not 100% of time, but usually + altitude=" ${C1}Altitude$SEP3${C2} ${a_weather[10]/ft/m}" fi location_string="${C1}Location$SEP3${C2}$city$state$country$altitude " else @@ -14098,7 +15989,7 @@ print_weather_data() time_string='' observation_time='' fi - # the last three are oftenblank + # the last three are often blank if [[ -z "$heat_index$wind_chill$dew_point" ]];then weather_data=$( create_print_line " " "$pressure$location_string" ) print_screen_output "$weather_data"