-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure_os
executable file
·132 lines (130 loc) · 4.41 KB
/
configure_os
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Determine the current OS
local SH_OS_TYPE SH_OS_FLAVOR SH_OS_DISTRO SH_OS_DISTRO_NUM SH_OS_RELEASE
if [[ $OSTYPE == darwin* ]]; then
# OS X
SH_OS_TYPE='OSX'
SH_OS_FLAVOR='OSX'
SH_OS_RELEASE=`type sw_vers >/dev/null 2>&1 && sw_vers -productVersion`
SH_OS_DISTRO_NUM=`uname -r | tr "." "\n" | head -n 1`
if [[ $OSTYPE == darwin24* ]]; then
SH_OS_DISTRO='Sequoia'
elif [[ $OSTYPE == darwin23* ]]; then
SH_OS_DISTRO='Sonoma'
elif [[ $OSTYPE == darwin22* ]]; then
SH_OS_DISTRO='Ventura'
elif [[ $OSTYPE == darwin21.1* ]]; then
SH_OS_DISTRO='Ventura'
elif [[ $OSTYPE == darwin21* ]]; then
SH_OS_DISTRO='Monterey'
elif [[ $OSTYPE == darwin20* ]]; then
SH_OS_DISTRO='Monterey'
elif [[ $OSTYPE == darwin19.4* ]]; then
SH_OS_DISTRO='Monterey'
elif [[ $OSTYPE == darwin19.2* ]]; then
SH_OS_DISTRO='Big Sur'
elif [[ $OSTYPE == darwin19* ]]; then
SH_OS_DISTRO='Catalina'
elif [[ $OSTYPE == darwin18* ]]; then
SH_OS_DISTRO='Mojave'
elif [[ $OSTYPE == darwin17* ]]; then
SH_OS_DISTRO='High Sierra'
elif [[ $OSTYPE == darwin16* ]]; then
SH_OS_DISTRO='Sierra'
elif [[ $OSTYPE == darwin15* ]]; then
SH_OS_DISTRO='El Capitan'
elif [[ $OSTYPE == darwin14* ]]; then
SH_OS_DISTRO='Yosemite'
elif [[ $OSTYPE == darwin13* ]]; then
SH_OS_DISTRO='Mavericks'
elif [[ $OSTYPE == darwin12* ]]; then
SH_OS_DISTRO='Mountain Lion'
elif [[ $OSTYPE == darwin11* ]]; then
SH_OS_DISTRO='Lion'
elif [[ $OSTYPE == darwin10* ]]; then
SH_OS_DISTRO='Snow Leopard'
else
# How to get the distro
SH_OS_DISTRO='Unknown'
fi
elif [[ $OSTYPE == linux-gnu ]]; then
# Linux
SH_OS_TYPE='Linux'
SH_OS_FLAVOR='Linux'
if [[ -n '$WSL_DISTRO_NAME' ]]; then
SH_OS_FLAVOR='WSL'
fi
if [[ -f /etc/lsb-release ]] || type lsb_release >/dev/null 2>&1 ; then
SH_OS_DISTRO=`type lsb_release >/dev/null 2>&1 && lsb_release -i -s`
SH_OS_RELEASE=`type lsb_release >/dev/null 2>&1 && lsb_release -r -s`
elif [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu
# How to distinguish Debian vs. Ubuntu?
SH_OS_DISTRO='Debian'
# How to get the release
SH_OS_RELEASE=0
elif [[ -f /etc/centos-release ]]; then
# CentOS 6+
SH_OS_DISTRO='CentOS'
SH_OS_RELEASE=`cat /etc/centos-release >/dev/null 2>&1 && cat /etc/centos-release | sed s/.\*release\ // | sed s/\ .\*//`
elif [[ -f /etc/redhat-release ]]; then
# RedHat
SH_OS_DISTRO='RedHat'
SH_OS_RELEASE=`cat /etc/redhat-release >/dev/null 2>&1 && cat /etc/redhat-release | sed s/.\*release\ // | sed s/\ .\*//`
elif [[ -f /etc/issue ]]; then
# Yocto
SH_OS_DISTRO='Yocto'
SH_OS_RELEASE=`cat /etc/issue >/dev/null 2>&1 && cat /etc/issue | sed s/\ \(Yocto.\*//`
else
# How to get the distro
SH_OS_DISTRO='Unknown'
# How to get the release
SH_OS_RELEASE=0
fi
elif [[ $OSTYPE == linux-gnueabi* ]]; then
# Linux Embedded
SH_OS_TYPE='Linux'
SH_OS_FLAVOR='Embedded'
if [[ -f /etc/debian_version ]]; then
if [[ -f /etc/rpi-issue ]]; then
# Raspbian
SH_OS_DISTRO='Raspbian'
else
# Debian
SH_OS_DISTRO='Debian'
fi
SH_OS_RELEASE=`cat /etc/debian_version >/dev/null 2>&1 && cat /etc/debian_version`
else
# How to get the distro
SH_OS_DISTRO='Unknown'
# How to get the release
SH_OS_RELEASE=0
fi
elif [[ '$OS' == Windows* ]]; then
# Windows Msys/MinGW (who uses these anymore?)
SH_OS_TYPE='Windows'
SH_OS_FLAVOR='Emulated'
if [[ '$OSTYPE' == msys* ]]; then
# Msys
SH_OS_DISTRO='Msys'
SH_OS_RELEASE=`uname -s | tr "-" "\n" | tail -n 1`
elif [[ '$MSYSTEM' == MSYS* ]]; then
# Msys
SH_OS_DISTRO='Msys'
SH_OS_RELEASE=`uname -s | tr "-" "\n" | tail -n 1`
elif [[ '$MSYSTEM' == MINGW* ]]; then
# MinGW
SH_OS_DISTRO='Msys'
SH_OS_RELEASE=`uname -s | tr "-" "\n" | tail -n 1`
else
# How to get the distro
SH_OS_DISTRO='Unknown'
# How to get the release
SH_OS_RELEASE=0
fi
else
# What the heck are we running on???
SH_OS_TYPE='Unknown'
SH_OS_FLAVOR='Unknown'
SH_OS_DISTRO='Unknown'
SH_OS_RELEASE=0
fi