Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / distro
blobe9995665b5c3802d08a98953f9a7fac4df3fd6b1
1 #!/bin/bash
3 # This script determines the Linux distribution we are running
4 # on. It output two words: (1) The distro name and (2) the version
5 # Example output "UBUNTU 10.04"
7 # Ubuntu is detected with /etc/lsb-release
8 SEP=${1:- }
9 if [ -e /etc/lsb-release ]
10 then
11 . /etc/lsb-release
12 if [ -n "$DISTRIB_ID" -a -n "$DISTRIB_RELEASE" ] ; then
13 echo "${DISTRIB_ID^^*}$SEP$DISTRIB_RELEASE"
14 exit 0
18 # Debian: We drop the last version: 5.0.4 -> 5.0
19 if [ -e /etc/debian_version ]
20 then
21 VERSION=$(cat /etc/debian_version)
22 if [ "${VERSION:3:1}" = . ] ; then
23 VERSION=${VERSION:0:3}
25 if [ "${VERSION:0:6}" = "wheezy" ] ; then
26 VERSION="7.0"
28 if [ "${VERSION:0:6}" = "jessie" ] ; then
29 VERSION="8.0"
31 echo "DEBIAN$SEP$VERSION"
32 exit 0
35 # RedHat / CentOS
36 if [ -e /etc/redhat-release ]
37 then
38 # CentOS release 5.4 (Final)
39 VERSION=$(cat /etc/redhat-release)
40 if [ "${VERSION:0:6}" = CentOS ]
41 then
42 if [ "${VERSION:0:24}" = "CentOS Linux release 6.0" ]; then
43 echo "CENTOS${SEP}6.0"
44 exit 0
46 REL=${VERSION#* }
47 REL=${REL#* }
48 REL=${REL%% *}
49 echo "CENTOS$SEP$REL"
50 exit 0
51 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.0" ]
52 then
53 echo "REDHAT${SEP}6.0"
54 exit 0
55 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.1" ]
56 then
57 echo "REDHAT${SEP}6.1"
58 exit 0
59 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.2" ]
60 then
61 echo "REDHAT${SEP}6.2"
62 exit 0
63 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.3" ]
64 then
65 echo "REDHAT${SEP}6.3"
66 exit 0
67 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.4" ]
68 then
69 echo "REDHAT${SEP}6.4"
70 exit 0
74 # SLES
75 if [ -e /etc/SuSE-release ]
76 then
77 # SLES 11
78 VERSION=$(sed -rn 's/^VERSION = (.*)/\1/p' < /etc/SuSE-release)
79 SP=$(sed -rn 's/^PATCHLEVEL = (.*)/\1/p' < /etc/SuSE-release)
80 if [ "$VERSION" = 11 -a "$SP" = 1 ]
81 then
82 echo "SLES$SEP${VERSION}SP1"
83 exit 0
84 elif [ "$VERSION" = 11 -a "$SP" = 2 ]
85 then
86 echo "SLES$SEP${VERSION}SP2"
87 exit 0
88 elif [ "$VERSION" = 11 -a "$SP" = 3 ]
89 then
90 echo "SLES$SEP${VERSION}SP3"
91 exit 0
92 elif [ "$VERSION" = 10 -a "$SP" = 1 ]
93 then
94 echo "SLES$SEP${VERSION}SP1"
95 exit 0
96 elif [ "$VERSION" = 10 -a "$SP" = 2 ]
97 then
98 echo "SLES$SEP${VERSION}SP2"
99 exit 0
100 elif [ "$VERSION" = 11 ]
101 then
102 echo "SLES$SEP${VERSION}"
103 exit 0
104 elif [ "$VERSION" = 12.1 ]
105 then
106 echo "OPENSUSE$SEP${VERSION}"
107 exit 0
111 exit 1