SLES11SP3: needs libtool
[omd.git] / distro
blob051cd353d7d2da11e9fee25c135307ba767a8349
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
45 elif [ "${VERSION:0:24}" = "CentOS Linux release 7.0" ]; then
46 echo "CENTOS${SEP}7.0"
47 exit 0
49 REL=${VERSION#* }
50 REL=${REL#* }
51 REL=${REL%% *}
52 echo "CENTOS$SEP$REL"
53 exit 0
54 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.0" ]
55 then
56 echo "REDHAT${SEP}6.0"
57 exit 0
58 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.1" ]
59 then
60 echo "REDHAT${SEP}6.1"
61 exit 0
62 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.2" ]
63 then
64 echo "REDHAT${SEP}6.2"
65 exit 0
66 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.3" ]
67 then
68 echo "REDHAT${SEP}6.3"
69 exit 0
70 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.4" ]
71 then
72 echo "REDHAT${SEP}6.4"
73 exit 0
74 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 6.5" ]
75 then
76 echo "REDHAT${SEP}6.5"
77 exit 0
78 elif [ "${VERSION:0:43}" = "Red Hat Enterprise Linux Server release 7.0" ]
79 then
80 echo "REDHAT${SEP}7.0"
81 exit 0
85 # SLES
86 if [ -e /etc/SuSE-release ]
87 then
88 # SLES 11
89 VERSION=$(sed -rn 's/^VERSION = (.*)/\1/p' < /etc/SuSE-release)
90 SP=$(sed -rn 's/^PATCHLEVEL = (.*)/\1/p' < /etc/SuSE-release)
91 if [ "$VERSION" = 11 -a "$SP" = 1 ]
92 then
93 echo "SLES$SEP${VERSION}SP1"
94 exit 0
95 elif [ "$VERSION" = 11 -a "$SP" = 2 ]
96 then
97 echo "SLES$SEP${VERSION}SP2"
98 exit 0
99 elif [ "$VERSION" = 10 -a "$SP" = 1 ]
100 then
101 echo "SLES$SEP${VERSION}SP1"
102 exit 0
103 elif [ "$VERSION" = 11 -a "$SP" = 3 ]
104 then
105 echo "SLES$SEP${VERSION}SP3"
106 exit 0
107 elif [ "$VERSION" = 10 -a "$SP" = 1 ]
108 then
109 echo "SLES$SEP${VERSION}SP1"
110 exit 0
111 elif [ "$VERSION" = 10 -a "$SP" = 2 ]
112 then
113 echo "SLES$SEP${VERSION}SP2"
114 exit 0
115 elif [ "$VERSION" = 11 ]
116 then
117 echo "SLES$SEP${VERSION}"
118 exit 0
119 elif [ "$VERSION" = 12 ]
120 then
121 echo "SLES$SEP${VERSION}"
122 exit 0
123 elif [ "$VERSION" = 12.1 ]
124 then
125 echo "OPENSUSE$SEP${VERSION}"
126 exit 0
130 exit 1