-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathck-distro.sh
executable file
·50 lines (41 loc) · 1.43 KB
/
ck-distro.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Detects which OS and if it is Linux then it will detect which Linux distro is running.
OS=$(uname -s)
REV=$(uname -r)
MACH=$(uname -m)
GetVersionFromFile()
{
VERSION=$(cat "$1" | tr "\n" ' ' | sed s/.*VERSION.*=\ // )
}
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=$(uname -p)
OSSTR="${OS} ${REV}(${ARCH} $(uname -v))"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} $(oslevel) ($(oslevel -r))"
elif [ "${OS}" = "Linux" ] ; then
KERNEL=$(uname -r)
if [ -f /etc/redhat-release ] ; then
DIST='RedHat'
PSUEDONAME=$(cat /etc/redhat-release | sed s/.*\(// | sed s/\)//)
REV=$(cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//)
elif [ -f /etc/SuSE-release ] ; then
DIST=$(cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//)
REV=$(cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //)
elif [ -f /etc/lsb-release ]; then
DIST=""
REV=$(cat /etc/lsb-release |grep DISTRIB_DESC | grep -Eo '["\047].*["\047]')
elif [ -f /etc/mandrake-release ] ; then
DIST='Mandrake'
PSUEDONAME=$(cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//)
REV=$(cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//)
elif [ -f /etc/debian_version ] ; then
DIST="Debian $(cat /etc/debian_version)"
REV=""
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[$(cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//)]"
fi
OSSTR="${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
fi
echo "${OSSTR}"