-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathbootstrap.rb
More file actions
90 lines (79 loc) · 2.23 KB
/
Copy pathbootstrap.rb
File metadata and controls
90 lines (79 loc) · 2.23 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
begin
require 'openssl'
Object.send(:remove_const, :Digest)
Digest = OpenSSL::Digest
rescue LoadError
require 'digest/sha2'
end
require 'logger'
require 'open4'
require 'pathname'
require 'settings.rb'
def is_rhel6()
# Checking corosync version works in most cases and supports non-rhel
# distributions as well as running (manually compiled) corosync2 on rhel6.
# - corosync2 does not support cman at all
# - corosync1 runs with cman on rhel6
# - corosync1 can be used without cman, but we don't support it anyways
# - corosync2 is the default result if errors occur
out = ''
status = Open4::popen4(COROSYNC, '-v') { |pid, stdin, stdout, stderr|
out = stdout.readlines()
}
retval = status.exitstatus
return false if retval != 0
match = /version\D+(\d+)/.match(out.join())
return (match and match[1] == "1")
end
def is_systemctl()
systemctl_paths = [
'/usr/bin/systemctl',
'/bin/systemctl',
'/var/run/systemd/system',
'/run/systemd/system',
]
systemctl_paths.each { |path|
return true if File.exist?(path)
}
return false
end
def get_pcs_path()
pcsd_path = Pathname.new(
File.expand_path(File.dirname(__FILE__))
).realpath.to_s
if PCSD_EXEC_LOCATION == pcsd_path or PCSD_EXEC_LOCATION == (pcsd_path + '/')
return PCS_EXEC
else
return pcsd_path + '/../pcs/pcs'
end
end
PCS_VERSION = '0.9.157'
# unique instance signature, allows detection of dameon restarts
DAEMON_INSTANCE_SIGNATURE = Digest::SHA2.hexdigest("#{Time.now} #{rand()}")
COROSYNC = COROSYNC_BINARIES + "corosync"
ISRHEL6 = is_rhel6
ISSYSTEMCTL = is_systemctl
if ISRHEL6
COROSYNC_CMAPCTL = COROSYNC_BINARIES + "corosync-objctl"
else
COROSYNC_CMAPCTL = COROSYNC_BINARIES + "corosync-cmapctl"
end
COROSYNC_QUORUMTOOL = COROSYNC_BINARIES + "corosync-quorumtool"
if not defined? $cur_node_name
$cur_node_name = `hostname`.chomp
end
def configure_logger(log_device)
logger = Logger.new(log_device)
if ENV['PCSD_DEBUG'] and ENV['PCSD_DEBUG'].downcase == "true" then
logger.level = Logger::DEBUG
logger.info "PCSD Debugging enabled"
else
logger.level = Logger::INFO
end
if ISRHEL6
logger.debug "Detected RHEL 6"
else
logger.debug "Did not detect RHEL 6"
end
return logger
end