Commit 189f0b84 authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: sync with distro_info 1.1

parent 6c9c0761
#!/bin/sh
# Author: Vitaly Lipatov <lav@etersoft.ru>
# 2007, 2009, 2010, 2012, 2016, 2017, 2018 (c) Etersoft
# 2007-2018 Public domain
# Detect the distro and version
# Welcome to send updates!
# 2007-2019 (c) Vitaly Lipatov <lav@etersoft.ru>
# 2007-2019 (c) Etersoft
# 2007-2019 Public domain
# You can set ROOTDIR to root system dir
#ROOTDIR=
......@@ -408,6 +405,9 @@ case "$DIST_BIT" in
'aarch64')
DIST_BIT="64"
;;
'e2k')
DIST_BIT="64"
;;
# 'pa_risc' | 'pa-risc') # Are some of these 64bit? Least not all...
# BIT="64"
# ;;
......@@ -444,31 +444,85 @@ get_memory_size() {
echo $detected
}
print_name_version()
{
[ -n "$DISTRIB_RELEASE" ] && echo $DISTRIB_ID/$DISTRIB_RELEASE || echo $DISTRIB_ID
}
get_virt()
{
local VIRT
local SDCMD
SDCMD=$(which systemd-detect-virt 2>/dev/null)
if [ -n "$SDCMD" ] ; then
VIRT="$($SDCMD)"
[ "$VIRT" = "none" ] && echo "(host system)" && return
[ -z "$VIRT" ] && echo "(unknown)" && return
echo "$VIRT" && return
fi
if [ -r /proc/user_beancounters ] ; then
echo "openvz" && return
fi
echo "(unknown)"
# TODO: check for openvz
}
# https://unix.stackexchange.com/questions/196166/how-to-find-out-if-a-system-uses-sysv-upstart-or-systemd-initsystem
get_service_manager()
{
[ -d /run/systemd/system ] && echo "systemd" && return
[ -d /usr/share/upstart ] && echo "upstart" && return
[ -d /etc/init.d ] && echo "sysvinit" && return
echo "(unknown)"
}
print_total_info()
{
cat <<EOF
distro_info total information (run with -h to get help):
Distro name and version (-e): $(print_name_version)
Packaging system (-p): $(pkgtype)
Running service manager (-y): $(get_service_manager)
Virtualization (-i): $(get_virt)
CPU Architecture (-a): $(get_arch)
CPU norm register size (-b): $(get_bit_size)
System memory size (MB) (-m): $(get_memory_size)
Base OS name (-o): $(get_base_os_name)
Build system distro name (-s): $(pkgvendor)
Build system vendor name (-n): $(rpmvendor)
EOF
}
case $1 in
-h)
echo "distro_info - distro name and version detection"
echo "Usage: distro_info [options] [args]"
echo "Options:"
echo " -a - print hardware architecture"
echo " -b - print size of arch bit (32/64)"
echo " -d - print distro name"
echo " -e - print full name of distro with version"
echo " -i - print virtualization type"
echo " -h - this help"
echo " -m - print system memory size (in MB)"
echo " -n [SystemName] - print vendor name (as _vendor macros in rpm)"
echo " -o - print base OS name"
echo " -p [SystemName] - print type of the packaging system"
echo " -s [SystemName] - print name of distro for build system (like in the package release name)"
ecgi " -y - print running service manager"
echo " -v - print version of distro"
echo " -V - print the utility version"
echo "Run without args to print all information."
exit 0
;;
-p)
# override DISTRIB_ID
test -n "$2" && DISTRIB_ID="$2"
pkgtype
exit 0
;;
-h)
echo "distr_vendor - system name and version detection"
echo "Usage: distr_vendor [options] [args]"
echo "-p [SystemName] - print type of packaging system"
echo "-d - print distro name"
echo "-a - print hardware architecture"
echo "-b - print size of arch bit (32/64)"
echo "-m - print system memory size (in MB)"
echo "-o - print base os name"
echo "-v - print version of distro"
echo "-e - print full name of distro with version (by default)"
echo "-s [SystemName] - print name of distro for build system (like in the package release name)"
echo "-n [SystemName] - print vendor name (as _vendor macros in rpm)"
echo "-V - print the version of $0"
echo "-h - this help"
exit 0
;;
-d)
echo $DISTRIB_ID
;;
......@@ -478,6 +532,9 @@ case $1 in
-b)
get_bit_size
;;
-i)
get_virt
;;
-m)
get_memory_size
;;
......@@ -499,13 +556,18 @@ case $1 in
rpmvendor
exit 0
;;
-y)
get_service_manager
;;
-V)
echo "20171010"
echo "20191121"
exit 0
;;
-e)
print_name_version
;;
*)
# if run without args, just printout Name/Version of the current system
[ -n "$DISTRIB_RELEASE" ] && echo $DISTRIB_ID/$DISTRIB_RELEASE || echo $DISTRIB_ID
print_total_info
;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment