python: Fixed dependencies for python sqlite3 module
[omd.git] / distro
blob40b92c0c75ee8f468665136c97b85a3a372815d2
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 two versions: 5.0.4 -> 5
19 if [ -e /etc/debian_version ]
20 then
21 VERSION=$(cat /etc/debian_version)
22 if [ "${VERSION:1:1}" = . ] ; then
23 VERSION=${VERSION:0:1}
25 if [ "${VERSION:0:6}" = "wheezy" ] ; then
26 VERSION="7"
28 if [ "${VERSION:0:6}" = "jessie" ] ; then
29 VERSION="8"
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"
44 exit 0
45 elif [ "${VERSION:0:22}" = "CentOS Linux release 7" ]; then
46 echo "CENTOS${SEP}7"
47 exit 0
49 echo "CENTOS$SEP${VERSION:15:1}"
50 exit 0
51 elif [ "${VERSION:0:24}" = "Red Hat Enterprise Linux" ]
52 then
53 echo "REDHAT$SEP${VERSION:40:1}"
54 exit 0
55 elif [ "${VERSION:0:6}" = "Fedora" ]
56 then
57 [[ $VERSION =~ (Fedora release ([0-9]+)) ]] && REL=${BASH_REMATCH[2]} || exit 0
58 echo "FEDORA$SEP$REL"
59 exit 0
63 # SLES
64 if [ -e /etc/SuSE-release ]
65 then
66 # SLES 11
67 VERSION=$(sed -rn 's/^VERSION = (.*)/\1/p' < /etc/SuSE-release)
68 SP=$(sed -rn 's/^PATCHLEVEL = (.*)/\1/p' < /etc/SuSE-release)
69 if [ "$VERSION" = 11 -a "$SP" = 1 ]
70 then
71 echo "SLES$SEP${VERSION}SP1"
72 exit 0
73 elif [ "$VERSION" = 11 -a "$SP" = 2 ]
74 then
75 echo "SLES$SEP${VERSION}SP2"
76 exit 0
77 elif [ "$VERSION" = 11 -a "$SP" = 3 ]
78 then
79 echo "SLES$SEP${VERSION}SP3"
80 exit 0
81 elif [ "$VERSION" = 11 -a "$SP" = 4 ]
82 then
83 echo "SLES$SEP${VERSION}SP4"
84 exit 0
85 elif [ "$VERSION" = 10 -a "$SP" = 1 ]
86 then
87 echo "SLES$SEP${VERSION}SP1"
88 exit 0
89 elif [ "$VERSION" = 10 -a "$SP" = 2 ]
90 then
91 echo "SLES$SEP${VERSION}SP2"
92 exit 0
93 elif [ "$VERSION" = 11 ]
94 then
95 echo "SLES$SEP${VERSION}"
96 exit 0
97 elif [ "$VERSION" = 12 ]
98 then
99 echo -n "SLES$SEP${VERSION}"
100 if [ $SP != 0 ]; then
101 echo "SP$SP"
102 else
103 echo
105 exit 0
106 elif [ "$VERSION" = 12.1 ]
107 then
108 echo "OPENSUSE$SEP${VERSION}"
109 exit 0
113 exit 1