2 ########################################################################
6 ########################################################################
8 ########################################################################
9 #### Special thanks to all those in #lsc and #smxi for their tireless
10 #### dedication helping test inxi modules.
11 ########################################################################
13 ########################################################################
14 #### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
15 #### As time permits functionality improvements and recoding will occur.
17 #### inxi, the universal, portable, system info script for irc.
18 #### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
19 #### Gaim/Pidgin, Weechat, KVIrc and Kopete.
20 #### Original infobash author and copyright holder:
21 #### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
22 #### inxi version: Copyright (C) 2008-9 Scott Rogers & Harald Hope
23 #### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
24 #### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
26 #### Current script home page: http://techpatterns.com/forums/about1131.html
27 #### Script svn: http://code.google.com/p/inxi
29 #### This program is free software; you can redistribute it and/or modify
30 #### it under the terms of the GNU General Public License as published by
31 #### the Free Software Foundation; either version 3 of the License, or
32 #### (at your option) any later version.
34 #### This program is distributed in the hope that it will be useful,
35 #### but WITHOUT ANY WARRANTY; without even the implied warranty of
36 #### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 #### GNU General Public License for more details.
39 #### You should have received a copy of the GNU General Public License
40 #### along with this program. If not, see <http://www.gnu.org/licenses/>.
42 #### If you don't understand what Free Software is, please read (or reread)
43 #### this page: http://www.gnu.org/philosophy/free-sw.html
44 ########################################################################
46 #### bash >=3.0(bash), df;readlink;stty;tr;uname;wc(coreutils),
47 #### gawk(gawk), grep(grep), hostname(hostname), lspci(pciutils),
48 #### ps;uptime(procps), glxinfo;xdpyinfo;xrandr(xbase-clients)
49 #### Also the proc filesystem should be present and mounted
51 #### Apparently unpatched bash 3.0 has arrays broken; bug reports:
52 #### http://ftp.gnu.org/gnu/bash/bash-3.0-patches/bash30-008
53 #### http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00144.html
55 #### Arrays work in bash 2.05b, but "egrep -m" does not
57 #### RECOMMENDS (Needed to run certain features)
58 #### For local interfaces/IP test: ifconfig (in net-tools for Debian systems)
59 #### runlevel(sysvinit): to view current runlevel while not in X window system
60 #### Bash 3.1 for proper array use
61 ########################################################################
63 #### Indentation: TABS
64 #### Do not use `....` (back quotes), those are totally non-reabable, use $(....).
65 #### Do not use one liner flow controls.
66 #### The ONLY time you should use ';' (semi-colon) is in this single case: if [[ condition ]];then.
67 #### Never use compound 'if': ie, if [[ condition ]] && statement.
68 #### Note: [[ -n $something ]] - double brackets does not require quotes for variables: ie, "$something".
69 #### Always use quotes, double or single, for all string values.
71 #### All new code/methods must be in a function.
72 #### For all boolean tests, use 'true' / 'false'.
73 #### !! Do NOT use 0 or 1 unless it's a function return.
74 #### Avoid complicated tests in the if condition itself.
75 #### To 'return' a value in a function, use 'echo <var>'.
77 #### For gawk: use always if ( num_of_cores > 1 ) { hanging { starter for all blocks
78 #### This lets us use one method for all gawk structures, including BEGIN/END, if, for, etc
80 #### VARIABLE/FUNCTION NAMING:
81 #### All functions should follow standard naming--verb adjective noun.
83 #### All variables MUST be initialized / declared explicitly.
84 #### All variables should clearly explain what they are, except counters like i, j.
85 #### Each word of variable must be separated by '_' (underscore) (camel form).
86 #### Global variables are 'UPPER CASE', at top of script.
87 #### ie, SOME_VARIABLE=''
88 #### Local variables are 'lower case' and declared at the top of the function.
89 #### ie, some_variable=''
90 #### Locals that will be inherited by child functions have first char capitalized (so you know they are inherited).
91 #### ie, Some_Variable
93 #### Booleans should start with b_ (local) or B_ (global) and state clearly what is being tested.
94 #### Arrays should start with a_ (local) or A_ (global).
97 #### The color variable ${C2} must always be followed by a space unless you know what
98 #### character is going to be next for certain. Otherwise irc color codes can be accidentally
99 #### activated or altered.
101 #### For native script konversation support (check distro for correct konvi scripts path):
102 #### ln -s <path to inxi> /usr/share/apps/konversation/scripts/inxi
103 #### DCOP doesn't like \n, so avoid using it for most output unless required, as in error messages.
105 #### As with all 'rules' there are acceptions, these are noted where used.
107 ###################################################################################
108 #### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4)
109 ###################################################################################
110 #### dcop and dbus -- these talk back to Konversation from this script
112 #### Scripting info -- http://konversation.berlios.de/docs/scripting.html
113 #### -- http://www.kde.org.uk/apps/konversation/
115 #### dbus info -- http://dbus.freedesktop.org/doc/dbus-tutorial.html
116 #### view dbus info -- https://fedorahosted.org/d-feet/
118 #### Konvi dbus/usage-- qdbus org.kde.konversation /irc say <server> <target-channel> <output>
120 #### Python usage -- http://wiki.python.org/moin/DbusExamples (just in case)
122 #### Because webpages come and go, the above information needs to be moved to inxi's wiki
124 ########################################################################
125 #### Valuable Resources
126 #### gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html
127 ########################################################################
129 #### inxi supports advanced testing triggers to do various things, using -! <arg>
130 #### -! 1 - triggers default B_TESTING_1='true' to trigger some test or other
131 #### -! 2 - triggers default B_TESTING_2='true' to trigger some test or other
132 #### -! 3 - triggers B_TESTING_1='true' and B_TESTING_2='true'
133 #### -! 10 - triggers an update from the primary dev download server instead of svn
134 #### -! 11 - triggers an update from svn branch one - if present, of course
135 #### -! 12 - triggers an update from svn branch two - if present, of course
136 #### -! 13 - triggers an update from svn branch three - if present, of course
137 #### -! 14 - triggers an update from svn branch four - if present, of course
138 #### -! <http://......> - Triggers an update from whatever server you list.
139 #### LOG FLAGS (logs to $HOME/.inxi/inxi.log with rotate 3 total)
140 #### -@ 8 - Basic data logging of generated data / array values
141 #### -@ 9 - Full logging of all data used, including cat of files and system data
142 #### -@ 10 - Basic data logging plus color code logging
143 ########################################################################
145 ########################################################################
147 ## NOTE: we can use hwinfo if it's available in all systems, or most, to get
148 ## a lot more data and verbosity levels going
150 ### Variable initializations: null values
155 IRC_CLIENT_VERSION=''
157 ### primary data array holders ## usage: 'A_<var>'
162 A_CPU_TYPE_PCNT_CCNT=''
172 ### Boolean true/false globals ## usage: 'B_<var>'
173 # flag to allow distro maintainers to turn off update features. If false, turns off
174 # -U and -! testing/advanced update options, as well as removing the -U help menu item
175 B_ALLOW_UPDATE='true'
176 # triggers full display of cpu flags
177 B_CPU_FLAGS_FULL='false'
178 # Debug flood override: make 'true' to allow long debug output
179 B_DEBUG_FLOOD='false'
180 # show extra output data
182 # override certain errors due to currupted data
183 B_HANDLE_CORRUPT_DATA='false'
185 B_LOG_FULL_DATA='false'
187 # Running in a shell? Defaults to false, and is determined later.
188 B_RUNNING_IN_SHELL='false'
189 # this sets the debug buffer
191 # Show sound card data
195 # Show full hard disk output
196 B_SHOW_FULL_HDD='false'
197 B_SHOW_GRAPHICS='false'
198 # Set this to 'false' to avoid printing the hostname
202 B_SHOW_LABELS='false'
203 B_SHOW_NETWORK='false'
204 # either -v > 3 or -P will show partitions
205 B_SHOW_PARTITIONS='false'
206 B_SHOW_PARTITIONS_FULL='false'
207 # triggers only short inxi output
208 B_SHOW_SHORT_OUTPUT='false'
209 B_SHOW_SYSTEM='false'
211 # triggers various debugging and new option testing
214 # set to true here for debug logging from script start
215 B_USE_LOGGING='false'
218 # test for dbus irc client
219 B_DBUS_CLIENT='false'
221 ### Directory/file exist flags; test as [[ $(boolean) ]] not [[ $boolean ]]
225 B_ASOUND_CARDS='false'
226 B_ASOUND_VERSION='false'
231 B_MODULES_DIR='false' #
233 B_PARTITIONS_DIR='false' #
235 ### Directory's used when present
236 DIR_CPUINFO='/proc/cpuinfo'
237 DIR_MEMINFO='/proc/meminfo'
238 DIR_ASOUND_DEVICE='/proc/asound/cards'
239 DIR_ASOUND_VERSION='/proc/asound/version'
240 DIR_LSB_RELEASE='/etc/lsb-release'
241 DIR_SCSI='/proc/scsi/scsi'
242 DIR_MODULES='/proc/modules' #
243 DIR_MOUNTS='/proc/mounts'
244 DIR_PARTITIONS='/proc/partitions' #
245 DIR_IFCONFIG='/sbin/ifconfig'
247 ### Variable initializations: constants
249 DEBUG=0 # Set debug levels from 1-10 (8-10 trigger logging levels)
250 # Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up'
252 ## note: the debugger rerouting to /dev/null has been moved to the end of the get_parameters function
253 ## so -@[number] debug levels can be set if there is a failure, otherwise you can't even see the errors
255 # Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Set to any other valid scheme you like.
256 # Same as runtime parameter.
258 # Default indentation level
261 # logging eval variables, start and end function: Insert to LOGFS LOGFE when debug level >= 8
262 LOGFS_STRING='log_function_data fs $FUNCNAME "$( echo $@ )"'
263 LOGFE_STRING='log_function_data fe $FUNCNAME'
266 # uncomment for debugging from script start
267 # LOGFS=$LOGFS_STRING
268 # LOGFE=$LOGFE_STRING
270 # default to false, no konversation found, 1 is native konvi (qt3/KDE3) script mode, 2 is /cmd inxi start,
271 ## 3 is Konversation > 1.2 (qt4/KDE4)
273 # NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
274 # This is a variable that controls how many parameters inxi will parse in a /proc/<pid>/cmdline file before stopping.
276 SCHEME=0 # set default scheme
277 # SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
279 # Verbosity level defaults to 0, this can also be set with -v0, -v2, -v3, etc as a parameter.
281 # Supported number of verbosity levels, including 0
284 # Clear nullglob, because it creates unpredictable situations with IFS=$'\n' ARR=($VAR) IFS="$ORIGINAL_IFS"
285 # type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
286 # therefore results in nothing.
288 ## info on bash built in: $IFS - http://tldp.org/LDP/abs/html/internalvariables.html
289 # Backup the current Internal Field Separator
292 # These two determine separators in single line output, to force irc clients not to break off sections
296 ### Script names/paths - must be non root writable
297 SCRIPT_DATA_DIR="$HOME/.inxi"
298 LOG_FILE="$SCRIPT_DATA_DIR/inxi.log"
299 LOG_FILE_1="$SCRIPT_DATA_DIR/inxi.1.log"
300 LOG_FILE_2="$SCRIPT_DATA_DIR/inxi.2.log"
302 SCRIPT_PATH="" #filled-in in Main
303 SCRIPT_VERSION_NUMBER="" #filled-in in Main
304 SCRIPT_DOWNLOAD='http://inxi.googlecode.com/svn/trunk/'
305 SCRIPT_DOWNLOAD_BRANCH_1='http://inxi.googlecode.com/svn/branches/one/'
306 SCRIPT_DOWNLOAD_BRANCH_2='http://inxi.googlecode.com/svn/branches/two/'
307 SCRIPT_DOWNLOAD_BRANCH_3='http://inxi.googlecode.com/svn/branches/three/'
308 SCRIPT_DOWNLOAD_BRANCH_4='http://inxi.googlecode.com/svn/branches/four/'
309 SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/'
310 KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
312 ### Script Localization
313 # Make sure every program speaks English.
318 # A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below.
320 # DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW
321 ANSI_COLORS="
\e[1;30m
\e[0;30m
\e[1;31m
\e[0;31m
\e[1;32m
\e[0;32m
\e[1;33m
\e[0;33m"
322 IRC_COLORS=" \x0314 \x0301 \x0304 \x0305 \x0309 \x0303 \x0308 \x0307"
323 # BLUE DBLUE MAGENTA DMAGENTA CYAN DCYAN WHITE GREY NORMAL
324 ANSI_COLORS="$ANSI_COLORS
\e[1;34m
\e[0;34m
\e[1;35m
\e[0;35m
\e[1;36m
\e[0;36m
\e[1;37m
\e[0;37m
\e[0;37m"
325 IRC_COLORS=" $IRC_COLORS \x0312 \x0302 \x0313 \x0306 \x0311 \x0310 \x0300 \x0315 \x03"
327 #ANSI_COLORS=($ANSI_COLORS); IRC_COLORS=($IRC_COLORS)
328 A_COLORS_AVAILABLE=( DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW BLUE DBLUE MAGENTA DMAGENTA CYAN DCYAN WHITE GREY NORMAL )
329 # See above for notes on EMPTY
330 A_COLOR_SCHEMES=( EMPTY,EMPTY,EMPTY NORMAL,NORMAL,NORMAL BLUE,NORMAL,NORMAL GREEN,YELLOW,NORMAL DYELLOW,NORMAL,NORMAL CYAN,BLUE,NORMAL RED,NORMAL,NORMAL GREEN,NORMAL,NORMAL YELLOW,NORMAL,NORMAL GREEN,DGREEN,NORMAL BLUE,RED,NORMAL BLUE,NORMAL,RED YELLOW,WHITE,GREEN BLUE,NORMAL,GREEN DCYAN,NORMAL,DMAGENTA )
331 ## Actual color variables
337 # In cases of derived distros where the version file of the base distro can also be found under /etc,
338 # the derived distro's version file should go first. (Such as with Sabayon / Gentoo)
339 DISTROS_DERIVED="antix-version kanotix-version knoppix-version mandrake-release pardus-release sabayon-release sidux-version turbolinux-release zenwalk-version"
340 # debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
341 DISTROS_EXCLUDE_LIST="debian_version ubuntu_version"
342 DISTROS_PRIMARY="gentoo-release redhat-release slackware-version SuSE-release"
343 DISTROS_LSB_GOOD="mandrake-release mandriva-release mandrakelinux-release"
344 ## Distros with known problems
345 # DSL (Bash 2.05b: grep -m doesn't work; arrays won't work) --> unusable output
346 # Puppy Linux 4.1.2 (Bash 3.0: arrays won't work) --> works partially
349 # Precede a banword with $'\2' to prevent it from being subject to automated escaping by the make_ban_lists routine
350 # $'\1' gets weird results :
351 # user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v
352 # 00000000 01 01 6f 6e 65 20 74 77 6f 0a |..one two.|
353 A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\<ltd\>" ltd. $'\2'"\<inc\>" inc. $'\2'\<co\> co. "(tm)" "(r)" "®" $'\2'"\(rev ..\)" )
354 A_CPU_BANS=( @ cpu deca 'dual core' dual-core 'tri core' tri-core 'quad core' quad-core ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
355 # after processing, the ban arrays will be put into these:
359 # WARNING: In the main part below (search for 'KONVI')
360 # there's a check for Konversation-specific config files.
361 # Any one of these can override the above if inxi is run
364 ########################################################################
365 #### MAIN: Where it all begins
366 ########################################################################
371 # This function just initializes variables
372 initialize_script_data
374 # Check for dependencies BEFORE running ANYTHING else except above functions
375 # Not all distro's have these depends installed by default
377 check_script_suggested_apps
379 # first init function must be set first for colors etc. Remember, no debugger
380 # stuff works on this function unless you set the debugging flag manually.
381 # Debugging flag -@ [number] will not work until get_parameters runs.
383 ### Only continue if depends ok
384 SCRIPT_PATH=$( dirname $0 )
385 SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' )
387 ### Source global config overrides
388 if [[ -s /etc/$SCRIPT_NAME.conf ]];then
389 source /etc/$SCRIPT_NAME.conf
391 # Source user config overrides, ~/.inxi/inxi.conf
392 if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then
393 source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf
396 ## this needs to run before the KONVI stuff is set below
397 ## Konversation 1.2 apparently does not like the $PPID test in get_start_client
398 ## So far there is no known way to detect if qt4_konvi is the parent process
399 ## this method will infer qt4_konvi as parent
403 # note: this only works if it's run from inside konversation as a script builtin or something
404 # only do this if inxi has been started as a konversation script, otherwise bypass this
405 # KONVI=3 ## for testing puroses
407 if [[ $KONVI -eq 1 || $KONVI -eq 3 ]];then
409 if [[ $KONVI -eq 1 ]]; then ## dcop Konversation (ie 1.x < 1.2(qt3))
414 elif [[ $KONVI -eq 3 ]]; then ## dbus Konversation (> 1.2 (qt4))
415 DCSERVER="$1" ##dbus testing
416 DCTARGET="$2" ##dbus testing
420 # The section below is on request of Argonel from the Konversation developer team:
421 # it sources config files like $HOME/.kde/share/apps/konversation/scripts/inxi.conf
423 for kde_config in $( kde-config --path data )
425 if [[ -r ${kde_config}${KONVI_CFG} ]];then
426 source "${kde_config}${KONVI_CFG}"
433 ## leave this for debugging dcop stuff if we get that working
434 # print_screen_output "DCPORT: $DCPORT"
435 # print_screen_output "DCSERVER: $DCSERVER"
436 # print_screen_output "DCTARGET: $DCTARGET"
438 # "$@" passes every parameter separately quoted, "$*" passes all parameters as one quoted parameter.
439 # must be here to allow debugger and other flags to be set.
442 # If no colorscheme was set in the parameter handling routine, then set the default scheme
443 if [[ $COLOR_SCHEME_SET != 'true' ]];then
444 set_color_scheme "$DEFAULT_SCHEME"
447 # all the pre-start stuff is in place now
449 script_debugger "Debugger: $SCRIPT_NAME is up and running..."
451 # then create the output
455 if [[ $B_RUNNING_IN_SHELL == 'true' && $SCHEME -gt 0 ]];then
459 # weechat's executor plugin forced me to do this, and rightfully so, because else the exit code
460 # from the last command is taken..
464 #### -------------------------------------------------------------------
465 #### basic tests: set script data, booleans, PATH
466 #### -------------------------------------------------------------------
468 # Set PATH data so we can access all programs as user. Set BAN lists.
469 # initialize some boleans, these directories are used throughout the script
470 # some apps are used for extended functions any directory used, should be
471 # checked here first.
473 initialize_script_data()
476 local path='' sys_path='' added_path='' b_path_found=''
477 # Extra path variable to make execute failures less likely, merged below
478 local extra_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
480 # Fallback paths put into $extra_paths; This might, among others, help on gentoo.
481 # Now, create a difference of $PATH and $extra_paths and add that to $PATH:
483 for path in $extra_paths
486 for sys_path in $PATH
488 if [[ $path == $sys_path ]];then
492 if [[ $b_path_found == 'false' ]];then
493 added_path="$added_path:$path"
498 PATH="${PATH}${added_path}"
499 ##echo "PATH='$PATH'"
500 ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
502 # Do this after sourcing of config overrides so user can customize banwords
503 BAN_LIST_NORMAL=$( make_ban_lists "${A_NORMAL_BANS[@]}" ) # Contrary to my previous belief, "${ARR[@]}" passes a quoted list, not one string
504 BAN_LIST_CPU=$( make_ban_lists "${A_CPU_BANS[@]}" )
505 ##echo "BAN_LIST_NORMAL='$BAN_LIST_NORMAL'"
507 # now set the script BOOLEANS for files required to run features
508 if [[ -d "/proc/" ]];then
514 if [[ -e $DIR_CPUINFO ]]; then
518 if [[ -e $DIR_MEMINFO ]];then
522 if [[ -e $DIR_ASOUND_DEVICE ]];then
523 B_ASOUND_CARDS='true'
526 if [[ -e $DIR_ASOUND_VERSION ]];then
527 B_ASOUND_VERSION='true'
530 if [[ -f $DIR_LSB_RELEASE ]];then
534 if [[ -e $DIR_SCSI ]];then
538 # lack of ifconfig will throw an error only upon it's usage
539 if [[ -x ifconfig ]]; then
541 DIR_IFCONFIG='ifconfig' # change from full path to use $PATH
542 elif [[ -x $DIR_IFCONFIG ]];then
545 A_INTERFACES_DATA=( "Interfaces tool requires missing app: $DIR_IFCONFIG" )
548 if [[ -n $DISPLAY ]];then
552 if [[ -e $DIR_MODULES ]];then
556 if [[ -e $DIR_MOUNTS ]];then
560 if [[ -e $DIR_PARTITIONS ]];then
561 B_PARTITIONS_DIR='true'
563 # gfx output will require this flag
564 if [[ $( whoami ) == 'root' ]];then
571 check_script_suggested_apps()
574 local bash_array_test=( "one" "two" )
576 # check for array ability of bash, this is only good for the warning at this time
577 # the boolean could be used later
578 # bash version 2.05b is used in DSL
579 # bash version 3.0 is used in Puppy Linux; it has a known array bug <reference to be placed here>
580 # versions older than 3.1 don't handle arrays
581 # distro's using below 2.05b are unknown, released in 2002
582 if [[ ${bash_array_test[1]} -eq "two" ]];then
585 script_debugger "Suggestion: update to Bash v3.1 for optimal inxi output"
590 # Determine if any of the absolutely necessary tools are absent
592 check_script_depends()
595 local app_name='' app_data=''
596 # bc removed from deps for now
597 local depends="df free gawk grep hostname lspci ps readlink tr uname uptime wc"
598 local x_apps="xrandr xdpyinfo glxinfo"
600 if [[ $B_X_RUNNING == 'true' ]];then
601 for app_name in $x_apps
603 app_data=$( type -p $app_name )
604 if [[ -z $app_data ]];then
605 script_debugger "Resuming in non X mode: $app_name not found in path"
614 for app_name in $depends
616 app_data=$( type -p $app_name )
617 if [[ -z $app_data ]];then
618 error_handler 5 "$app_name"
624 ## note: this is now running inside each gawk sequence directly to avoid exiting gawk
625 ## looping in bash through arrays, then re-entering gawk to clean up, then writing back to array
626 ## in bash. For now I'll leave this here because there's still some interesting stuff to get re methods
627 # Enforce boilerplate and buzzword filters
628 # args: $1 - BAN_LIST_NORMAL/BAN_LIST_CPU; $2 - string to sanitize
629 sanitize_characters()
632 # Cannot use strong quotes to unquote a string with pipes in it!
633 # bash will interpret the |'s as usual and try to run a subshell!
634 # Using weak quotes instead, or use '"..."'
641 gsub(/ [ ]+/,\" \") ## ([ ]+) with (space)
642 gsub(/^ +| +$/,\"\") ## (pipe char) with (nothing)
643 print ## prints (returns) cleaned input
648 # Filter boilerplate & buzzwords.
649 # args: $1 - quoted: "$@" array of ban terms
655 ## note: this is a weird, non-intuitive method, needs some documentation or rewriting
656 ## if you declare ban_string it stops working, have to read up on this
659 # echo "term=\"$ban_string\"" # >&2
660 if [[ ${ban_string:0:1} = $'\2' ]];then
661 ban_list="${ban_list}${ban_list+|}${ban_string:1:${#ban_string}-1}"
663 # Automatically escapes [ ] ( ) . and +
664 ban_list="${ban_list}${ban_list+|}$( echo "$ban_string" | gawk '{
665 gsub(/([\[\]+().])/,"\\\\&")
674 # make_ban_lists "${A_CPU_BANS[@]}";exit
676 # Set the colorscheme
677 # args: $1 = <scheme number>|<"none">
681 local i='' script_colors='' color_codes=''
683 if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then
686 # Set a global variable to allow checking for chosen scheme later
688 if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
689 color_codes=( $ANSI_COLORS )
691 color_codes=( $IRC_COLORS )
693 for (( i=0; i < ${#A_COLORS_AVAILABLE[@]}; i++ ))
695 eval "${A_COLORS_AVAILABLE[i]}=\"${color_codes[i]}\""
698 script_colors=( ${A_COLOR_SCHEMES[$1]} )
700 # then assign the colors globally
701 C1="${!script_colors[0]}"
702 C2="${!script_colors[1]}"
703 CN="${!script_colors[2]}"
704 # ((COLOR_SCHEME++)) ## note: why is this? ##
708 ########################################################################
709 #### UTILITY FUNCTIONS
710 ########################################################################
712 #### -------------------------------------------------------------------
713 #### error handler, debugger, script updater
714 #### -------------------------------------------------------------------
717 # args: $1 - error number; $2 - optional, extra information
721 local error_message=''
723 # assemble the error message
725 2) error_message="large flood danger, debug buffer full!"
727 3) error_message="unsupported color scheme number: $2"
729 4) error_message="unsupported verbosity level: $2"
731 5) error_message="dependency not met: $2 not found in path"
733 6) error_message="/proc not found! Quitting..."
735 7) error_message="One of the options you entered in your script parameters: $2\nIs not supported. For supported options, check the help menu: $SCRIPT_NAME -h"
737 8) error_message="the self-updater failed, wget exited with error: $2.\nYou probably need to be root.\nHint, to make for easy updates without being root, do: chown <user name> $SCRIPT_PATH/$SCRIPT_NAME"
739 9) error_message="unsupported debugging level: $2"
742 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/"
745 error_message="unsupported testing option argument: -! $2"
748 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."
750 *) error_message="error unknown: $@"
754 # then print it and exit
755 print_screen_output "Error $1: $error_message"
760 # prior to script up set, pack the data into an array
761 # then we'll print it out later.
762 # args: $1 - $@ debugging string text
766 if [[ $B_SCRIPT_UP == 'true' ]];then
767 # only return if debugger is off and no pre start up errors have occured
768 if [[ $DEBUG -eq 0 && $DEBUG_BUFFER_INDEX -eq 0 ]];then
770 # print out the stored debugging information if errors occured
771 elif [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then
772 for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#A_DEBUG_BUFFER[@]}; DEBUG_BUFFER_INDEX++ ))
774 print_screen_output "${A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]}"
778 # or print out normal debugger messages if debugger is on
779 if [[ $DEBUG -gt 0 ]];then
780 print_screen_output "$1"
783 if [[ $B_DEBUG_FLOOD == 'true' && $DEBUG_BUFFER_INDEX -gt 10 ]];then
785 # this case stores the data for later printout, will print out only
786 # at B_SCRIPT_UP == 'true' if array index > 0
788 A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]="$1"
789 # increment count for next pre script up debugging error
790 (( DEBUG_BUFFER_INDEX++ ))
796 # NOTE: no logging available until get_parameters is run, since that's what sets logging
797 # in order to trigger earlier logging manually set B_USE_LOGGING to true in top variables.
798 # $1 alone: logs data; $2 with or without $3 logs func start/end.
799 # $1 type (fs/fe/cat/raw) or logged data; [$2 is $FUNCNAME; [$3 - function args]]
802 if [ "$B_USE_LOGGING" == 'true' ];then
803 local logged_data='' spacer=' ' line='----------------------------------------'
806 logged_data="Function: $2 - Primary: Start"
808 logged_data="$logged_data\n${spacer}Args: $3"
813 logged_data="Function: $2 - Primary: End"
817 if [[ $B_LOG_FULL_DATA == 'true' ]];then
818 logged_data="\n$line\nFull file data: cat $2\n\n$( cat $2 )\n$line\n"
823 if [[ $B_LOG_FULL_DATA == 'true' ]];then
824 logged_data="\n$line\nRaw system data:\n\n$2\n$line\n"
832 # Create any required line breaks and strip out escape color code, either ansi (case 1)or irc (case 2).
833 # This pattern doesn't work for irc colors, if we need that someone can figure it out
834 if [[ -n $logged_data ]];then
835 if [[ $B_LOG_COLORS != 'true' ]];then
836 echo -e "${spacer}$logged_data" | sed -r 's/\x1b\[[0-9]{1,2}(;[0-9]{1,2}){0,2}m//g' >> $LOG_FILE
838 echo -e "${spacer}$logged_data" >> $LOG_FILE
844 # called in the initial -@ 10 script args setting so we can get logging as soon as possible
845 # will have max 3 files, inxi.log, inxi.1.log, inxi.2.log
846 create_rotate_logfiles()
848 if [[ ! -d $SCRIPT_DATA_DIR ]];then
849 mkdir $SCRIPT_DATA_DIR
851 # do the rotation if logfile exists
852 if [[ -f $LOG_FILE ]];then
853 # copy if present second to third
854 if [[ -f $LOG_FILE_1 ]];then
855 mv -f $LOG_FILE_1 $LOG_FILE_2
857 # then copy initial to second
858 mv -f $LOG_FILE $LOG_FILE_1
860 # now create the logfile
862 # and echo the start data
863 echo "=========================================================" >> $LOG_FILE
864 echo "START $SCRIPT_NAME LOGGING:" >> $LOG_FILE
865 echo "Script started: $( date +%Y-%m-%d-%H:%M:%S )" >> $LOG_FILE
866 echo "=========================================================" >> $LOG_FILE
869 # args: $1 - download url, not including file name; $2 - string to print out
870 # note that $1 must end in / to properly construct the url path
871 script_self_updater()
875 print_screen_output "Starting $SCRIPT_NAME self updater."
876 print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
877 print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH using $2 as download source..."
878 # first test if path is good, need to make sure it's good because we're -O overwriting file
879 wget -q --spider $1$SCRIPT_NAME || wget_error=$?
880 # then do the actual download
881 if [[ $wget_error -eq 0 ]];then
882 wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME || wget_error=$?
883 if [[ $wget_error -eq 0 ]];then
884 SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' )
885 print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER"
886 print_screen_output "To run the new version, just start $SCRIPT_NAME again."
890 # now run the error handlers on any wget failure
891 if [[ $wget_error -gt 0 ]];then
892 if [[ $2 == 'svn server' ]];then
893 error_handler 8 "$wget_error"
894 elif [[ $2 == 'alt server' ]];then
895 error_handler 10 "$1"
897 error_handler 12 "$1"
903 #### -------------------------------------------------------------------
904 #### print / output cleaners
905 #### -------------------------------------------------------------------
907 # inxi speaks through here. When run by Konversation script alias mode, uses DCOP
908 # for dcop to work, must use 'say' operator, AND colors must be evaluated by echo -e
909 # note: dcop does not seem able to handle \n so that's being stripped out and replaced with space.
910 print_screen_output()
913 # the double quotes are needed to avoid losing whitespace in data when certain output types are used
914 local print_data="$( echo -e "$1" )"
916 # just using basic debugger stuff so you can tell which thing is printing out the data. This
917 # should help debug kde 4 konvi issues when that is released into sid, we'll see. Turning off
918 # the redundant debugger output which as far as I can tell does exactly nothing to help debugging.
919 if [[ $DEBUG -gt 5 ]];then
920 if [[ $KONVI -eq 1 ]];then
921 # konvi doesn't seem to like \n characters, it just prints them literally
922 # print_data="$( tr '\n' ' ' <<< "$print_data" )"
923 # dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$print_data'"
924 print_data="KP-$KONVI: $print_data"
925 elif [[ $KONVI -eq 2 ]];then
926 # echo "konvi='$KONVI' saying : '$print_data'"
927 print_data="KP-$KONVI: $print_data"
929 # echo "printing out: '$print_data'"
930 print_data="P: $print_data"
934 if [[ $KONVI -eq 1 ]]; then ## dcop Konversation (<= 1.1 (qt3))
935 # konvi doesn't seem to like \n characters, it just prints them literally
936 $print_data="$( tr '\n' ' ' <<< "$print_data" )"
937 dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "$print_data"
939 elif [[ $KONVI -eq 3 ]]; then ## dbus Konversation (> 1.2 (qt4))
940 qdbus org.kde.konversation /irc say "$DCSERVER" "$DCTARGET" "$print_data"
942 # elif [[ $IRC_CLIENT == 'X-Chat' ]]; then
943 # qdbus org.xchat.service print "$print_data\n"
946 # the -n is needed to avoid double spacing of output in terminal
947 echo -ne "$print_data\n"
952 ## this handles all verbose line construction with indentation/line starter
953 ## args: $1 - null (, actually: " ") or line starter; $2 - line content
957 printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2"
961 # this removes newline and pipes.
962 # args: $1 - string to clean
963 remove_erroneous_chars()
966 ## RS is input record separator
967 ## gsub is substitute;
973 gsub(/\n$/,"") ## (newline; end of string) with (nothing)
974 gsub(/\n/," "); ## (newline) with (space)
975 gsub(/^ *| *$/, "") ## (pipe char) with (nothing)
976 gsub(/ +/, " ") ## ( +) with (space)
977 gsub(/ [ ]+/, " ") ## ([ ]+) with (space)
978 gsub(/^ +| +$/, "") ## (pipe char) with (nothing)
980 }' "$1" ## prints (returns) cleaned input
984 #### -------------------------------------------------------------------
985 #### parameter handling, print usage functions.
986 #### -------------------------------------------------------------------
988 # Get the parameters. Note: standard options should be lower case, advanced or testing, upper
989 # args: $1 - full script startup args: $@
993 local opt='' wget_test='' update_flags='U!:'
994 local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
996 # <comment here. what is this for?>
997 if [[ $B_ALLOW_UPDATE == 'false' ]];then
1001 # the short form only runs if no args output args are used
1002 # no need to run through these if there are no args
1004 while getopts Ac:CdDfFGhHiIlNpPSuv:Vx%@:${update_flags} opt
1007 A) B_SHOW_AUDIO='true'
1010 c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
1011 COLOR_SCHEME_SET='true'
1012 ## note: not sure about this, you'd think user values should be overridden, but
1013 ## we'll leave this for now
1014 if [[ -z $COLOR_SCHEME ]];then
1015 set_color_scheme "$OPTARG"
1018 error_handler 3 "$OPTARG"
1021 C) B_SHOW_CPU='true'
1024 d) VERBOSITY_LEVEL=1
1027 D) B_SHOW_DISK='true'
1030 f) B_SHOW_CPU='true'
1031 B_CPU_FLAGS_FULL='true'
1034 F) VERBOSITY_LEVEL=$VERBOSITY_LEVELS
1037 B_SHOW_PARTITIONS='true'
1041 G) B_SHOW_GRAPHICS='true'
1045 B_SHOW_NETWORK='true'
1048 I) B_SHOW_INFO='true'
1051 l) B_SHOW_LABELS='true'
1052 B_SHOW_PARTITIONS='true'
1055 N) B_SHOW_NETWORK='true'
1058 p) B_SHOW_PARTITIONS_FULL='true'
1059 B_SHOW_PARTITIONS='true'
1062 P) B_SHOW_PARTITIONS='true'
1065 S) B_SHOW_SYSTEM='true'
1068 u) B_SHOW_UUIDS='true'
1069 B_SHOW_PARTITIONS='true'
1072 v) if [[ -n $( egrep "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then
1073 VERBOSITY_LEVEL="$OPTARG"
1074 if [[ $OPTARG -gt 0 ]];then
1078 error_handler 4 "$OPTARG"
1081 U) script_self_updater "$SCRIPT_DOWNLOAD" 'svn server'
1083 V) print_version_info
1086 x) B_EXTRA_DATA='true'
1091 H) show_options 'full'
1094 ## debuggers and testing tools
1095 %) B_HANDLE_CORRUPT_DATA='true'
1097 @) if [[ -n $( egrep "^([1-9]|10)$" <<< $OPTARG ) ]];then
1100 # switch on logging only for -@ 8-10
1101 if [[ $OPTARG -ge 8 ]];then
1102 if [[ $OPTARG -eq 10 ]];then
1104 elif [[ $OPTARG -eq 9 ]];then
1105 B_LOG_FULL_DATA='true'
1107 B_USE_LOGGING='true'
1108 # pack the logging data for evals function start/end
1111 create_rotate_logfiles # create/rotate logfiles before we do anything else
1114 error_handler 9 "$OPTARG"
1117 !) # test for various supported methods
1119 1) B_TESTING_1='true'
1121 2) B_TESTING_2='true'
1123 3) B_TESTING_1='true'
1127 script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server'
1130 script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server'
1133 script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server'
1136 script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'svn: branch three server'
1139 script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server'
1142 script_self_updater "$OPTARG" 'alt server'
1144 *) error_handler 11 "$OPTARG"
1148 *) error_handler 7 "$1"
1153 ## this must occur here so you can use the debugging flag to show errors
1154 ## Reroute all error messages to the bitbucket (if not debugging)
1155 if [[ $DEBUG -eq 0 ]];then
1158 #((DEBUG)) && exec 2>&1 # This is for debugging konversation
1160 # after all the args have been processed, if no long output args used, run short output
1161 if [[ $use_short == 'true' ]];then
1162 B_SHOW_SHORT_OUTPUT='true'
1167 ## print out help menu, not including Testing or Debugger stuff because it's not needed
1170 local color_scheme_count=${#A_COLOR_SCHEMES[@]}
1172 print_screen_output "$SCRIPT_NAME supports the following options. You can combine them, or list them"
1173 print_screen_output "one by one: Examples: $SCRIPT_NAME -v4 -c6 OR $SCRIPT_NAME -dDc 6"
1174 print_screen_output ""
1175 print_screen_output "If you start $SCRIPT_NAME with no arguments, it will show the short form."
1176 print_screen_output "The following options if used without -d or -v will show just that complete line:"
1177 print_screen_output "A,C,D,G,I,N,P,S - you can use these together to show just the lines you want to see."
1178 print_screen_output "If you use them with a -v level (or -d), it will show the full output for that line "
1179 print_screen_output "along with the output for the chosen verbosity level."
1180 print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
1181 print_screen_output "Output Control Options:"
1182 print_screen_output "-A Show Audio/sound card information."
1183 print_screen_output "-c Available color schemes. Scheme number is required."
1184 print_screen_output " Supported schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11"
1185 print_screen_output "-C Show full CPU output, including per CPU clockspeed."
1186 print_screen_output "-d Default output verbosity level, same as: $SCRIPT_NAME -v 1"
1187 print_screen_output "-D Show full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB."
1188 print_screen_output "-f Show all cpu flags used, not just the short list. Not shown with -F to avoid spamming."
1189 print_screen_output "-F Show Full output for $SCRIPT_NAME. Does not show extra verbose options like -f -u -l or -p"
1190 print_screen_output "-G Show Graphic card information (card, x type, resolution, glx renderer, version)."
1191 print_screen_output "-i Show Wan IP address, and shows local interfaces (requires ifconfig network tool)."
1192 print_screen_output " Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
1193 print_screen_output "-I Show Information: processes, uptime, memory, irc client, inxi version."
1194 print_screen_output "-l Show partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu)."
1195 print_screen_output "-N Show Network card information."
1196 print_screen_output "-p Show full partition information (-P plus all other detected partitions)."
1197 print_screen_output "-P Show Partition information (shows what -v 4 would show, but without extra data)."
1198 print_screen_output " Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted partitions."
1199 print_screen_output "-S Show System information: host name, kernel, distro"
1200 print_screen_output "-u Show partition UUIDs. Default: short partition -P. For full -p output, use: -pu (or -plu)."
1201 print_screen_output "-v Script verbosity levels. Verbosity level number is required."
1202 print_screen_output " Supported levels: 0-${VERBOSITY_LEVELS} Example: $SCRIPT_NAME -v 4"
1203 print_screen_output " 0 - short output, same as: $SCRIPT_NAME"
1204 print_screen_output " 1 - basic verbose, same as: $SCRIPT_NAME -d"
1205 print_screen_output " 2 - Also show networking card data"
1206 print_screen_output " 3 - Also show hard disk names as detected."
1207 print_screen_output " 4 - Also show partition size/filled data for (if present):/, /home, /var/, /boot"
1208 print_screen_output " 5 - For multicore systems, also show per core clock speeds; shows audio card."
1209 print_screen_output "-x Show extra data: bogomips on Cpu; driver version (if available) for Network/Audio;"
1210 print_screen_output " direct rendering status for Graphics (in X). Only works with verbose or line output."
1211 print_screen_output ""
1212 print_screen_output "Additional Options:"
1213 print_screen_output "-h - this help menu."
1214 if [[ $B_ALLOW_UPDATE == 'true' ]];then
1215 print_screen_output "-U Auto-update script. Note: if you installed as root, you"
1216 print_screen_output " must be root to update, otherwise user is fine."
1218 print_screen_output "-V $SCRIPT_NAME version information. Prints information then exits."
1219 print_screen_output "-% Overrides defective or corrupted data."
1220 print_screen_output "-@ Triggers debugger output. Requires debugging level 1-10 (8-10 - logging)."
1221 print_screen_output " 8 - basic logging; 9 - full file/sys info logging; 10 - color logging."
1222 if [[ $1 == 'full' ]];then
1223 print_screen_output ""
1224 print_screen_output "Developer and Testing Options (Advanced):"
1225 print_screen_output "-! 1 - Sets testing flag B_TESTING_1='true' to trigger testing condition 1."
1226 print_screen_output "-! 2 - Sets testing flag B_TESTING_2='true' to trigger testing condition 2."
1227 print_screen_output "-! 3 - Sets flags B_TESTING_1='true' and B_TESTING_2='true'."
1228 print_screen_output "-! 10 - Triggers an update from the primary dev download server instead of svn."
1229 print_screen_output "-! 11 - Triggers an update from svn branch one - if present, of course."
1230 print_screen_output "-! 12 - Triggers an update from svn branch two - if present, of course."
1231 print_screen_output "-! 13 - Triggers an update from svn branch three - if present, of course."
1232 print_screen_output "-! 14 - Triggers an update from svn branch four - if present, of course."
1233 print_screen_output "-! <http://......> - Triggers an update from whatever server you list."
1234 print_screen_output ""
1236 print_screen_output ""
1239 ## print out version information for -V/--version
1240 print_version_info()
1242 local last_modified=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3,$4,$5}' )
1244 print_screen_output "$SCRIPT_NAME - the universal, portable, system info script for irc."
1245 print_screen_output "Version: $SCRIPT_VERSION_NUMBER"
1246 print_screen_output "Script Last Modified: $last_modified"
1247 print_screen_output "Script Location: $SCRIPT_PATH"
1248 print_screen_output ""
1249 print_screen_output "Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,"
1250 print_screen_output "Gaim/Pidgin, Weechat, KVIrc and Kopete."
1251 print_screen_output ""
1252 print_screen_output "This script is a fork of Infobash 3.02, which is:"
1253 print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
1254 print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:"
1255 print_screen_output "Copyright (C) 2008-9 Scott Rogers, Harald Hope, aka trash80 & h2"
1256 print_screen_output ""
1257 print_screen_output "This program is free software; you can redistribute it and/or modify"
1258 print_screen_output "it under the terms of the GNU General Public License as published by"
1259 print_screen_output "the Free Software Foundation; either version 3 of the License, or"
1260 print_screen_output "(at your option) any later version."
1263 ########################################################################
1265 ########################################################################
1267 #### -------------------------------------------------------------------
1268 #### initial startup stuff
1269 #### -------------------------------------------------------------------
1271 # Determine where inxi was run from, set IRC_CLIENT and IRC_CLIENT_VERSION
1275 local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
1276 local b_non_native_app='false' pppid='' app_working_name=''
1277 local b_qt4_konvi='false'
1279 if tty >/dev/null;then
1281 unset IRC_CLIENT_VERSION
1282 B_RUNNING_IN_SHELL='true'
1283 elif [[ -n $PPID && -f /proc/$PPID/exe ]];then
1284 irc_client_path=$( readlink /proc/$PPID/exe )
1285 irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )
1286 app_working_name=$( basename $irc_client_path_lower )
1287 # handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where clients
1288 # report themselves as perl or unknown shell. IE: when konversation starts inxi
1289 # from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc
1290 # note: perl can report as: perl5.10.0, so it needs wildcard handling
1291 case $app_working_name in
1292 bash|dash|sh|perl*) # We want to know who wrapped it into the shell or perl.
1293 pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )"
1294 if [[ -n $pppid && -f /proc/$pppid/exe ]];then
1295 irc_client_path="$( readlink /proc/$pppid/exe )"
1296 irc_client_path_lower="$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )"
1297 app_working_name=$( basename $irc_client_path_lower )
1298 b_non_native_app='true'
1302 # replacing loose detection with tight detection, bugs will be handled with app names
1304 case $app_working_name in
1305 # check for shell first
1307 unset IRC_CLIENT_VERSION
1308 IRC_CLIENT="Shell wrapper"
1310 # now start on irc clients, alphabetically
1312 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
1315 gsub(/[()]|bitchx-/,"",a)
1328 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1334 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1340 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1346 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1351 konversation) ## konvi < 1.2 (qt4)
1352 # this is necessary to avoid the dcop errors from starting inxi as a /cmd started script
1353 if [[ $b_non_native_app == 'true' ]];then ## true negative is confusing
1355 else # if native app
1358 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
1360 for ( i=2; i<=NF; i++ ) {
1371 T=($IRC_CLIENT_VERSION)
1372 if [[ ${T[0]} == *+* ]];then
1373 # < Sho_> locsmif: The version numbers of SVN versions look like this:
1374 # "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ...
1375 # for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1"
1376 IRC_CLIENT_VERSION=" CVS $IRC_CLIENT_VERSION"
1379 IRC_CLIENT_VERSION=" ${T[0]}"
1382 # Remove any dots except the first, and make sure there are no trailing zeroes,
1383 T2=$( echo "$T2" | gawk '{
1389 # Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc
1390 # becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller
1391 # than 1 and change the DCOP parameter/object accordingly.
1392 if [[ ${T2} -lt 1 ]];then
1393 DCOPOBJ="Konversation"
1395 IRC_CLIENT="Konversation"
1398 IRC_CLIENT_VERSION=" $( kopete -v | gawk '
1406 IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '{
1407 for ( i=2; i<=NF; i++) {
1420 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1426 # sample: quassel -v
1428 # KDE: 4.2.65 (KDE 4.2.65 (KDE 4.3 >= 20090226))
1429 # Quassel IRC: v0.4.0 [+60] (git-22effe5)
1430 # note: early < 0.4.1 quassels do not have -v
1431 IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>/dev/null | gawk -F ': ' '
1440 # this handles pre 0.4.1 cases with no -v
1441 if ( clientVersion == "" ) {
1442 clientVersion = "(pre v0.4.1)"
1446 # now handle primary, client, and core. quasselcore doesn't actually
1447 # handle scripts with exec, but it's here just to be complete
1448 case $app_working_name in
1450 IRC_CLIENT="Quassel [M]"
1453 IRC_CLIENT="Quassel"
1456 IRC_CLIENT="Quassel (core)"
1461 IRC_CLIENT_VERSION=" $( $irc_client_path -v ) "
1462 IRC_CLIENT="Weechat"
1465 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1468 IRC_CLIENT="X-Chat-Gnome"
1471 IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 {
1476 # then do some perl type searches, do this last since it's a wildcard search
1478 unset IRC_CLIENT_VERSION
1479 # KSirc is one of the possibilities now. KSirc is a wrapper around dsirc, a perl client
1481 for (( i=0; i <= $CMDL_MAX; i++ ))
1483 case ${A_CMDL[i]} in
1486 # Dynamic runpath detection is too complex with KSirc, because KSirc is started from
1487 # kdeinit. /proc/<pid of the grandparent of this process>/exe is a link to /usr/bin/kdeinit
1488 # with one parameter which contains parameters separated by spaces(??), first param being KSirc.
1489 # Then, KSirc runs dsirc as the perl irc script and wraps around it. When /exec is executed,
1490 # dsirc is the program that runs inxi, therefore that is the parent process that we see.
1491 # You can imagine how hosed I am if I try to make inxi find out dynamically with which path
1492 # KSirc was run by browsing up the process tree in /proc. That alone is straightjacket material.
1493 # (KSirc sucks anyway ;)
1494 IRC_CLIENT_VERSION=" $( ksirc -v | gawk '
1503 if [[ -z $IRC_CLIENT_VERSION ]];then
1504 IRC_CLIENT="Unknown Perl client"
1507 # then unset, set unknown data
1509 IRC_CLIENT="Unknown : ${irc_client_path##*/}"
1510 unset IRC_CLIENT_VERSION
1513 if [[ $SHOW_IRC -lt 2 ]];then
1514 unset IRC_CLIENT_VERSION
1517 ## lets look to see if qt4_konvi is the parent. There is no direct way to tell, so lets infer it.
1518 ## because $PPID does not work with qt4_konvi, the above case does not work
1519 b_qt4_konvi=$( is_this_qt4_konvi )
1520 if [[ $b_qt4_konvi == 'true' ]];then
1522 IRC_CLIENT='Konversation'
1523 IRC_CLIENT_VERSION=" $( konversation -v | gawk '
1525 for ( i=2; i<=NF; i++ ) {
1536 IRC_CLIENT="PPID=\"$PPID\" - empty?"
1537 unset IRC_CLIENT_VERSION
1540 log_function_data "IRC_CLIENT: $IRC_CLIENT :: IRC_CLIENT_VERSION: $IRC_CLIENT_VERSION :: PPID: $PPID"
1544 ## try to infer the use of Konversation >= 1.2, which shows $PPID improperly
1545 ## no known method of finding Kovni >= 1.2 as parent process, so we look to see if it is running,
1546 ## and all other irc clients are not running.
1549 local konvi_qt4_client='' konvi_dbus_exist='' konvi_pid='' konvi_home_dir=''
1550 local konvi='' konvi_qt4_ver='' b_is_qt4=''
1552 konvi_dbus_exist=$( qdbus | grep "org.kde.konversation" )
1554 if [[ -n $konvi_dbus_exist && -e /usr/share/kde4/apps/konversation ]]; then
1556 konvi_pid=$( ps -A | grep -i 'konversation' )
1557 konvi_pid=$( echo $konvi_pid | gawk '{ print $1 }' )
1559 konvi_home_dir=$( readlink /proc/$konvi_pid/exe )
1560 konvi=$( echo $konvi_home_dir | sed "s/\// /g" )
1563 if [[ ${konvi[2]} == 'konversation' ]];then
1564 konvi_qt4_ver=$( konversation -v | grep -i 'konversation' )
1565 konvi_qt4_client=$( echo "$konvi_qt4_ver" | gawk '{ print $2 }' )
1567 if [[ $konvi_qt4_client > 1.1 ]]; then
1577 ## for testing this module
1578 #qdbus org.kde.konversation /irc say $1 $2 "getpid_dir: $konvi_qt4 qt4_konvi: $konvi_qt4_ver verNum: $konvi_qt4_ver_num pid: $konvi_pid ppid: $PPID konvi_home_dir: ${konvi[2]}"
1581 # This needs some cleanup and comments, not quite understanding what is happening, although generally output is known
1582 # Parse the null separated commandline under /proc/<pid passed in $1>/cmdline
1589 if [[ ! -e /proc/$ppid/cmdline ]];then
1593 ##print_screen_output "Marker"
1594 ##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
1596 ## note: need to figure this one out, and ideally clean it up and make it readable
1597 while read -d $'\0' L && [[ $i -lt 32 ]]
1599 A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
1600 done < /proc/$ppid/cmdline
1601 ##print_screen_output "\$i='$i'"
1602 if [[ $i -eq 0 ]];then
1603 A_CMDL[0]=$(< /proc/$ppid/cmdline)
1604 if [[ -n ${A_CMDL[0]} ]];then
1609 log_function_data "CMDL_MAX: $CMDL_MAX"
1613 #### -------------------------------------------------------------------
1615 #### -------------------------------------------------------------------
1616 ## create array of sound cards installed on system, and if found, use asound data as well
1620 local i='' alsa_data='' alsa_driver='' device_count=''
1621 local usb_proc_file='' array_count='' usb_id='' usb_data=''
1624 # this first step handles the drivers for cases where the second step fails to find one
1625 device_count=$( echo "$Lspci_Data" | egrep -ic '(multimedia audio controller|audio device)' )
1626 if [[ $device_count -eq 1 ]] && [[ $B_ASOUND_CARDS == 'true' ]];then
1627 alsa_driver=$( gawk -F ']: ' '
1631 # filtering out modems and usb devices like webcams, this might get a
1632 # usb audio card as well, this will take some trial and error
1633 $0 !~ /modem/ || $0 !~ /usb/ {
1634 driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
1635 gsub(/^ +| +$/,"",driver)
1636 if ( driver != "" ){
1639 }' $DIR_ASOUND_DEVICE )
1640 log_function_data 'cat' "$DIR_ASOUND_DEVICE"
1643 # this is to safeguard against line breaks from results > 1, which if inserted into following
1644 # array will create a false array entry. This is a hack, not a permanent solution.
1645 alsa_driver=$( echo $alsa_driver )
1646 # now we'll build the main audio data, card name, driver, and port. If no driver is found,
1647 # and if the first method above is not null, and one card is found, it will use that instead.
1648 A_AUDIO_DATA=( $( echo "$Lspci_Data" | gawk -F ': ' -v alsaDriver="$alsa_driver" '
1652 /multimedia audio controller|audio device/ {
1653 audioCard=gensub(/^[0-9a-f:.]+ [^:]+: (.+)$/,"\\1","g",$0)
1654 # The doublequotes are necessary because of the pipes in the variable.
1655 gsub(/'"$BAN_LIST_NORMAL"'/, "", audioCard)
1656 gsub(/,/, " ", audioCard)
1657 gsub(/^ +| +$/, "", audioCard)
1658 gsub(/ [ \t]+/, " ", audioCard)
1662 # loop until you get to the end of the data block
1663 while (getline && !/^$/) {
1664 if (/driver in use/) {
1665 drivers[audioCard] = drivers[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) ""
1667 else if (/kernel modules:/) {
1668 modules[audioCard] = modules[audioCard] gensub(/(.*): (.*)/,"\\2","g",$0) ""
1671 portsTemp = gensub(/\t*I\/O ports at (.*) \[.*\]/,"\\1","g",$0)
1672 ports[audioCard] = ports[audioCard] portsTemp " "
1685 if (drivers[i] != "") {
1686 useDrivers=drivers[i]
1688 if (ports[i] != "") {
1691 if (modules[i] != "" ) {
1692 useModules = modules[i]
1697 # little trick here to try to catch the driver if there is
1698 # only one card and it was null, from the first test of asound/cards
1699 if (drivers[i] != "") {
1700 useDrivers=drivers[i]
1702 else if ( alsaDriver != "" ) {
1703 useDrivers=alsaDriver
1705 if (ports[i] != "") {
1708 if (modules[i] != "" ) {
1709 useModules = modules[i]
1712 # create array primary item for master array
1713 print a[j] "," useDrivers "," usePorts "," useModules
1718 # in case of failure of first check do this instead
1719 if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]] && [[ $B_ASOUND_CARDS == 'true' ]];then
1720 A_AUDIO_DATA=( $( gawk -F ']: ' '
1724 $1 !~ /modem/ && $2 !~ /modem/ {
1725 card=gensub( /^(.+)( - )(.+)$/, "\\3", 1, $2 )
1726 driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
1730 }' $DIR_ASOUND_DEVICE ) )
1733 # alsa usb detection by damentz
1734 # for every sound card symlink in /proc/asound - display information about it
1735 for usb_proc_file in /proc/asound/*
1737 # if lsusb exists, the file is a symlink, and contains an important usb exclusive file: continue
1738 if [[ -n $( which lsusb ) && -L $usb_proc_file && -e $usb_proc_file/usbid ]]; then
1739 # send error messages of lsusb to /dev/null as it will display a bunch if not a super user
1740 # also, find the contents of usbid in lsusb and print everything after the 7th word on the
1741 # corresponding line. Finally, strip out commas as they will change the driver :)
1742 usb_id=$( cat $usb_proc_file/usbid )
1743 usb_data=$( lsusb -v 2>/dev/null | grep "$usb_id" )
1744 log_function_data 'raw' "usb_data:\n$usb_data"
1746 gsub( /,/, " ", $0 )
1747 for( i=7; i <= NF; i++ ) {
1750 }' <<< "$usb_data" )
1751 # this method is interesting, it shouldn't work but it does
1752 #A_AUDIO_DATA=( "${A_AUDIO_DATA[@]}" "$usb_data,snd-usb-audio,," )
1753 # but until we learn why the above worked, I'm using this one, which is safer
1754 if [[ -n $usb_data ]];then
1755 array_count=${#A_AUDIO_DATA[@]}
1756 A_AUDIO_DATA[$array_count]="$usb_data,snd-usb-audio,,"
1762 # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
1763 if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]];then
1764 A_AUDIO_DATA[0]='Failed to Detect Sound Card!'
1766 log_function_data "A_AUDIO_DATA: ${A_AUDIO_DATA[@]}"
1770 get_audio_alsa_data()
1775 # now we'll get the alsa data if the file exists
1776 if [[ $B_ASOUND_VERSION == 'true' ]];then
1781 # some alsa strings have the build date in (...)
1782 # remove trailing . and remove possible second line if compiled by user
1784 gsub( "Driver | [(].*[)]|\.$","",$0 )
1786 gsub(/^ +| +$/, "", $0)
1787 gsub(/ [ \t]+/, " ", $0)
1791 }' $DIR_ASOUND_VERSION )
1792 log_function_data 'cat' "$DIR_ASOUND_VERSION"
1795 log_function_data "alsa_data: $alsa_data"
1799 ## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text
1800 ## return value cpu core count string, this helps resolve the multi redundant lines of old style output
1801 get_cpu_core_count()
1804 if [[ $B_CPUINFO == 'true' ]]; then
1805 # load the A_CPU_TYPE_PCNT_CCNT core data array
1806 get_cpu_ht_multicore_smp_data
1807 ## Because of the upcoming release of cpus with core counts over 6, a count of cores is given after Deca (10)
1808 # count the number of processors given
1809 local cpu_physical_count=${A_CPU_TYPE_PCNT_CCNT[1]}
1810 local cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]}
1811 local cpu_type=${A_CPU_TYPE_PCNT_CCNT[0]}
1813 # match the numberic value to an alpha value
1814 case $cpu_core_count in
1815 1) cpu_alpha_count='Single';;
1816 2) cpu_alpha_count='Dual';;
1817 3) cpu_alpha_count='Triple';;
1818 4) cpu_alpha_count='Quad';;
1819 5) cpu_alpha_count='Penta';;
1820 6) cpu_alpha_count='Hexa';;
1821 7) cpu_alpha_count='Hepta';;
1822 8) cpu_alpha_count='Octa';;
1823 9) cpu_alpha_count='Ennea';;
1824 10) cpu_alpha_count='Deca';;
1825 *) cpu_alpha_count='Multi';;
1827 # create array, core count integer; core count string
1828 # A_CPU_CORE_DATA=( "$cpu_core_count" "$cpu_alpha_count Core$cpu_type" )
1829 A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" )
1831 log_function_data "A_CPU_CORE_DATA: ${A_CPU_CORE_DATA[@]}"
1835 ## main cpu data collector
1839 local i='' j='' cpu_array_nu='' a_cpu_working='' multi_cpu='' bits=''
1841 if [[ $B_CPUINFO == 'true' ]];then
1843 A_CPU_DATA=( $( gawk -F': ' '
1847 # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+
1848 # TAKE NOTE: \t+ will work for $DIR_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
1849 # Therefore PATCH to use [ \t]+ when TESTING!
1850 /^processor[ \t]+:/ {
1854 /^model name|^cpu\t+:/ {
1855 gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
1856 gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
1858 gsub(/^ +| +$/, "", $NF)
1859 gsub(/ [ \t]+/, " ", $NF)
1860 cpu[nr, "model"] = $NF
1863 /^cpu MHz|^clock\t+:/ {
1876 gsub(/MHZ/,"",$NF) ## clears out for cell cpu
1877 gsub(/.00[0]+$/,".00",$NF) ## clears out excessive zeros
1878 cpu[nr, "speed"] = $NF
1882 cpu[nr, "cache"] = $NF
1886 cpu[nr, "flags"] = $NF
1890 cpu[nr, "bogomips"] = $NF
1894 gsub(/genuine|authentic/,"",$NF)
1895 cpu[nr, "vendor"] = tolower( $NF )
1899 #if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
1900 for ( i = 0; i <= nr; i++ ) {
1901 print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
1908 printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
1911 printf("%s %s\n", max, "Mhz")
1914 log_function_data 'cat' "$DIR_CPUINFO"
1918 log_function_data "A_CPU_DATA: ${A_CPU_DATA[@]}"
1920 # echo getMainCpu: ${[@]}
1923 ## this is for counting processors and finding HT types
1924 get_cpu_ht_multicore_smp_data()
1929 # if > 1 processor && processor id (physical id) == core id then Hyperthreaded (HT)
1930 # if > 1 processor && different processor ids then Multiple Processors (SMP)
1931 # if > 1 processor && processor id != core id then Multi-Core Processors (MCP)
1932 # if = 1 processor then single core/processor Uni-Processor (UP)
1934 if [[ $B_CPUINFO == 'true' ]]; then
1935 A_CPU_TYPE_PCNT_CCNT=( $(
1944 physical_cpu_count = 0
1945 processor_logical_count = 0
1949 # counts logical processors, both HT and physical
1951 processor_logical_count = $NF + 1
1953 # counts physical cores (not used currently)
1957 # array of physical cpus ids
1959 a_physical_id[i] = $NF
1967 # look for the largest id number, and assign it
1968 for ( j = 0; j < processor_logical_count; j++ ) {
1969 if ( a_core_id[j] > core_count ) {
1970 core_count = a_core_id[j]
1973 core_count = core_count + 1
1974 # trick, set the index equal to value, if the same, it will overwrite
1975 # this lets us create the actual array of true cpu physical ids
1976 for ( j in a_physical_id ) {
1977 index_temp = a_physical_id[j]
1978 a_cpu_physical_working[index_temp] = a_physical_id[j]
1980 # note that length() is a gawk >= 3.1.5 only method, better to do it manually
1981 for ( j in a_cpu_physical_working ) {
1982 ++physical_cpu_count
1985 # looking at logical processor counts over 1, which means either HT, SMP or MCP
1986 # http://en.wikipedia.org/wiki/Symmetric_multiprocessing
1987 if ( processor_logical_count > 1 ) {
1988 if ( processor_logical_count > core_count && physical_cpu_count > 1 ) {
1989 type = "SMP-HT" # could be Xeon/P4 HT dual cpu
1991 else if ( processor_logical_count > core_count ) {
1992 type = "HT" # this is more than likely a P4 w/HT or an Atom 270
1998 # make sure to handle up cpus too
2001 physical_cpu_count = 1
2003 print type " " physical_cpu_count " " core_count
2007 log_function_data "A_CPU_TYPE_PCNT_CCNT: ${A_CPU_TYPE_PCNT_CCNT[@]}"
2011 # for more on distro id, please reference this python thread: http://bugs.python.org/issue1322
2012 ## return distro name/id if found
2016 local i='' j='' distro='' distro_file='' a_distro_glob=''
2018 # get the wild carded array of release/version /etc files if present
2021 a_distro_glob=(*[-_]{release,version})
2025 if [[ ${#a_distro_glob[@]} -eq 1 ]];then
2026 distro_file="${a_distro_glob}"
2027 # use the file if it's in the known good lists
2028 elif [[ ${#a_distro_glob[@]} -gt 1 ]];then
2029 for i in $DISTROS_DERIVED $DISTROS_PRIMARY
2031 # Only echo works with ${var[@]}, not print_screen_output() or script_debugger()
2032 # This is a known bug, search for the word "strange" inside comments
2033 # echo "i='$i' a_distro_glob[@]='${a_distro_glob[@]}'"
2034 if [[ " ${a_distro_glob[@]} " == *" $i "* ]];then
2035 # Now lets see if the distro file is in the known-good working-lsb-list
2036 # if so, use lsb-release, if not, then just use the found file
2037 # this is for only those distro's with self named release/version files
2038 # because Mint does not use such, it must be done as below
2039 ## this if statement requires the spaces and * as it is, else it won't work
2041 if [[ " $DISTROS_LSB_GOOD " == *" ${i} "* ]] && [[ $B_LSB_DIR == 'true' ]];then
2042 distro_file='lsb-release'
2050 log_function_data "distro_file: $distro_file"
2051 # first test for the legacy antiX distro id file
2052 if [[ -e /etc/antiX ]];then
2053 distro="$( egrep -oi 'antix.*\.iso' <<< $( remove_erroneous_chars '/etc/antiX' ) | sed 's/\.iso//' )"
2054 # this handles case where only one release/version file was found, and it's lsb-release. This would
2055 # never apply for ubuntu or debian, which will filter down to the following conditions. In general
2056 # if there's a specific distro release file available, that's to be preferred, but this is a good backup.
2057 elif [[ -n $distro_file && -f $DIR_LSB_RELEASE && " $DISTROS_LSB_GOOD" == *" $distro_file "* ]];then
2058 distro=$( get_distro_lsb_data )
2059 elif [[ $distro_file == 'lsb-release' ]];then
2060 distro=$( get_distro_lsb_data )
2061 # then if the distro id file was found and it's not in the exluded primary distro file list, read it
2062 elif [[ -n $distro_file && -s /etc/$distro_file && " $DISTROS_EXCLUDE_LIST " != *" $distro_file "* ]];then
2063 distro=$( remove_erroneous_chars "/etc/$distro_file" )
2064 # otherwise try the default debian/ubuntu /etc/issue file
2065 elif [[ -f /etc/issue ]];then
2066 # lsb gives more manageable and accurate output than issue, but mint should use issue for now
2067 # some bashism, boolean must be in parenthesis to work correctly, ie [[ $(boolean) ]] not [[ $boolean ]]
2068 if [[ $B_LSB_DIR == 'true' ]] && [[ -z $( grep -i 'mint' /etc/issue ) ]];then
2069 distro=$( get_distro_lsb_data )
2079 gsub(/ [ \t]+/, " ")
2085 if [[ ${#distro} -gt 80 ]] && [[ $B_HANDLE_CORRUPT_DATA != 'true' ]];then
2086 distro="${RED}/etc/${distro_file} corrupted, use -% to override${NORMAL}"
2088 ## note: would like to actually understand the method even if it's not used
2089 # : ${distro:=Unknown distro o_O}
2090 ## test for /etc/lsb-release as a backup in case of failure, in cases where > one version/release file
2091 ## were found but the above resulted in null distro value
2092 if [[ -z $distro ]] && [[ $B_LSB_DIR == 'true' ]];then
2093 distro=$( get_distro_lsb_data )
2095 ## finally, if all else has failed, give up
2096 if [[ -z $distro ]];then
2097 distro='Unknown distro o_O'
2100 # this handles an arch bug where /etc/arch-release is empty and /etc/issue is corrupted
2101 if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then
2106 log_function_data "distro: $distro"
2110 # args: $1 - optional, app, uses the app test, not being used now
2111 get_distro_lsb_data()
2116 if [[ $B_LSB_DIR == 'true' ]] && [[ $1 != 'app' ]];then
2117 distro=$( gawk -F '=' '
2121 # note: adding the spacing directly to variable to make sure distro output is null if not found
2123 gsub(/^ +| +$/, "", $NF)
2124 # this is needed because grep for "arch" is too loose to be safe
2125 if ( $NF == "arch" ) {
2126 distroId = "Arch Linux"
2128 else if ( $NF != "n/a" ) {
2132 /^DISTRIB_RELEASE/ {
2133 gsub(/^ +| +$/, "", $NF)
2134 if ( $NF != "n/a" ) {
2135 distroRelease = $NF " "
2138 /^DISTRIB_CODENAME/ {
2139 gsub(/^ +| +$/, "", $NF)
2140 if ( $NF != "n/a" ) {
2141 distroCodename = $NF " "
2145 print distroId distroRelease distroCodename
2146 }' $DIR_LSB_RELEASE )
2147 log_function_data 'cat' "$DIR_LSB_RELEASE"
2149 # this is HORRIBLY slow, but I don't know why, it runs fast in shell
2150 # if [[ -n $( which lsb_release ) && $1 == 'app' ]];then
2151 # distro=$( echo "$( lsb_release -irc )" | gawk '
2153 # /^Distributor ID/ {
2154 # gsub(/^ +| +$/, "", $NF)
2158 # gsub(/^ +| +$/, "", $NF)
2159 # distroRelease = $NF
2162 # gsub(/^ +| +$/, "", $NF)
2163 # distroCodename = $NF
2166 # print distroId " " distroRelease " (" distroCodename ")"
2171 log_function_data "distro: $distro"
2175 ## create array of gfx cards installed on system
2176 get_graphics_card_data()
2182 A_GFX_CARD_DATA=( $( echo "$Lspci_Data" | gawk -F': ' '
2186 /vga compatible controller/ {
2187 gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF)
2189 gsub(/^ +| +$/, "", $NF)
2190 gsub(/ [ \t]+/, " ", $NF)
2194 # for (( i=0; i < ${#A_GFX_CARD_DATA[@]}; i++ ))
2196 # A_GFX_CARD_DATA[i]=$( sanitize_characters BAN_LIST_NORMAL "${A_GFX_CARD_DATA[i]}" )
2198 # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
2199 if [[ ${#A_GFX_CARD_DATA[@]} -eq 0 ]];then
2200 A_GFX_CARD_DATA[0]='Failed to Detect Video Card!'
2203 # GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory..
2204 # GFXMEM="size=[$(echo "$Lspci_Data" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size<size2){size=size2}}}}END{print size2}')M]"
2205 log_function_data "A_GFX_CARD_DATA: ${A_GFX_CARD_DATA[@]}"
2209 ## create array of glx data
2210 get_graphics_glx_data()
2213 if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
2215 A_GLX_DATA=( $( glxinfo | gawk -F ': ' '
2216 # note: function declarations go before BEGIN? It appears so, confirm.
2217 # the real question here though is why this function is even here, seems
2218 # just to be a complicated way to pack/print a variable, but maybe the
2219 # original idea was to handle > 1 cases of detections I guess
2220 function join( arr, sep ) {
2236 if ( $2 ~ /mesa/ ) {
2238 # if ( $2 ~ / r[3-9][0-9][0-9] / ) {
2239 gsub(/'"$BAN_LIST_NORMAL"'/, "", $2)
2241 # this counter failed in one case, a bug, and is not needed now
2248 # dropping all conditions from this test to just show full mesa information
2249 # there is a user case where not f and mesa apply, atom mobo
2250 # /opengl version/ && ( f || $2 !~ /mesa/ ) {
2254 /direct rendering/ {
2258 printf( "%s\n%s\n%s\n", join( a, ", " ), join( b, ", " ), join( c, ", " ) )
2262 # GLXR=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl renderer/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}')
2263 # GLXV=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl version/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}')
2265 log_function_data "A_GLX_DATA: ${A_GLX_DATA[@]}"
2269 ## return screen resolution / tty resolution
2270 get_graphics_res_data()
2273 local screen_resolution=''
2275 if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
2276 # Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in
2277 # 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0
2278 screen_resolution=$( xrandr | gawk '
2280 res[++m] = gensub(/^.* ([0-9]+) ?x ?([0-9]+)[_ ].* ([0-9\.]+)\*.*$/,"\\1x\\2@\\3hz","g",$0)
2284 if (res[n] ~ /^[[:digit:]]+x[[:digit:]]+/) {
2285 line = line ? line ", " res[n] : res[n]
2292 if [[ -z $screen_resolution ]];then
2293 screen_resolution=$( xdpyinfo | gawk '
2299 screen_resolution=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{
2303 echo "$screen_resolution"
2304 log_function_data "screen_resolution: $screen_resolution"
2308 ## for possible future data, not currently used
2309 get_graphics_agp_data()
2314 if [[ $B_MODULES_DIR == 'true' ]];then
2315 ## not used currently
2316 agp_module=$( gawk '
2317 /agp/ && !/agpgart/ && $3 > 0 {
2318 print(gensub(/(.*)_agp.*/,"\\1","g",$1))
2320 log_function_data 'cat' "$DIR_MODULES"
2322 log_function_data "agp_module: $agp_module"
2326 ## create array of x vendor/version data
2327 get_graphics_x_data()
2330 local x_vendor='' x_version=''
2332 if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
2333 # X vendor and version detection.
2334 x_vendor=$( xdpyinfo | gawk -F': +' '
2339 gsub(/the|inc|foundation|project|corporation/, "", $2)
2341 gsub(/^ +| +$/, "", $2)
2342 gsub(/ [ \t]+/, " ", $2)
2346 # new method added since radeon and X.org and the disappearance of <X server name> version : ...etc
2347 # Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2
2348 # A failover mechanism is in place. (if $x_version is empty, the release number is parsed instead)
2349 x_version=$( xdpyinfo | gawk '/version:/ {
2352 if [[ -z $x_version ]];then
2353 x_version=$(xdpyinfo | gawk -F': +' '
2357 /vendor release number/ {
2363 A_X_DATA[0]="$x_vendor"
2364 A_X_DATA[1]="$x_version"
2366 #X -version 2>&1 | gawk '/^X Window System Version/ { print $5 }'
2367 #This method could be used in the future to detect X when X is not running,
2368 #however currently inxi ignores X checks when X is not found.
2370 log_function_data "A_X_DATA: ${A_X_DATA[@]}"
2374 # this gets just the raw data, total space/percent used and disk/name/per disk capacity
2375 get_hdd_data_basic()
2379 local hdd_data="$( df --exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660 )"
2380 log_function_data 'raw' "hdd_data:\n$hdd_data"
2382 hdd_used=$( echo "$hdd_data" | gawk '
2383 # also handles odd dm-1 type, from lvm
2384 /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+|dm[-]?[0-9]+)/ {
2385 # this handles the case where the first item is too long
2386 # and makes df wrap output to next line, so here we advance
2387 # it to the next line for that single case
2388 if ( NF < 5 && $0 !~ /.*\%/ ) {
2391 # if the first item caused a wrap, use one less than standard
2392 # testing for the field with % in it, ie: 34%, then go down from there
2393 # this also protects against cases where the mount point has a space in the
2394 # file name, thus breaking going down from $NF directly.
2395 if ( $4 ~ /.*\%/ ) {
2398 # otherwise use standard
2399 else if ( $5 ~ /.*\%/ ) {
2402 # and if this is not detected, give up, we need user data to debug
2411 if [[ -z $hdd_used ]];then
2414 log_function_data "hdd_used: $hdd_used"
2415 # create the initial array strings:
2416 # disk-dev, capacity, name, usb or not
2417 # final item is the total of the disk
2420 if [[ $B_PARTITIONS_DIR == 'true' ]];then
2422 gawk -v hddused="$hdd_used" '
2424 driveSize = $(NF - 1)*1024/1000**3
2425 gsub(/,/, " ", driveSize)
2426 gsub(/^ +| +$/, "", driveSize)
2427 printf( $NF",%.1fGB,,\n", driveSize )
2429 # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
2430 # $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {
2433 # special case from this data: 8 0 156290904 sda
2434 $1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {
2439 size = size*1024/1000**3 # calculate size in GB size
2440 workingUsed = hddused*1024/1000**3 # calculate workingUsed in GB used
2441 # this handles a special case with livecds where no hdd_used is detected
2442 if ( size > 0 && hddused == "na" ) {
2443 size = sprintf( "%.1f", size )
2446 else if ( size > 0 && workingUsed > 0 ) {
2447 diskUsed = workingUsed*100/size # calculate used percentage
2448 diskUsed = sprintf( "%.1f", diskUsed )
2449 size = sprintf( "%.1f", size )
2450 print size "GB," diskUsed "% used"
2453 print "NA,-" # print an empty array, this will be further handled in the print out function
2455 }' $DIR_PARTITIONS ) )
2456 log_function_data 'cat' "$DIR_PARTITIONS"
2459 log_function_data "A_HDD_DATA: ${A_HDD_DATA[@]}"
2463 ## fills out the A_HDD_DATA array with disk names
2464 get_hard_drive_data_advanced()
2467 local a_temp_working='' a_temp_scsi='' temp_holder='' temp_name='' i='' j=''
2468 local sd_ls_by_id='' ls_disk_by_id=''
2470 ## check for all ide type drives, non libata, only do it if hdx is in array
2471 if [[ -n $( egrep 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
2472 # remember, we're using the last array item to store the total size of disks
2473 for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
2476 a_temp_working=( ${A_HDD_DATA[i]} )
2478 if [[ -n $( egrep '^hd[a-z]' <<< ${a_temp_working[0]} ) ]];then
2479 if [[ -e /proc/ide/${a_temp_working[0]}/model ]];then
2480 a_temp_working[2]="$( remove_erroneous_chars /proc/ide/${a_temp_working[0]}/model )"
2482 a_temp_working[2]="Name n/a"
2484 # these loops are to easily extend the cpu array created in the gawk script above with more fields per cpu.
2485 for (( j=0; j < ${#a_temp_working[@]}; j++ ))
2487 if [[ $j -gt 0 ]];then
2488 A_HDD_DATA[i]="${A_HDD_DATA[i]},${a_temp_working[$j]}"
2490 A_HDD_DATA[i]="${a_temp_working[$j]}"
2497 ## then handle libata names
2498 # first get the ata device names, put them into an array
2500 if [[ $B_SCSI_DIR == 'true' ]]; then
2501 a_temp_scsi=( $( gawk '
2511 if (b[i] ~ / *type: *direct-access.*/) {
2512 #c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i])
2513 #c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i] )
2514 # the vendor: string is useless, and is a bug, ATA is not a vendor for example
2515 c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/, "\\2", "g", a[i] )
2517 gsub(/^ +| +$/, "", c)
2518 gsub(/ [ \t]+/, " ", c)
2520 # we actually want this data, so leaving this off for now
2521 # if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) {
2528 log_function_data 'cat' "$DIR_SCSI"
2532 ## then we'll loop through that array looking for matches.
2533 if [[ -n $( egrep 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
2534 # first pack the main ls variable so we don't have to keep using ls /dev...
2535 ls_disk_by_id="$( ls -l /dev/disk/by-id )"
2536 for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
2538 if [[ -n $( egrep '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then
2540 a_temp_working=( ${A_HDD_DATA[$i]} )
2542 if [[ ${#a_temp_scsi[@]} -gt 0 ]];then
2543 for (( j=0; j < ${#a_temp_scsi[@]}; j++ ))
2545 ## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the
2546 # discovered disk name AND ends with the correct identifier, sdx
2547 # get rid of whitespace for some drive names and ids, and extra data after - in name
2548 temp_name=$( tr ' ' '_' <<< ${a_temp_scsi[$j]} | cut -d '-' -f 1 )
2549 sd_ls_by_id=$( egrep -m1 ".*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" )
2551 if [[ -n $sd_ls_by_id ]];then
2552 a_temp_working[2]=${a_temp_scsi[$j]}
2553 if [[ -n $( grep 'usb-' <<< $sd_ls_by_id ) ]];then
2554 a_temp_working[3]='USB'
2558 a_temp_working[2]="Name n/a"
2562 a_temp_working[2]="Name n/a"
2565 # these loops are to easily extend the cpu array created in the gawk script above with more fields per cpu.
2566 for (( j=0; j < ${#a_temp_working[@]}; j++ ))
2568 if [[ $j -gt 0 ]];then
2569 A_HDD_DATA[i]="${A_HDD_DATA[i]},${a_temp_working[$j]}"
2571 A_HDD_DATA[i]="${a_temp_working[$j]}"
2576 unset ls_disk_by_id # and then let's dump the data we don't need
2578 log_function_data "A_HDD_DATA: ${A_HDD_DATA[@]}"
2585 local lspci_data="$( lspci -v | gawk '{
2586 gsub(/\(prog-if[^)]*\)/,"")
2591 log_function_data 'raw' "lspci_data:\n$lspci_data"
2595 ## return memory used/installed
2600 if [[ $B_MEMINFO == 'true' ]];then
2605 /^(MemFree|Buffers|Cached):/ {
2610 printf("%.1f/%.1fMB\n", used/1024, tot/1024)
2612 log_function_data 'cat' "$DIR_MEMINFO"
2615 log_function_data "memory: $memory"
2619 # process and return module version data
2620 get_module_version_number()
2623 local module_version=''
2625 if [[ -n $( which modinfo ) ]];then
2626 module_version=$( modinfo $1 | gawk '
2632 gsub(/^ +| +$/, "", $2)
2633 gsub(/ [ \t]+/, " ", $2)
2639 echo "$module_version"
2640 log_function_data "module_version: $module_version"
2644 ## create array of network cards
2645 get_networking_data()
2649 A_NETWORK_DATA=( $( echo "$Lspci_Data" | gawk '
2653 /^[0-9a-f:.]+ (ethernet|network) (controller|bridge)/ || /^[0-9a-f:.]+ [^:]+: .*(ethernet|network).*$/ {
2654 nic=gensub(/^[0-9a-f:.]+ [^:]+: (.+)$/,"\\1","g",$0)
2655 gsub(/realtek semiconductor/, "Realtek", nic)
2656 gsub(/davicom semiconductor/, "Davicom", nic)
2657 # The doublequotes are necessary because of the pipes in the variable.
2658 gsub(/'"$BAN_LIST_NORMAL"'/, "", nic)
2660 gsub(/^ +| +$/, "", nic)
2661 gsub(/ [ \t]+/, " ", nic)
2664 while (getline && !/^$/) {
2666 ports[nic] = ports[nic] $4 " "
2668 if (/driver in use/) {
2669 drivers[nic] = drivers[nic] gensub(/(.*): (.*)/,"\\2","g",$0) ""
2671 else if (/kernel modules/) {
2672 modules[nic] = modules[nic] gensub(/(.*): (.*)/,"\\2","g",$0) ""
2685 ## note: this loses the plural ports case, is it needed anyway?
2686 if (ports[i] != "") {
2689 if (drivers[i] != "") {
2690 useDrivers=drivers[i]
2692 if (modules[i] != "" ) {
2693 useModules = modules[i]
2698 if (ports[i] != "") {
2701 if (drivers[i] != "") {
2702 useDrivers=drivers[i]
2704 if (modules[i] != "" ) {
2705 useModules = modules[i]
2708 # create array primary item for master array
2709 print a[j] "," useDrivers "," usePorts "," useModules
2714 log_function_data "A_NETWORK_DATA: ${A_NETWORK_DATA[@]}"
2718 get_networking_wan_ip_data()
2723 # get ip using wget redirect to stdout. This is a clean, text only IP output url.
2724 ip=$( wget -q -O - http://smxi.org/opt/ip.php | gawk -F 'is: ' '{
2729 if [[ -z $ip ]];then
2733 log_function_data "ip: $ip"
2737 get_networking_local_ip_data()
2740 if [[ $B_IFCONFIG == 'true' ]];then
2742 A_INTERFACES_DATA=( $( $DIR_IFCONFIG | gawk '
2747 # not clear on why inet is coming through, but this gets rid of it
2748 # as first line item.
2750 gsub(/,/, " ", interface)
2751 gsub(/^ +| +$/, "", interface)
2752 gsub(/ [ \t]+/, " ", interface)
2754 aInterfaces[interface]++
2755 while (getline && !/^$/) {
2757 ipAddresses[interface] = gensub( /addr:([0-9\.]+)/, "\\1", "g", $2 )
2764 for (i in aInterfaces) {
2767 if (ipAddresses[i] != "") {
2768 useInterfaceIp = ipAddresses[i]
2770 # create array primary item for master array
2771 # tested needed to avoid bad data from above, if null it is garbage
2772 # this is the easiest way to handle junk I found, improve if you want
2773 if ( useInterfaceIp != "" ) {
2774 print a[j] "," useInterfaceIp
2781 log_function_data "A_INTERFACES_DATA: ${A_INTERFACES_DATA[@]}"
2785 get_partition_data()
2788 #local excluded_file_types='--exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660'
2789 # df doesn't seem to work in script with variables like at the command line
2790 local main_partition_data="$( df -h -T --exclude-type=aufs --exclude-type=tmpfs --exclude-type=iso9660 )"
2791 local swap_data="$( swapon -s )"
2792 log_function_data 'raw' "main_partition_data:\n$main_partition_data\n\nswap_data:\n$swap_data"
2795 # sample line: /dev/sda2 ext3 15G 8.9G 4.9G 65% /home
2796 # $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used
2797 ## note: by subtracting from the last field number NF, we avoid a subtle issue with LVM df output, where if
2798 ## the first field is too long, it will occupy its own line, this way we are getting only the needed data
2799 A_PARTITION_DATA=( $( echo "$main_partition_data" | gawk '
2803 # this has to be nulled for every iteration so it does not retain value from last iteration
2805 # this is required because below we are subtracting from NF, so it has to be > 4
2806 # the real issue is long file system names that force the wrap of df output: //fileserver/main
2807 # but we still need to handle more dynamically long space containing file names, but later.
2808 ( NF < 5 ) && ( $0 !~ /[0-9]+\%/ ) {
2809 # set the dev location here for cases of wrapped output
2811 devBase=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
2815 # this handles yet another fredforfaen special case where a mounted drive
2816 # has the search string in its name
2817 $NF ~ /^\/$|^\/boot$|^\/var$|^\/home$|^\/tmp$|^\/usr$/ {
2818 print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1) ",main," devBase
2820 # skip all these, including the first, header line. Use the --exclude-type
2821 # to handle new filesystems types we do not want listed here
2822 $NF !~ /^\/$|^\/boot$|^\/var$|^\/home$|^\/tmp$|^\/usr$|^filesystem/ {
2823 # this is to avoid file systems with spaces in their names, that will make
2824 # the test show the wrong data in each of the fields, if no x%, then do not use
2825 # using 3 cases, first default, standard, 2nd, 3rd, handles one and two spaces in name
2826 if ( $(NF - 1) ~ /[0-9]+\%/ ) {
2827 print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1) ",secondary," devBase
2829 # these two cases construct the space containing name
2830 else if ( $(NF - 2) ~ /[0-9]+\%/ ) {
2831 print $(NF - 1) " " $NF "," $(NF - 5) "," $(NF - 4) "," $(NF - 2) ",secondary," devBase
2833 else if ( $(NF - 3) ~ /[0-9]+\%/ ) {
2834 print $(NF - 2) " " $(NF - 1) " " $NF "," $(NF - 6) "," $(NF - 5) "," $(NF - 3) ",secondary," devBase
2838 # now add the swap partition data, don't want to show swap files, just partitions,
2839 # though this can include /dev/ramzswap0. Note: you can also use /proc/swaps for this
2840 # data, it's the same exact output as swapon -s
2841 $( echo "$swap_data" | gawk '
2846 size = sprintf( "%.2f", $3*1024/1000**3 )
2847 devBase = gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
2848 used = sprintf( "%.2f", $4*1024/1000**3 )
2849 percentUsed = sprintf( "%.0f", ( $4/$3 )*100 )
2850 print "swap-" swapCounter "," size "GB," used "GB," percentUsed "\%,main," devBase
2851 swapCounter = ++swapCounter
2855 if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
2856 get_partition_data_advanced
2858 log_function_data "A_PARTITION_DATA: ${A_PARTITION_DATA[@]}"
2862 # first get the locations of the mount points for label/uuid detection
2863 get_partition_data_advanced()
2866 local a_partition_working='' dev_partition_data=''
2867 local dev_disk_label='' dev_disk_uuid='' dev_item='' dev_label='' dev_uuid=''
2868 local mount_point=''
2870 if [[ -d /dev/disk/by-label ]];then
2871 dev_disk_label="$( ls -l /dev/disk/by-label )"
2873 if [[ -d /dev/disk/by-uuid ]];then
2874 dev_disk_uuid="$( ls -l /dev/disk/by-uuid )"
2876 log_function_data 'raw' "dev_disk_label:\n$dev_disk_label\n\ndev_disk_uuid:\n$dev_disk_uuid"
2878 if [[ $B_MOUNTS_DIR == 'true' ]];then
2879 for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
2882 a_partition_working=( ${A_PARTITION_DATA[i]} )
2884 # note: for swap this will already be set
2885 if [[ -z ${a_partition_working[5]} ]];then
2886 mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} )
2887 #echo mount_point $mount_point
2888 dev_partition_data=$( gawk '
2894 # trying to handle space in name
2895 # gsub( /\\040/, " ", $0 )
2896 /[ \t]'$mount_point'[ \t]/ && $1 != "rootfs" {
2897 # initialize the variables
2901 # slice out the /dev
2902 partition=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
2903 # label and uuid can occur for root, set partition to null now
2904 if ( partition ~ /by-label/ ) {
2905 label=gensub( /^(\/dev\/disk\/by-label\/)(.+)$/, "\\2", 1, $1 )
2908 if ( partition ~ /by-uuid/ ) {
2909 uuid=gensub( /^(\/dev\/disk\/by-uuid\/)(.+)$/, "\\2", 1, $1 )
2913 # handle /dev/root for / id
2914 if ( partition == "root" ) {
2915 # if this works, great, otherwise, just set this to null values
2916 partTemp="'$( readlink /dev/root 2>/dev/null )'"
2917 if ( partTemp != "" ) {
2918 if ( partTemp ~ /[hs]d[a-z][0-9]/ ) {
2919 partition=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, partTemp )
2921 else if ( partTemp ~ /by-uuid/ ) {
2922 uuid=gensub( /^(\/dev\/disk\/by-uuid\/)(.+)$/, "\\2", 1, partTemp )
2923 partition="" # set null to let real location get discovered
2925 else if ( partTemp ~ /by-label/ ) {
2926 label=gensub( /^(\/dev\/disk\/by-label\/)(.+)$/, "\\2", 1, partTemp )
2927 partition="" # set null to let real location get discovered
2936 print partition "," label "," uuid
2939 # echo dev_partition_data: $dev_partition_data
2940 # assemble everything we could get for dev/h/dx, label, and uuid
2942 A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","$dev_partition_data
2945 ## now we're ready to proceed filling in the data
2947 a_partition_working=( ${A_PARTITION_DATA[i]} )
2950 dev_item=${a_partition_working[5]}
2951 dev_label=${a_partition_working[6]}
2952 dev_uuid=${a_partition_working[7]}
2954 # then if dev data/uuid is incomplete, try to get missing piece
2955 # it's more likely we'll get a uuid than a label. But this should get the
2956 # dev item set no matter what, so then we can get the rest of any missing data
2957 # first we'll get the dev_item if it's missing
2958 if [[ -n $dev_disk_uuid ]] && [[ -z $dev_item && -n $dev_uuid ]];then
2959 dev_item=$( echo "$dev_disk_uuid" | gawk '
2961 item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF )
2964 elif [[ -n $dev_disk_label ]] && [[ -z $dev_item && -n $dev_label ]];then
2965 dev_item=$( echo "$dev_disk_label" | gawk '
2966 # first we need to change space x20 in by-label back to a real space
2967 #gsub( /x20/, " ", $0 )
2968 # then we can see if the string is there
2970 item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF )
2974 if [[ -n $dev_disk_uuid ]] && [[ -n $dev_item && -z $dev_uuid ]];then
2975 dev_uuid=$( echo "$dev_disk_uuid" | gawk '
2980 if [[ -n $dev_disk_label ]] && [[ -n $dev_item && -z $dev_label ]];then
2981 dev_label=$( echo "$dev_disk_label" | gawk '
2987 # assemble everything we could get for dev/h/dx, label, and uuid
2989 A_PARTITION_DATA[i]=${a_partition_working[0]}","${a_partition_working[1]}","${a_partition_working[2]}","${a_partition_working[3]}","${a_partition_working[4]}","$dev_item","$dev_label","$dev_uuid
2992 log_function_data 'cat' "$DIR_MOUNTS"
2994 log_function_data "A_PARTITION_DATA: ${A_PARTITION_DATA[@]}"
2998 ## return uptime string
3002 ## note: removing gsub(/ /,"",a); to get get space back in there, goes right before print a
3003 local uptime_value="$( uptime | gawk '{
3004 a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0)
3007 echo "$uptime_value"
3008 log_function_data "uptime_value: $uptime_value"
3012 #### -------------------------------------------------------------------
3013 #### special data handling for specific options and conditions
3014 #### -------------------------------------------------------------------
3016 ## multiply the core count by the data to be calculated, bmips, cache
3017 # args: $1 - string to handle; $2 - cpu count
3018 calculate_multicore_data()
3021 local string_number=$1 string_data=''
3023 if [[ -n $( egrep -i '( mb| kb)' <<< $1 ) ]];then
3024 string_data=" $( gawk '{print $2}' <<< $1 )" # add a space for output
3025 string_number=$( gawk '{print $1}' <<< $1 )
3027 # handle weird error cases where it's not a number
3028 if [[ -n $( egrep '^[0-9\.,]+$' <<< $string_number ) ]];then
3029 string_number=$( echo $string_number $2 | gawk '{
3033 elif [[ $string_number == '' ]];then
3034 string_number='Not Available'
3036 # I believe that the above returns 'unknown' by default so no need for extra text
3037 string_number="$string_number "
3039 echo "$string_number$string_data"
3040 log_function_data "string_numberstring_data: $string_number$string_data"
3044 # prints out shortened list of flags, the main ones of interest
3045 # args: $1 - string of cpu flags to process
3049 local cpu_flags="$1"
3051 # nx = AMD stack protection extensions
3052 # lm = Intel 64bit extensions
3053 # sse, sse2, pni = sse1,2,3 gfx extensions
3054 # svm = AMD pacifica virtualization extensions
3055 # vmx = Intel IVT (vanderpool) virtualization extensions
3056 cpu_flags=$( echo "$cpu_flags" | gawk '
3066 /^(nx|lm|svm|vmx)$/ {
3075 if (ssel[$0] > sse) {
3091 #grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
3092 if [[ -z $cpu_flags ]];then
3096 log_function_data "cpu_flags: $cpu_flags"
3100 #### -------------------------------------------------------------------
3101 #### print and processing of output data
3102 #### -------------------------------------------------------------------
3104 #### MASTER PRINT FUNCTION - triggers all line item print functions
3105 ## main function to print out, master for all sub print functions.
3109 # note that print_it_out passes local variable values on to its children,
3110 # and in some cases, their children, with Lspci_Data
3111 local Lspci_Data='' # only for verbose
3113 if [[ $B_SHOW_SHORT_OUTPUT == 'true' ]];then
3116 Lspci_Data="$( get_lspci_data )"
3117 if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_SYSTEM == 'true' ]];then
3120 if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_CPU == 'true' ]];then
3123 if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_GRAPHICS == 'true' ]];then
3126 if [[ $VERBOSITY_LEVEL -ge 5 || $B_SHOW_AUDIO == 'true' ]];then
3129 if [[ $VERBOSITY_LEVEL -ge 2 || $B_SHOW_NETWORK == 'true' ]];then
3130 print_networking_data
3132 if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_DISK == 'true' ]];then
3133 print_hard_disk_data
3135 if [[ $VERBOSITY_LEVEL -ge 4 || $B_SHOW_PARTITIONS == 'true' ]];then
3136 print_partition_data
3138 if [[ $VERBOSITY_LEVEL -ge 1 || $B_SHOW_INFO == 'true' ]];then
3145 #### SHORT OUTPUT PRINT FUNCTION, ie, verbosity 0
3146 # all the get data stuff is loaded here to keep execution time down for single line print commands
3147 # these will also be loaded in each relevant print function for long output
3151 local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' )
3152 local processes="$(( $( ps aux | wc -l ) - 1 ))"
3153 local short_data='' i='' b_background_black='false'
3154 local memory=$( get_memory_data )
3155 local up_time="$( get_uptime )"
3157 # set A_CPU_CORE_DATA
3159 local cpc_plural='' cpu_count_print='' model_plural=''
3160 local cpu_physical_count=${A_CPU_CORE_DATA[0]}
3161 local cpu_core_count=${A_CPU_CORE_DATA[3]}
3162 local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
3163 local cpu_type=${A_CPU_CORE_DATA[2]}
3165 if [[ $cpu_physical_count -gt 1 ]];then
3168 cpu_count_print="$cpu_physical_count "
3171 local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core"
3172 # local cpu_core_count=${A_CPU_CORE_DATA[0]}
3176 ## note: if hdd_model is declared prior to use, whatever string you want inserted will
3177 ## be inserted first. In this case, it's desirable to print out (x) before each disk found.
3178 local a_hdd_data_count=$(( ${#A_HDD_DATA[@]} - 1 ))
3180 local a_hdd_basic_working=( ${A_HDD_DATA[$a_hdd_data_count]} )
3182 local hdd_capacity=${a_hdd_basic_working[0]}
3183 local hdd_used=${a_hdd_basic_working[1]}
3189 local a_cpu_working=(${A_CPU_DATA[0]})
3191 local cpu_model="${a_cpu_working[0]}"
3192 ## assemble data for output
3193 local cpu_clock="${a_cpu_working[1]}" # old CPU3
3194 # this gets that weird min/max final array item
3195 local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
3196 local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
3198 #set_color_scheme 12
3199 if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
3200 for i in $C1 $C2 $CN
3203 "$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN")
3204 b_background_black='true'
3208 if [[ $b_background_black == 'true' ]];then
3211 ## these need to be in quotes, don't know why
3212 if [[ ${!i} == $NORMAL ]];then
3213 declare $i="${!i}15,1"
3215 declare $i="${!i},1"
3218 #C1="${C1},1"; C2="${C2},1"; CN="${CN},1"
3221 short_data="${C1}CPU$cpc_plural${CN}[${C2}${SEP1}${cpu_data_string} ${cpu_model}$model_plural (${cpu_type}) clocked at ${min_max_clock}${SEP1}${CN}] ${C1}Kernel${CN}[${C2}${SEP1}${current_kernel}${SEP1}${CN}] ${C1}Up${CN}[${C2}${SEP1}${up_time}${SEP1}${CN}] ${C1}Mem${CN}[${C2}${SEP1}${memory}${SEP1}${CN}] ${C1}HDD${CN}[${C2}${SEP1}${hdd_capacity}($hdd_used)${SEP1}${CN}] ${C1}Procs${CN}[${C2}${SEP1}${processes}${SEP1}${CN}]"
3223 if [[ $SHOW_IRC -gt 0 ]];then
3224 short_data="${short_data} ${C1}Client${CN}[${C2}${SEP1}${IRC_CLIENT}${IRC_CLIENT_VERSION}${SEP1}${CN}]"
3226 short_data="${short_data} ${C1}$SCRIPT_NAME${C2}${CN}[${C2}${SEP1}$SCRIPT_VERSION_NUMBER${SEP1}${CN}]"
3227 if [[ $SCHEME -gt 0 ]];then
3228 short_data="${short_data} $NORMAL"
3230 print_screen_output "$short_data"
3234 #### LINE ITEM PRINT FUNCTIONS
3236 # print sound card data
3240 local i='' card_one='Card-1' audio_data='' a_audio_data='' port_data=''
3241 local a_audio_working='' alsa_driver='' alsa_data='' port_plural='' module_version=''
3242 # set A_AUDIO_DATA and get alsa data
3244 alsa_data=$( get_audio_alsa_data )
3246 a_audio_working=(${A_AUDIO_DATA[0]})
3249 if [[ -n ${A_AUDIO_DATA[@]} ]];then
3250 # slightly complicated because 2nd array item could be the alsa data
3251 if [[ ${#A_AUDIO_DATA[@]} -le 1 ]];then
3255 # if [[ -n ${a_audio_working[2]} ]];then
3256 # port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
3258 # this should only trigger if the $DIR_ASOUND_DEVICE data is used, not lspci -nn
3259 if [[ -n ${a_audio_working[3]} && $B_EXTRA_DATA == 'true' ]];then
3260 module_version=$( print_module_version "${a_audio_working[3]}" )
3262 if [[ -n ${a_audio_working[1]} ]];then
3263 alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}$module_version"
3265 if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then
3266 if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then
3269 port_data=" ${C1}at port$port_plural${C2} ${a_audio_working[2]}"
3271 audio_data="${C1}$card_one${C2} ${a_audio_working[0]}$alsa_driver$port_data"
3272 audio_data=$( create_print_line "Audio:" "$audio_data" )
3273 print_screen_output "$audio_data"
3274 i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
3275 while [[ -n ${A_AUDIO_DATA[++i]} ]]
3278 a_audio_working=( ${A_AUDIO_DATA[i]} )
3284 if [[ -n ${a_audio_working[3]} && $B_EXTRA_DATA == 'true' ]];then
3285 module_version=$( print_module_version "${a_audio_working[3]}" )
3287 # we're testing for the presence of the 2nd array item here, which is the driver name
3288 if [[ -n ${a_audio_working[1]} ]];then
3289 alsa_driver="${C1}driver${C2} ${a_audio_working[1]}"
3291 if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then
3292 if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then
3295 port_data=" ${C1}at port$port_plural${C2} ${a_audio_working[2]}"
3297 if [[ -n ${a_audio_working[0]} ]];then
3298 audio_data="${C1}Card-$(( $i + 1 ))${C2} ${a_audio_working[0]}$alsa_driver$port_data"
3300 if [[ -n $audio_data ]];then
3301 audio_data=$( create_print_line " " "$audio_data" )
3302 print_screen_output "$audio_data"
3305 # alsa driver data only prints out if sound card data is found
3306 if [[ -n $alsa_data ]];then
3307 audio_data="${C1}Sound:${C2} $alsa_data"
3308 audio_data=$( create_print_line " " "$audio_data" )
3309 print_screen_output "$audio_data"
3318 local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data=''
3319 local bmip_data='' cpu_cache='' cpu_vendor='' cpu_flags=''
3321 ##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
3322 # Array A_CPU_DATA always has one extra element: max clockfreq found.
3323 # that's why its count is one more than you'd think from cores/cpus alone
3328 local a_cpu_working=(${A_CPU_DATA[0]})
3330 local cpu_model="${a_cpu_working[0]}"
3331 ## assemble data for output
3332 local cpu_clock="${a_cpu_working[1]}"
3334 cpu_vendor=${a_cpu_working[5]}
3336 # set A_CPU_CORE_DATA
3338 local cpc_plural='' cpu_count_print='' model_plural=''
3339 local cpu_physical_count=${A_CPU_CORE_DATA[0]}
3340 local cpu_core_count=${A_CPU_CORE_DATA[3]}
3341 local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
3342 local cpu_type=${A_CPU_CORE_DATA[2]}
3344 if [[ $cpu_physical_count -gt 1 ]];then
3346 cpu_count_print="$cpu_physical_count "
3350 local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core"
3351 # Strange (and also some expected) behavior encountered. If print_screen_output() uses $1
3352 # as the parameter to output to the screen, then passing "<text1> ${ARR[@]} <text2>"
3353 # will output only <text1> and first element of ARR. That "@" splits in elements and "*" _doesn't_,
3354 # is to be expected. However, that text2 is consecutively truncated is somewhat strange, so take note.
3355 # This has been confirmed by #bash on freenode.
3356 # The above mentioned only emerges when using the debugging markers below
3357 ## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
3359 if [[ -z ${a_cpu_working[2]} ]];then
3360 a_cpu_working[2]="unknown"
3363 cpu_data=$( create_print_line "CPU$cpc_plural:" "${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural (${cpu_type})" )
3364 if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_CPU == 'true' ]];then
3365 # update for multicore, bogomips x core count.
3366 if [[ $B_EXTRA_DATA == 'true' ]];then
3367 # if [[ $cpu_vendor != 'intel' ]];then
3368 bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
3370 # bmip_data="${a_cpu_working[4]}"
3372 bmip_data=" ${C1}bmips${C2} $bmip_data"
3374 ## note: this handles how intel reports L2, total instead of per core like AMD does
3375 # note that we need to multiply by number of actual cpus here to get true cache size
3376 if [[ $cpu_vendor != 'intel' ]];then
3377 cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
3379 cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" )
3381 # only print shortened list
3382 if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
3383 cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" )
3384 cpu_flags=" ${C1}flags${C2} ($cpu_flags)"
3386 cpu_data="$cpu_data${C2} ${C1}cache${C2} $cpu_cache$cpu_flags$bmip_data${CN}"
3388 # we don't this printing out extra line unless > 1 cpu core
3389 if [[ ${#A_CPU_DATA[@]} -gt 2 ]] && [[ $B_SHOW_CPU == 'true' || $VERBOSITY_LEVEL -ge 5 ]];then
3390 cpu_clock_speed='' # null < verbosity level 5
3392 cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]} MHz${CN}"
3395 cpu_data="$cpu_data $cpu_clock_speed"
3396 print_screen_output "$cpu_data"
3398 # we don't this printing out extra line unless > 1 cpu core
3399 if [[ ${#A_CPU_DATA[@]} -gt 2 ]] && [[ $B_SHOW_CPU == 'true' || $VERBOSITY_LEVEL -ge 5 ]];then
3400 for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
3403 a_cpu_working=(${A_CPU_DATA[i]})
3405 # note: the first iteration will create a first space, for color code separation below
3406 cpu_multi_clock_data="$cpu_multi_clock_data ${C1}($(( i + 1 )))${C2} ${a_cpu_working[1]} MHz${CN}"
3407 if [[ $i -gt 10 ]];then
3411 if [[ -n $cpu_multi_clock_data ]];then
3412 cpu_multi_clock_data=$( create_print_line " " "${C1}Clock Speeds:${C2}$cpu_multi_clock_data" )
3413 print_screen_output "$cpu_multi_clock_data"
3416 if [[ $B_CPU_FLAGS_FULL == 'true' ]];then
3417 print_cpu_flags_full "${a_cpu_working[3]}"
3422 # takes list of all flags, split them and prints x per line
3423 # args: $1 - cpu flag string
3424 print_cpu_flags_full()
3427 local cpu_flags_full="$1" a_cpu_flags='' line_starter=''
3428 local i=0 counter=0 max_length=18 max_length_add=18 flag='' flag_data=''
3430 # build the flag line array
3431 for flag in $cpu_flags_full
3433 a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag "
3434 if [[ $i -ge $max_length ]];then
3436 max_length=$(( $max_length + $max_length_add ))
3441 for (( i=0; i < ${#a_cpu_flags[@]};i++ ))
3443 if [[ $i -eq 0 ]];then
3444 line_starter="${C1}CPU Flags${C2} "
3448 flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" )
3449 print_screen_output "$flag_data"
3457 local gfx_data='' i='' card_one='Card' root_alert=''
3458 local screen_resolution="$( get_graphics_res_data )"
3459 local b_is_mesa='false' display_full_string=''
3460 # set A_GFX_CARD_DATA
3461 get_graphics_card_data
3464 local x_vendor=${A_X_DATA[0]}
3465 local x_version=${A_X_DATA[1]}
3467 get_graphics_glx_data
3468 local glx_renderer="${A_GLX_DATA[0]}"
3469 local glx_version="${A_GLX_DATA[1]}"
3470 # this can contain a long No case debugging message, so it's being sliced off
3471 # note: using grep -ioE '(No|Yes)' <<< ${A_GLX_DATA[2]} did not work in Arch, no idea why
3472 local glx_direct_render=$( gawk '{
3474 }' <<< "${A_GLX_DATA[2]}" )
3475 # some basic error handling:
3476 if [[ -z $screen_resolution ]];then
3477 screen_resolution='N/A'
3480 if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
3481 if [[ -z $x_vendor || -z $x_version ]];then
3482 x_vendor='X-Vendor: N/A'
3484 display_full_string="${C1}$x_vendor${C2} $x_version ${C1}Res:${C2} ${screen_resolution} "
3486 if [[ $B_X_RUNNING == 'true' && $B_ROOT == 'true' ]];then
3487 root_alert="${C1}Gfx Data:${C2} N/A for root user"
3489 display_full_string="${C1}tty res:${C2} ${screen_resolution} $root_alert"
3492 if [[ ${#A_GFX_CARD_DATA[@]} -gt 1 ]];then
3494 while [[ -n ${A_GFX_CARD_DATA[i]} && $i -le 3 ]]
3496 gfx_data=" ${C1}Card-$(($i+1))${C2} ${A_GFX_CARD_DATA[i]}"
3501 gfx_data=$( create_print_line "Graphics:" "${C1}$card_one${C2} ${A_GFX_CARD_DATA[0]}${gfx_data} $display_full_string" )
3502 print_screen_output "$gfx_data"
3504 # if [[ -z $glx_renderer || -z $glx_version ]];then
3508 ## note: if glx render or version have no content, then mesa is true
3509 # if [[ $B_X_RUNNING == 'true' ]] && [[ $b_is_mesa != 'true' ]];then
3510 if [[ $B_X_RUNNING == 'true' && $B_ROOT != 'true' ]];then
3511 if [[ -z $glx_renderer ]];then
3514 if [[ -z $glx_version ]];then
3517 if [[ -z $glx_direct_render ]];then
3518 glx_direct_render='N/A'
3520 gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${C1}GLX Version${C2} ${glx_version}${CN}" )
3521 if [[ $B_HANDLE_CORRUPT_DATA == 'true' || $B_EXTRA_DATA == 'true' ]];then
3522 gfx_data="$gfx_data ${C1}Direct Rendering${C2} ${glx_direct_render}${CN}"
3524 print_screen_output "$gfx_data"
3529 print_hard_disk_data()
3532 local hdd_data='' hdd_data_2='' a_hdd_working=''
3533 local dev_data='' size_data='' hdd_model='' hdd_model_2='' hdd_model_3='' usb_data=''
3537 ## note: if hdd_model is declared prior to use, whatever string you want inserted will
3538 ## be inserted first. In this case, it's desirable to print out (x) before each disk found.
3539 local a_hdd_data_count=$(( ${#A_HDD_DATA[@]} - 1 ))
3541 local a_hdd_basic_working=( ${A_HDD_DATA[$a_hdd_data_count]} )
3543 local hdd_capacity=${a_hdd_basic_working[0]}
3544 local hdd_used=${a_hdd_basic_working[1]}
3546 if [[ $VERBOSITY_LEVEL -ge 3 ]] || [[ $B_SHOW_DISK == 'true' ]];then
3547 ## note: the output part of this should be in the print hdd data function, not here
3548 get_hard_drive_data_advanced
3549 for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
3551 # this adds the (x) numbering in front of each disk found, and creates the full disk string
3553 a_hdd_working=( ${A_HDD_DATA[i]} )
3555 if [[ $B_SHOW_DISK == 'true' ]];then
3556 if [[ -n ${a_hdd_working[3]} ]];then
3557 usb_data="${a_hdd_working[3]} "
3561 dev_data="/dev/${a_hdd_working[0]} "
3562 size_data=" ${a_hdd_working[1]}"
3564 # wrap to avoid long lines
3566 if [[ $i -gt 1 && $B_SHOW_DISK == 'true' ]] || [[ $i -gt 3 ]];then
3567 hdd_model_2="${hdd_model_2}${hdd_model_2+${C1}$(($i+1)):${C2}} $usb_data$dev_data${a_hdd_working[2]}$size_data "
3569 hdd_model="${hdd_model}${hdd_model+ ${C1}$(($i+1)):${C2}} $usb_data$dev_data${a_hdd_working[2]}$size_data"
3572 if [[ -z $hdd_model ]];then
3573 hdd_model=' None Detected'
3575 if [[ -n $hdd_model_2 ]];then
3576 hdd_data=$( create_print_line "Disks:" "${C1}HDD${C2} ${C1}Total Size:${C2} ${hdd_capacity} (${hdd_used})${hdd_model}" )
3577 hdd_data_2=$( create_print_line " " "${hdd_model_2}${CN}" )
3579 hdd_data=$( create_print_line "Disks:" "${C1}HDD${C2} ${C1}Total Size:${C2} ${hdd_capacity} (${hdd_used})${hdd_model}${CN}" )
3582 hdd_data=$( create_print_line "Disks:" "${C1}HDD Total Size:${C2} ${hdd_capacity} (${hdd_used})${CN}" )
3584 print_screen_output "$hdd_data"
3585 if [[ -n $hdd_model_2 ]];then
3586 print_screen_output "$hdd_data_2"
3594 local suggested_app="runlevel"
3597 local memory="$( get_memory_data )"
3598 local processes="$(( $( ps aux | wc -l ) - 1 ))"
3599 local up_time="$( get_uptime )"
3601 # Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
3602 # long_last=$( echo -ne "${C1}Processes${C2} ${processes}${CN} | ${C1}Uptime${C2} ${up_time}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
3603 info_data=$( create_print_line "Info:" "${C1}Processes${C2} ${processes} ${C1}Uptime${C2} ${up_time} ${C1}Memory${C2} ${memory}${CN}" )
3605 # this only triggers if no X data is present
3606 if [[ $B_X_RUNNING != 'true' ]];then
3607 if [[ -e $suggested_app ]];then
3608 runlvl="$( runlevel | gawk '{ print $2 }' )"
3609 info_data="${info_data} ${C1}Runlevel${C2} ${runlvl}${CN}"
3613 if [[ $SHOW_IRC -gt 0 ]];then
3614 info_data="${info_data} ${C1}Client${C2} ${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}"
3616 info_data="${info_data} ${C1}$SCRIPT_NAME${C2} $SCRIPT_VERSION_NUMBER${CN}"
3618 if [[ $SCHEME -gt 0 ]];then
3619 info_data="${info_data} ${NORMAL}"
3621 print_screen_output "$info_data"
3625 # args: $1 - module name (could be > 1, so loop it )
3626 print_module_version()
3629 local module_versions='' module='' version=''
3633 version=$( get_module_version_number $module )
3634 if [[ -n $version ]];then
3635 module_versions="$module_versions $version"
3639 if [[ -n $module_versions ]];then
3640 echo " ${C1}v:${C2}$module_versions"
3645 print_networking_data()
3648 local i='' card_one='Card-1' network_data='' a_network_working='' port_data='' driver_data=''
3649 local card_string='' port_plural='' module_version=''
3650 # set A_NETWORK_DATA
3654 a_network_working=(${A_NETWORK_DATA[0]})
3657 # will never be null because null is handled in get_network_data, but in case we change
3658 # that leaving this test in place.
3659 if [[ -n ${A_NETWORK_DATA[@]} ]];then
3660 if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then
3663 if [[ -n ${a_network_working[3]} && $B_EXTRA_DATA == 'true' ]];then
3664 module_version=$( print_module_version "${a_network_working[3]}" )
3666 if [[ -n ${a_network_working[1]} ]];then
3667 driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version"
3669 if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
3670 if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
3673 port_data=" ${C1}at port$port_plural${C2} ${a_network_working[2]}"
3676 network_data="${C1}$card_one${C2} ${a_network_working[0]}$driver_data$port_data"
3677 network_data=$( create_print_line "Network:" "$network_data" )
3678 print_screen_output "$network_data"
3679 i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
3680 while [[ -n ${A_NETWORK_DATA[++i]} ]]
3683 a_network_working=( ${A_NETWORK_DATA[i]} )
3689 if [[ -n ${a_network_working[3]} && $B_EXTRA_DATA == 'true' ]];then
3690 module_version=$( print_module_version "${a_network_working[3]}" )
3692 if [[ -n ${a_network_working[1]} ]];then
3693 driver_data=" ${C1}driver${C2} ${a_network_working[1]}$module_version"
3695 if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then
3696 if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then
3699 port_data=" ${C1}at port$port_plural${C2} ${a_network_working[2]}"
3701 network_data="${C1}Card-$(( $i + 1 ))${C2} ${a_network_working[0]}$driver_data$port_data"
3702 network_data=$( create_print_line " " "$network_data" )
3703 print_screen_output "$network_data"
3706 if [[ $B_SHOW_IP == 'true' ]];then
3707 print_networking_ip_data
3712 print_networking_ip_data()
3715 local ip=$( get_networking_wan_ip_data )
3716 local ip_data='' a_interfaces_working='' interfaces='' interfaces_2='' i=''
3718 # set A_INTERFACES_DATA
3719 get_networking_local_ip_data
3720 # first print output for wan ip line. Null is handled in the get function
3721 ip_data=$( create_print_line " " "${C1}Wan IP:${C2} $ip" )
3723 # then create the list of local interface/ip
3724 interfaces=" ${C1}Interface:${C2}"
3725 i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
3726 while [[ -n ${A_INTERFACES_DATA[i]} ]]
3729 a_interfaces_working=(${A_INTERFACES_DATA[i]})
3731 if [[ $i -lt 3 ]];then
3732 if [[ -n ${a_interfaces_working[0]} ]];then
3733 interfaces="$interfaces ${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]}"
3736 if [[ -n ${a_interfaces_working[0]} ]];then
3737 # space on end here for lining up with line starter
3738 interfaces_2="$interfaces_2${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]} "
3743 print_screen_output "$ip_data$interfaces"
3744 # then wrap it if needed
3745 if [[ -n $interfaces_2 ]];then
3746 interfaces_2=$( create_print_line " " "$interfaces_2" )
3747 print_screen_output "$interfaces_2"
3752 print_partition_data()
3755 local a_partition_working='' partition_used='' partition_data=''
3756 local counter=0 line_max=160 i=0 a_partition_data='' line_starter=''
3757 local partitionIdClean='' part_dev='' full_dev='' part_label='' full_label=''
3758 local part_uuid='' full_uuid='' dev_remote=''
3760 # this handles the different, shorter, irc colors strings embedded in variable data
3761 if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
3764 # and no color string data at all
3765 if [[ $SCHEME -eq 0 ]];then
3768 if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
3772 # set A_PARTITION_DATA
3775 for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
3778 a_partition_working=(${A_PARTITION_DATA[i]})
3782 if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_partition_working[4]} == 'main' ]];then
3783 if [[ -n ${a_partition_working[2]} ]];then
3784 partition_used=" ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})"
3786 partition_used='' # reset partition used to null
3789 # don't show user names in output
3790 if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then
3791 if [[ -n ${a_partition_working[5]} ]];then
3792 if [[ -z $( grep -E '(^//|:/)' <<< ${a_partition_working[5]} ) ]];then
3793 part_dev="/dev/${a_partition_working[5]}"
3796 part_dev="${a_partition_working[5]}"
3803 full_dev=" ${C1}$dev_remote:${C2} $part_dev"
3804 if [[ $B_SHOW_LABELS == 'true' && $dev_remote != 'remote' ]];then
3805 if [[ -n ${a_partition_working[6]} ]];then
3806 part_label="${a_partition_working[6]}"
3810 full_label=" ${C1}label:${C2} $part_label"
3812 if [[ $B_SHOW_UUIDS == 'true' && $dev_remote != 'remote' ]];then
3813 if [[ -n ${a_partition_working[7]} ]];then
3814 part_uuid="${a_partition_working[7]}"
3818 full_uuid=" ${C1}uuid:${C2} $part_uuid"
3821 partitionIdClean=$( sed -r 's|/home/(.*)/(.*)|/home/##/\2|' <<< ${a_partition_working[0]} )
3822 # because these lines can vary widely, using dynamic length handling here
3823 a_partition_data[$counter]="${a_partition_data[$counter]}${C1}ID:${C2}$partitionIdClean ${C1}size:${C2} ${a_partition_working[1]}$partition_used$full_dev$full_label$full_uuid "
3825 if [[ $( wc -c <<< ${a_partition_data[$counter]} ) -gt $line_max ]];then
3830 # print out all lines, line starter on first line
3831 for (( i=0; i < ${#a_partition_data[@]};i++ ))
3833 if [[ $i -eq 0 ]];then
3834 line_starter='Partition:'
3838 partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" )
3839 print_screen_output "$partition_data"
3847 local system_data='' bits=''
3848 local host_name=$( hostname )
3849 local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' )
3850 local distro="$( get_distro_data )"
3851 # check for 64 bit first
3852 if [[ -n $( uname -m | grep -o 'x86_64' ) ]];then
3858 if [[ $B_SHOW_HOST == 'true' ]];then
3859 system_data=$( create_print_line "System:" "${C1}Host${C2} $host_name ${C1}Kernel${C2}" )
3861 system_data=$( create_print_line "System:" "${C1}Kernel${C2}" )
3863 system_data="$system_data $current_kernel $bits ${C1}Distro${C2} $distro"
3864 print_screen_output "$system_data"
3868 ########################################################################
3869 #### SCRIPT EXECUTION
3870 ########################################################################
3872 main $@ ## From the End comes the Beginning
3874 ## note: this EOF is needed for smxi handling, this is what triggers the full download ok