Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
689f5d88
Commit
689f5d88
authored
Oct 19, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distr_info: updated from distro_info 1.6
parent
ece1e1f8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
14 deletions
+84
-14
distr_info
bin/distr_info
+84
-14
No files found.
bin/distr_info
View file @
689f5d88
#!/bin/sh
# 2007-20
19
(c) Vitaly Lipatov <lav@etersoft.ru>
# 2007-20
19
(c) Etersoft
# 2007-20
19
Public domain
# 2007-20
20
(c) Vitaly Lipatov <lav@etersoft.ru>
# 2007-20
20
(c) Etersoft
# 2007-20
20
Public domain
# You can set ROOTDIR to root system dir
#ROOTDIR=
PROGVERSION
=
"20201010"
# TODO: check /etc/system-release
# Check for DISTRO specific file in /etc
...
...
@@ -121,11 +123,14 @@ if distro altlinux-release ; then
elif
has
"ALT Linux 7."
;
then
DISTRIB_RELEASE
=
"p7"
elif
has
"ALT Linux t7."
;
then
DISTRIB_RELEASE
=
"t7"
elif
has
"ALT Linux 8."
;
then
DISTRIB_RELEASE
=
"p8"
elif
has
"ALT .*8.[0-9]"
;
then
DISTRIB_RELEASE
=
"p8"
elif
has
"ALT .*9.[0-9]"
;
then
DISTRIB_RELEASE
=
"p9"
elif
has
"ALT p9 "
;
then
DISTRIB_RELEASE
=
"p9"
elif
has
"ALT 8 SP "
;
then
DISTRIB_RELEASE
=
"c8"
elif
has
"ALT 9 SP "
;
then
DISTRIB_RELEASE
=
"c9"
elif
has
"ALT c8 "
;
then
DISTRIB_RELEASE
=
"c8"
elif
has
"ALT c8.1 "
;
then
DISTRIB_RELEASE
=
"c8.1"
elif
has
"ALT c8.2 "
;
then
DISTRIB_RELEASE
=
"c8.2"
elif
has
"ALT .*8.[0-9]"
;
then
DISTRIB_RELEASE
=
"p8"
elif
has
"ALT .*9.[0-9]"
;
then
DISTRIB_RELEASE
=
"p9"
elif
has
"ALT p9.* p9 "
;
then
DISTRIB_RELEASE
=
"p9"
elif
has
"Simply Linux 6."
;
then
DISTRIB_RELEASE
=
"p6"
elif
has
"Simply Linux 7."
;
then
DISTRIB_RELEASE
=
"p7"
elif
has
"Simply Linux 8."
;
then
DISTRIB_RELEASE
=
"p8"
...
...
@@ -287,7 +292,7 @@ elif distro os-release ; then
elif
[
"
$(
uname
)
"
=
"FreeBSD"
]
;
then
DISTRIB_ID
=
"FreeBSD"
UNAME
=
$(
uname
-r
)
DISTRIB_RELEASE
=
$(
echo
"
$UNAME
"
|
grep
RELEASE |
sed
-e
"s|
\(
[0-9]
\.
[0-9]
\)
-RELEASE|
\1
|g"
)
DISTRIB_RELEASE
=
$(
echo
"
$UNAME
"
|
grep
RELEASE |
sed
-e
"s|
\(
[0-9]
\.
[0-9]
\)
-RELEASE|
\1
|g"
)
#"
# fixme: can we detect by some file?
elif
[
"
$(
uname
)
"
=
"SunOS"
]
;
then
...
...
@@ -398,6 +403,25 @@ esac
echo
"
$DIST_ARCH
"
}
get_distro_arch
()
{
local arch
=
"
$(
get_arch
)
"
case
"
$(
pkgtype
)
"
in
rpm
)
:
;;
deb
)
case
$arch
in
'i586'
)
arch
=
'i386'
;;
'x86_64'
)
arch
=
'amd64'
;;
esac
;;
esac
echo
"
$arch
"
}
get_bit_size
()
{
local
DIST_BIT
...
...
@@ -430,8 +454,9 @@ echo "$DIST_BIT"
}
# TODO: check before calc
get_memory_size
()
{
local
detected
=
0
get_memory_size
()
{
local
detected
=
""
local
DIST_OS
=
"
$(
get_base_os_name
)
"
case
"
$DIST_OS
"
in
macosx
)
...
...
@@ -443,9 +468,14 @@ get_memory_size() {
linux
)
[
-r
/proc/meminfo
]
&&
detected
=
$((
`
cat
/proc/meminfo |
grep
MemTotal |
awk
'{print $2}'
`
/
1024
))
;;
solaris
)
detected
=
$(
prtconf |
grep
Memory |
sed
-e
"s|Memory size:
\(
[0-9][0-9]*
\)
Megabyte.*|
\1
|"
)
;;
# *)
# fatal "Unsupported OS $DIST_OS"
esac
# Exit codes only support values between 0 and 255. So use stdout.
[
-n
"
$detected
"
]
||
detected
=
0
echo
$detected
}
...
...
@@ -454,6 +484,32 @@ print_name_version()
[
-n
"
$DISTRIB_RELEASE
"
]
&&
echo
$DISTRIB_ID
/
$DISTRIB_RELEASE
||
echo
$DISTRIB_ID
}
get_core_count
()
{
local
detected
=
""
local
DIST_OS
=
"
$(
get_base_os_name
)
"
case
"
$DIST_OS
"
in
macos|freebsd
)
detected
=
$(
sysctl hw.ncpu |
awk
'{print $2}'
)
;;
linux
)
detected
=
$(
grep
-c
"^processor"
/proc/cpuinfo
)
;;
solaris
)
detected
=
$(
prtconf |
grep
-c
'cpu[^s]'
)
;;
aix
)
detected
=
$(
lsdev
-Cc
processor
-S
A |
wc
-l
)
;;
# *)
# fatal "Unsupported OS $DIST_OS"
esac
[
-n
"
$detected
"
]
||
detected
=
0
echo
$detected
}
get_virt
()
{
local
VIRT
...
...
@@ -499,29 +555,34 @@ print_pretty_name()
print_total_info
()
{
cat
<<
EOF
distro_info total information (run with -h to get help):
distro_info v
$PROGVERSION
: Copyright © 2007-2020 Etersoft
==== Total system information:
Pretty distro name (--pretty):
$(
print_pretty_name
)
Distro name and version (-e):
$(
print_name_version
)
Packaging system (-p):
$(
pkgtype
)
Running service manager (-y):
$(
get_service_manager
)
Virtualization (-i):
$(
get_virt
)
CPU Cores (-c):
$(
get_core_count
)
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
)
(run with -h to get help)
EOF
}
case
$1
in
-h
)
echo
"distro_info
- distro name and version detection
"
echo
"distro_info
v
$PROGVERSION
- distro information retriever
"
echo
"Usage: distro_info [options] [args]"
echo
"Options:"
echo
" -a - print hardware architecture"
echo
" -a - print hardware architecture
(--distro-arch for distro depended name)
"
echo
" -b - print size of arch bit (32/64)"
echo
" -c - print number of CPU cores"
echo
" -d - print distro name"
echo
" -e - print full name of distro with version"
echo
" -i - print virtualization type"
...
...
@@ -547,6 +608,12 @@ case $1 in
--pretty
)
print_pretty_name
;;
--distro-arch
)
# override DISTRIB_ID
test
-n
"
$2
"
&&
DISTRIB_ID
=
"
$2
"
get_distro_arch
exit
0
;;
-d
)
echo
$DISTRIB_ID
;;
...
...
@@ -556,6 +623,9 @@ case $1 in
-b
)
get_bit_size
;;
-c
)
get_core_count
;;
-i
)
get_virt
;;
...
...
@@ -584,7 +654,7 @@ case $1 in
get_service_manager
;;
-V
)
echo
"
20191121
"
echo
"
$PROGVERSION
"
exit
0
;;
-e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment