mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
New feature, not new line option though. Now shows init type with -x (also shows rc
type if openrc). -xx shows init / rc version number. Change runlevel to target if systemd and if non numeric runlevel given. Should support systemd/upstart/epoch/runit sysvinit. Supports openrc as extra data if it's present. Rearranged -I line a bit but really just exchanged Runlevel: for Init: v: Runlevel: default: This is the first step, some of the init system ID methods are weak and non robust and this may need to be revised, but it should for now identify systemd/upstart quite accurately, and in most cases sysvinit. Note that to get sysvinit version number requires tool: strings which in debian/ubuntu is in package binutils. I don't know the package names for arch/fedora/etc for the recommends check tool in inxi yet. I believe this will be good enough for a first draft version, but over time we'll get it more fine tuned, but as it is now, it should cover at least 99% of users, which isn't bad.
This commit is contained in:
parent
70ddbfe37a
commit
aca844c7d8
168
inxi
168
inxi
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### Version: 1.9.19
|
||||
#### Date: 2014-03-03
|
||||
#### Version: 2.0.0
|
||||
#### Date: 2014-03-12
|
||||
#### Patch Number: 00
|
||||
########################################################################
|
||||
#### SPECIAL THANKS
|
||||
|
@ -233,6 +233,7 @@ A_GLX_DATA=''
|
|||
A_GRAPHICS_CARD_DATA=''
|
||||
A_GRAPHIC_DRIVERS=''
|
||||
A_HDD_DATA=''
|
||||
A_INIT_DATA=''
|
||||
A_INTERFACES_DATA=''
|
||||
A_MACHINE_DATA=''
|
||||
A_NETWORK_DATA=''
|
||||
|
@ -1820,6 +1821,7 @@ check_recommends_items()
|
|||
ifconfig:net-tools~net-tools~net-tools~:-i_ip_lan-deprecated
|
||||
ip:iproute~iproute2~iproute~:-i_ip_lan
|
||||
sensors:lm-sensors~lm_sensors~lm-sensors~:-s_sensors_output
|
||||
strings:binutils~~~:-I_sysvinit_version
|
||||
lsusb:usbutils~usbutils~usbutils~:-A_usb_audio;-N_usb_networking
|
||||
modinfo:module-init-tools~module-init-tools~module-init-tools~:-Ax,-Nx_module_version
|
||||
runlevel:sysvinit~sysvinit~systemd~:-I_runlevel
|
||||
|
@ -2529,7 +2531,7 @@ show_options()
|
|||
print_screen_output " -i - IPv6 as well for LAN interface (IF) devices."
|
||||
print_screen_output " -I - System GCC, default. With -xx, also show other installed GCC versions."
|
||||
print_screen_output " If running in console, not in IRC client, shows shell version number,"
|
||||
print_screen_output " if detected. Adds current runlevel."
|
||||
print_screen_output " if detected. Init/RC Type and runlevel (if available)."
|
||||
print_screen_output " -N -A - Version/port(s)/driver version (if available) for Network/Audio;"
|
||||
print_screen_output " -N -A -G - Network, audio, graphics, shows PCI Bus ID/Usb ID number of card;"
|
||||
print_screen_output " -R - md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5);"
|
||||
|
@ -2546,6 +2548,7 @@ show_options()
|
|||
print_screen_output " -G - Chip vendor:product ID for each video card."
|
||||
print_screen_output " -I - Other detected installed gcc versions (if present). System default runlevel."
|
||||
print_screen_output " Adds parent program (or tty) for shell info if not in IRC (like Konsole or Gterm)."
|
||||
print_screen_output " Adds Init/RC (if found) version number."
|
||||
print_screen_output " -M - Chassis information, bios rom size (dmidecode only), if data for either is available."
|
||||
print_screen_output " -N - Chip vendor:product ID for each nic."
|
||||
print_screen_output " -R - md-raid: Superblock (if present); algorythm, U data. Adds system info line"
|
||||
|
@ -4042,6 +4045,9 @@ get_de_app_version()
|
|||
dwm|jwm|mate-about|wmii|wmii2)
|
||||
get_version='-v'
|
||||
;;
|
||||
epoch)
|
||||
get_version='version'
|
||||
;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
|
@ -4070,8 +4076,8 @@ get_de_app_version()
|
|||
}
|
||||
/'$2'/ {
|
||||
# sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string
|
||||
# xfce, and other, output has , in it, so dump all commas
|
||||
gsub(/(,|dwm-|wmii2-|wmii-|v|V)/, "",$'$3')
|
||||
# xfce, and other, output has , in it, so dump all commas and parentheses
|
||||
gsub(/(,|dwm-|wmii2-|wmii-|v|V|\(|\))/, "",$'$3')
|
||||
print $'$3'
|
||||
exit # quit after first match prints
|
||||
}' <<< "$version_data" )
|
||||
|
@ -5406,6 +5412,83 @@ get_hdd_temp_data()
|
|||
eval $LOGFE
|
||||
}
|
||||
|
||||
get_init_data()
|
||||
{
|
||||
eval $LOGFS
|
||||
|
||||
local init_type='' init_version='' rc_type='' rc_version='' temp_array=''
|
||||
local ls_run='' strings_init_version=''
|
||||
local runlevel=$( get_runlevel_data )
|
||||
local default_runlevel=$( get_runlevel_default )
|
||||
|
||||
# this test is pretty solid, if pid 1 is owned by systemd, it is systemd
|
||||
# otherwise that is 'init', which covers the rest of the init systems, I think anyway.
|
||||
# more data may be needed for other init systems.
|
||||
if [[ -e /proc/1/comm && -n $( grep -s 'systemd' /proc/1/comm ) ]];then
|
||||
init_type='systemd'
|
||||
init_version=$( get_de_app_version 'systemd' '^systemd' '2' )
|
||||
else
|
||||
ls_run=$(ls /run)
|
||||
# note: upstart-file-bridge.pid upstart-socket-bridge.pid upstart-udev-bridge.pid
|
||||
if [[ -n $( grep 'upstart' <<< "$ls_run" ) ]];then
|
||||
init_type='Upstart'
|
||||
# /sbin/init --version == init (upstart 1.12.1)
|
||||
init_version=$( get_de_app_version 'init' 'upstart' '3' )
|
||||
elif [[ -n $( type -p epoch ) ]];then
|
||||
init_type='Epoch'
|
||||
# epoch version == Epoch Init System 1.0.1 "Sage"
|
||||
init_version=$( get_de_app_version 'epoch' '^Epoch' '4' )
|
||||
# missing data:
|
||||
# http://smarden.org/runit/sv.8.html
|
||||
elif [[ -e /etc/runit || -n $( type -p sv ) ]];then
|
||||
init_type='runit' # lower case
|
||||
# no data on version yet
|
||||
elif [[ -f /etc/inittab ]];then
|
||||
init_type='SysVinit'
|
||||
if [[ -n $( type -p strings ) ]];then
|
||||
strings_init_version="$( strings /sbin/init | grep -E 'version[[:space:]]+[0-9]' )"
|
||||
fi
|
||||
if [[ -n $strings_init_version ]];then
|
||||
init_version=$( gawk '{print $2}' <<< "$strings_init_version" )
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n $( grep 'openrc' <<< "$ls_run" ) ]];then
|
||||
rc_type='OpenRC'
|
||||
# /sbin/openrc --version == openrc (OpenRC) 0.13
|
||||
if [[ -n $( type -p openrc ) ]];then
|
||||
rc_version=$( get_de_app_version 'openrc' '^openrc' '3' )
|
||||
# /sbin/rc --version == rc (OpenRC) 0.11.8 (Gentoo Linux)
|
||||
elif [[ -n $( type -p rc ) ]];then
|
||||
rc_version=$( get_de_app_version 'rc' '^rc' '3' )
|
||||
fi
|
||||
## assume sysvrc, but this data is too buggy and weird and inconsistent to have meaning
|
||||
# leaving this off for now
|
||||
# elif [[ -f /etc/inittab ]];then
|
||||
# rc_type='SysVrc'
|
||||
# # this is a guess that rc and init are same versions, may need updates / fixes
|
||||
# rc_version=$init_version
|
||||
fi
|
||||
fi
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
A_INIT_DATA=(
|
||||
"$init_type"
|
||||
"$init_version"
|
||||
"$rc_type"
|
||||
"$rc_version"
|
||||
"$runlevel"
|
||||
"$default_runlevel" )
|
||||
|
||||
IFS="$ORIGINAL_IFS"
|
||||
|
||||
temp_array=${A_INIT_DATA[@]}
|
||||
log_function_data "A_INIT_DATA: $temp_array"
|
||||
|
||||
eval $LOGFE
|
||||
}
|
||||
|
||||
get_kernel_version()
|
||||
{
|
||||
eval $LOGFS
|
||||
|
@ -9431,8 +9514,9 @@ print_info_data()
|
|||
{
|
||||
eval $LOGFS
|
||||
|
||||
local info_data='' line_starter='Info:' runlvl_default=''
|
||||
local runlvl='' client_data='' shell_data='' shell_parent='' tty_session=''
|
||||
local info_data='' line_starter='Info:' runlvl_default='' runlvl='' runlvl_title='runlevel'
|
||||
local init_data='' init_type='' init_version='' rc_type='' rc_version=''
|
||||
local client_data='' shell_data='' shell_parent='' tty_session=''
|
||||
local memory="$( get_memory_data )"
|
||||
local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 ))
|
||||
local up_time="$( get_uptime )"
|
||||
|
@ -9484,17 +9568,46 @@ print_info_data()
|
|||
|
||||
# this only triggers if no X data is present or if extra data switch is on
|
||||
if [[ $B_SHOW_DISPLAY_DATA != 'true' || $B_EXTRA_DATA == 'true' ]];then
|
||||
get_init_data
|
||||
if [[ ${A_INIT_DATA[0]} == 'systemd' && -z $( grep -E '^[0-9]$' <<< ${A_INIT_DATA[4]} ) ]];then
|
||||
runlvl_title='target'
|
||||
fi
|
||||
init_type=${A_INIT_DATA[0]}
|
||||
if [[ -z $init_type ]];then
|
||||
init_type='N/A'
|
||||
fi
|
||||
|
||||
if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
|
||||
runlvl_default=$( get_runlevel_default )
|
||||
init_version=${A_INIT_DATA[1]}
|
||||
if [[ -z $init_version ]];then
|
||||
init_version='N/A'
|
||||
fi
|
||||
init_version=" ${C1}v$SEP3${C2} $init_version"
|
||||
rc_version=${A_INIT_DATA[3]}
|
||||
if [[ -n $rc_version ]];then
|
||||
rc_version=" ${C1}v$SEP3${C2} $rc_version"
|
||||
fi
|
||||
|
||||
runlvl_default=${A_INIT_DATA[5]}
|
||||
if [[ -z $runlvl_default ]];then
|
||||
runlvl_default='N/A'
|
||||
fi
|
||||
fi
|
||||
# currently only using openrc here, otherwise show nothing
|
||||
rc_type=${A_INIT_DATA[2]}
|
||||
if [[ -n $rc_type ]];then
|
||||
rc_type=" ${C1}rc$SEP3${C2} $rc_type$rc_version"
|
||||
fi
|
||||
init_type="${C1}Init$SEP3${C2} $init_type$init_version "
|
||||
|
||||
runlvl=${A_INIT_DATA[4]}
|
||||
if [[ -n $runlvl ]];then
|
||||
runlvl="${C1}$runlvl_title$SEP3${C2} $runlvl "
|
||||
fi
|
||||
if [[ -n $runlvl_default ]];then
|
||||
runlvl_default="${C1}default$SEP3${C2} $runlvl_default "
|
||||
fi
|
||||
runlvl="$( get_runlevel_data )"
|
||||
if [[ -n $runlvl ]];then
|
||||
info_data="${info_data}${C1}Runlevel$SEP3${C2} $runlvl$runlvl_default "
|
||||
fi
|
||||
init_data="$init_type$rc_type$runlvl$runlvl_default"
|
||||
fi
|
||||
if [[ $SHOW_IRC -gt 0 ]];then
|
||||
client_data="${C1}Client$SEP3${C2} ${IRC_CLIENT}${IRC_CLIENT_VERSION} "
|
||||
|
@ -9503,24 +9616,27 @@ print_info_data()
|
|||
closing_data="$client_data${C1}$SCRIPT_NAME$SEP3${C2} $SCRIPT_VERSION_NUMBER$patch_version_number${CN}"
|
||||
|
||||
# sometimes gcc is very long, and default runlevel can be long with systemd, so create a gcc-less line first
|
||||
if [[ -n $info_data && $( calculate_line_length "${info_data}${gcc_installed}" ) -gt $LINE_MAX ]];then
|
||||
if [[ $( calculate_line_length "${info_data}${init_data}${gcc_installed}${closing_data}" ) -gt $LINE_MAX ]];then
|
||||
info_data=${info_data}${init_data}
|
||||
info_data=$( create_print_line "$line_starter" "$info_data" )
|
||||
print_screen_output "$info_data"
|
||||
info_data="${gcc_installed}${closing_data}"
|
||||
gcc_installed=''
|
||||
closing_data=''
|
||||
init_data=''
|
||||
info_data=''
|
||||
# closing_data=''
|
||||
line_starter=' '
|
||||
elif [[ -n $info_data && $( calculate_line_length "${info_data}${gcc_installed}${closing_data}" ) \
|
||||
-gt $LINE_MAX ]];then
|
||||
info_data=$( create_print_line "$line_starter" "$info_data" )
|
||||
print_screen_output "$info_data"
|
||||
info_data="${gcc_installed}${closing_data}"
|
||||
gcc_installed=''
|
||||
closing_data=''
|
||||
line_starter=' '
|
||||
else
|
||||
info_data="${info_data}${gcc_installed}${closing_data}"
|
||||
#echo 1
|
||||
fi
|
||||
if [[ $( calculate_line_length "${info_data}${init_data}${gcc_installed}${closing_data}" ) -gt $LINE_MAX ]];then
|
||||
info_data=${info_data}${init_data}${gcc_installed}
|
||||
info_data=$( create_print_line "$line_starter" "$info_data" )
|
||||
print_screen_output "$info_data"
|
||||
info_data=''
|
||||
gcc_installed=''
|
||||
init_data=''
|
||||
line_starter=' '
|
||||
#echo 2
|
||||
fi
|
||||
info_data="${info_data}${init_data}${gcc_installed}${closing_data}"
|
||||
|
||||
info_data=$( create_print_line "$line_starter" "$info_data" )
|
||||
if [[ $SCHEME -gt 0 ]];then
|
||||
|
|
12
inxi.1
12
inxi.1
|
@ -1,4 +1,4 @@
|
|||
.TH INXI 1 "2014\-03\-03" inxi "inxi manual"
|
||||
.TH INXI 1 "2014\-03\-12" inxi "inxi manual"
|
||||
.SH NAME
|
||||
inxi \- Command line system information script for console and IRC
|
||||
|
||||
|
@ -126,6 +126,7 @@ paste your local/wan IP.
|
|||
.TP
|
||||
.B \-I
|
||||
Show Information: processes, uptime, memory, irc client (or shell type if run in shell, not irc), inxi version.
|
||||
See \fB\-x\fR and \fB\-xx\fR for extra information (init type/version, runlevel).
|
||||
.TP
|
||||
.B \-l
|
||||
Show partition labels. Default: short partition \fB\-P\fR. For full \fB\-p\fR output, use: \fB\-pl\fR (or \fB\-plu\fR).
|
||||
|
@ -317,11 +318,15 @@ The following shows which lines / items get extra information with each extra da
|
|||
.B \-x \-i
|
||||
\- Show IPv6 as well for LAN interface (IF) devices.
|
||||
.TP
|
||||
.TP
|
||||
.B \-x \-I
|
||||
\- Show current init system (and init rc in some cases, like OpenRC). With \-xx, shows init/rc
|
||||
version number, if available.
|
||||
.B \-x \-I
|
||||
\- Show system GCC, default. With \-xx, also show other installed GCC versions.
|
||||
.TP
|
||||
.B \-x \-I
|
||||
\- Show current runlevel.
|
||||
\- Show current runlevel (not available with all init systems).
|
||||
.TP
|
||||
.B \-x \-I
|
||||
\- If in shell (not in IRC client, that is), show shell version number (if available).
|
||||
|
@ -356,6 +361,9 @@ The following shows which lines / items get extra information with each extra da
|
|||
\- Adds vendor:product ID of each Graphics card.
|
||||
.TP
|
||||
.B \-xx \-I
|
||||
\- Show init type version number (and rc if present).
|
||||
.TP
|
||||
.B \-xx \-I
|
||||
\- Adds other detected installed gcc versions to primary gcc output (if present).
|
||||
.TP
|
||||
.B \-xx \-I
|
||||
|
|
|
@ -1,3 +1,28 @@
|
|||
=====================================================================================
|
||||
Version: 2.0.0
|
||||
Patch Version: 00
|
||||
Script Date: 2014-03-12
|
||||
-----------------------------------
|
||||
Changes:
|
||||
-----------------------------------
|
||||
New feature, not new line option though. Now shows init type with -x (also shows rc
|
||||
type if openrc). -xx shows init / rc version number. Change runlevel to target if
|
||||
systemd and if non numeric runlevel given. Should support systemd/upstart/epoch/runit
|
||||
sysvinit. Supports openrc as extra data if it's present. Rearranged -I line a bit but
|
||||
really just exchanged Runlevel: for Init: v: Runlevel: default:
|
||||
|
||||
This is the first step, some of the init system ID methods are weak and non robust
|
||||
and this may need to be revised, but it should for now identify systemd/upstart quite
|
||||
accurately, and in most cases sysvinit. Note that to get sysvinit version number requires
|
||||
tool: strings which in debian/ubuntu is in package binutils. I don't know the package names
|
||||
for arch/fedora/etc for the recommends check tool in inxi yet.
|
||||
|
||||
I believe this will be good enough for a first draft version, but over time we'll get it
|
||||
more fine tuned, but as it is now, it should cover at least 99% of users, which isn't bad.
|
||||
|
||||
-----------------------------------
|
||||
-- Harald Hope - Wed, 12 Mar 2014 17:12:11 -0700
|
||||
|
||||
=====================================================================================
|
||||
Version: 1.9.19
|
||||
Patch Version: 00
|
||||
|
|
Loading…
Reference in a new issue