-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetLinuxDist.sh
More file actions
67 lines (51 loc) · 1.52 KB
/
Copy pathGetLinuxDist.sh
File metadata and controls
67 lines (51 loc) · 1.52 KB
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
#!/bin/bash
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
osversion=""
function get_os_release(){
local l_path="/etc/os-release"
if [ x"${osversion}" == x"" ] && [ -r "${l_path}" ]; then
osversion="$(egrep -i "^\<PRETTY_NAME\>=" "${l_path}" |sed -n 1p |sed -e "s/^\<PRETTY_NAME\>=//g" -e "s/\"//g")"
fi
unset l_path
}
function get_suse_release(){
local l_path="/etc/SuSE-release"
if [ x"${osversion}" == x"" ] && [ -r "${l_path}" ]; then
osversion="$(egrep -i "\<SUSE\>" "${l_path}" |sed -n 1p |sed "s/$/ SP$(egrep -i "^\<PATCHLEVEL\>[[:space:]]*=[[:space:]]*" "${l_path}" |sed "s/^\<PATCHLEVEL\>[[:space:]]*=[[:space:]]*//g")/g")"
fi
unset l_path
}
function get_system_release(){
local l_path="/etc/system-release"
if [ x"${osversion}" == x"" ] && [ -r "${l_path}" ]; then
osversion="$(sed -n 1p "${l_path}")"
fi
unset l_path
}
function get_redhat_release(){
local l_path="/etc/redhat-release"
if [ x"${osversion}" == x"" ] && [ -r "${l_path}" ]; then
osversion="$(sed -n 1p "${l_path}")"
fi
unset l_path
}
function get_centos_release(){
local l_path="/etc/centos-release"
if [ x"${osversion}" == x"" ] && [ -r "${l_path}" ]; then
osversion="$(sed -n 1p "${l_path}")"
fi
unset l_path
}
function main(){
get_os_release
get_suse_release
get_system_release
get_redhat_release
get_centos_release
if [ x"${osversion}" != x"" ]; then
echo "${osversion}"
else
echo 'Unknown'
fi
}
main