forked from WIPACrepo/pyglidein
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_arch.sh
executable file
·74 lines (71 loc) · 2.34 KB
/
os_arch.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
if [ -x /usr/bin/lsb_release ]; then
DISTRIB=`lsb_release -si|tr '[:upper:]' '[:lower:]'`
VERSION=`lsb_release -sr`
elif [ -e /etc/os-release ]; then
DISTRIB=`cat /etc/os-release|grep '^ID='|cut -d '=' -f 2|sed s/\"//g|tr '[:upper:]' '[:lower:]'`
VERSION=`cat /etc/os-release|grep '^VERSION='|cut -d '=' -f 2|cut -d ' ' -f 1|sed s/\"//g`
elif [ -e /etc/redhat-release ]; then
DISTRIB="centos"
VERSION=`cat /etc/redhat-release|sed s/\ /\\\\n/g|grep '\.'`
else
DISTRIB=`uname -s|tr '[:upper:]' '[:lower:]'`
VERSION=`uname -r`
fi
ARCH=`uname -m`
# Map binary compatible operating systems and versions onto one another
case $DISTRIB in
"redhatenterpriseclient" | "redhatenterpriseserver" | "rhel" | "scientificsl" | "scientific" | "centos" | "scientificfermi" | "scientificcernslc")
DISTRIB="RHEL"
VERSION=`echo "${VERSION}" | cut -d '.' -f 1`
;;
"ubuntu")
DISTRIB="Ubuntu"
if echo $VERSION | grep -q '16\.\?'; then
VERSION="16.04"
elif echo $VERSION | grep -q '15\.10'; then
VERSION="15.10"
elif echo $VERSION | grep -q '15\.\?'; then
VERSION="14.04"
elif echo $VERSION | grep -q '14\.\?'; then
VERSION="14.04"
elif echo $VERSION | grep -q '13\.\?'; then
VERSION="12.04"
elif echo $VERSION | grep -q '12\.\?'; then
VERSION="12.04"
fi
;;
"debian")
DISTRIB="Ubuntu"
if [ "$VERSION" = "testing" ]; then
VERSION="16.04"
elif echo $VERSION | grep -q '9\.\?'; then
VERSION="16.04"
elif echo $VERSION | grep -q '8\.\?'; then
VERSION="14.04"
fi
;;
"freebsd")
DISTRIB="FreeBSD"
VERSION=`uname -r | cut -d '.' -f 1`
ARCH=`uname -p`
;;
"darwin")
DISTRIB="OSX"
VERSION=`uname -r | cut -d '.' -f 1`
;;
"linux")
# Damn. Try harder with the heuristics.
if echo $VERSION | grep -q '\.el7\.\?'; then
DISTRIB="RHEL"
VERSION=7
elif echo $VERSION | grep -q '\.el6\.\?'; then
DISTRIB="RHEL"
VERSION=6
elif echo $VERSION | grep -q '\.el5\.\?'; then
DISTRIB="RHEL"
VERSION=5
fi
esac
OS_ARCH=${DISTRIB}_${VERSION}_${ARCH}
export OS_ARCH