File: ocf-distro

package info (click to toggle)
resource-agents 1%3A4.0.0~rc1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,644 kB
  • ctags: 2,191
  • sloc: sh: 47,713; ansic: 4,074; perl: 3,457; makefile: 663; xml: 89
file content (47 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (3)
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
#
# This is OCF Linux distribution query support
# 
# Currently needed for the nfsserver RA which has some already
# released RH specific stuff (/etc/sysconfig/nfs editing)
# 

_DEBIAN_VERSION_FILE="/etc/debian_version"
_REDHAT_RELEASE_FILE="/etc/redhat-release"
_SUSE_RELEASE_FILE="/etc/SuSE-release"
_RELEASE_FILES="/etc/*-release"
_REDHAT_BASED_DISTROS_RE='red *hat|fedora|centos|scientific linux'

get_release_id() {
	if which lsb_release >/dev/null 2>&1; then
		lsb_release -si
	elif [ -e $_DEBIAN_VERSION_FILE ]; then
		echo Debian
	elif [ -e $_SUSE_RELEASE_FILE ]; then
		echo SUSE
	elif [ -e $_REDHAT_RELEASE_FILE ]; then
		echo Redhat
	else # FIXME not exactly the id here, but will do for our purpose
		cat $_RELEASE_FILES 2>/dev/null
	fi
}

is_redhat_based() {
	get_release_id | egrep -qsi "$_REDHAT_BASED_DISTROS_RE"
}

# get_os_ver() is currently unused
get_os_ver() {
	if which lsb_release >/dev/null 2>&1; then
		OS=`lsb_release -si`
		VER=`lsb_release -sr`
	elif [ -f $_DEBIAN_VERSION_FILE ]; then
		OS=Debian
		VER=$(cat $_DEBIAN_VERSION_FILE)
	elif [ -f $_REDHAT_RELEASE_FILE ]; then
		OS=RedHat  # redhat or similar
		VER= # here some complex sed script
	else
		OS=$(uname -s)
		VER=$(uname -r)
	fi
}