Skip to content

Commit

Permalink
Fix systemctl compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Egesdahl authored and tomjelinek committed Feb 9, 2015
1 parent 2eea6ef commit f1a8b48
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
22 changes: 19 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@ ifeq ($(PYTHON_SITELIB), /usr/lib/python2.7/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif

IS_SYSTEMCTL=false
ifeq ("$(wildcard /usr/bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
else
ifeq ("$(wildcard /bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
endif
endif

MANDIR=/usr/share/man

ifndef PREFIX
PREFIX=$(shell prefix=`python -c "import sys; print(sys.prefix)"` || prefix="/usr"; echo $$prefix)
endif
ifndef initdir
initdir=/etc/init.d
endif
install: bash_completion
python setup.py install --prefix ${DESTDIR}${PREFIX} ${EXTRA_SETUP_OPTS}
mkdir -p ${DESTDIR}${PREFIX}/sbin/
Expand All @@ -28,13 +41,16 @@ install_pcsd:
mkdir -p ${DESTDIR}${PREFIX}/lib/
cp -r pcsd ${DESTDIR}${PREFIX}/lib/
install -m 644 -D pcsd/pcsd.conf ${DESTDIR}/etc/sysconfig/pcsd
install -d ${DESTDIR}/usr/lib/systemd/system/
install -m 644 pcsd/pcsd.service ${DESTDIR}/usr/lib/systemd/system/
install -d ${DESTDIR}/etc/pam.d
install pcsd/pcsd.pam ${DESTDIR}/etc/pam.d/pcsd
install -m 700 -d ${DESTDIR}/var/lib/pcsd
install -m 644 -D pcsd/pcsd.logrotate ${DESTDIR}/etc/logrotate.d/pcsd
# install -m 755 -D pcsd/pcsd ${DESTDIR}/${initdir}/pcsd
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/usr/lib/systemd/system/
install -m 644 pcsd/pcsd.service ${DESTDIR}/usr/lib/systemd/system/
else
install -m 755 -D pcsd/pcsd ${DESTDIR}/${initdir}/pcsd
endif
uninstall:
rm -f ${DESTDIR}${PREFIX}/sbin/pcs
Expand Down
2 changes: 1 addition & 1 deletion pcs/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def resource_list_available(argv):
if os.access(lsb_dir + agent, os.X_OK):
ret += "lsb:" + agent + "\n"
# systemd agents
if not utils.is_rhel6():
if utils.is_systemctl():
agents, retval = utils.run(["systemctl", "list-unit-files", "--full"])
agents = agents.split("\n")

Expand Down
12 changes: 6 additions & 6 deletions pcsd/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def disable_cluster()
end

def corosync_running?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl status corosync.service`
else
`service corosync status`
Expand All @@ -593,7 +593,7 @@ def corosync_running?()
end

def corosync_enabled?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl is-enabled corosync.service`
else
`chkconfig corosync`
Expand All @@ -602,7 +602,7 @@ def corosync_enabled?()
end

def pacemaker_running?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl status pacemaker.service`
else
`service pacemaker status`
Expand All @@ -611,7 +611,7 @@ def pacemaker_running?()
end

def pacemaker_enabled?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl is-enabled pacemaker.service`
else
`chkconfig pacemaker`
Expand All @@ -620,7 +620,7 @@ def pacemaker_enabled?()
end

def cman_running?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl status cman.service`
else
`service cman status`
Expand All @@ -629,7 +629,7 @@ def cman_running?()
end

def pcsd_enabled?()
if not ISRHEL6
if ISSYSTEMCTL
`systemctl is-enabled pcsd.service`
else
`chkconfig pcsd`
Expand Down
1 change: 1 addition & 0 deletions pcsd/pcsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

configure do
ISRHEL6 = is_rhel6
ISSYSTEMCTL = is_systemctl
DISABLE_GUI = false

OCF_ROOT = "/usr/lib/ocf"
Expand Down
16 changes: 13 additions & 3 deletions pcsd/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def is_rhel6()
end
end

def is_systemctl()
if File.exist?('/usr/bin/systemctl')
return true
else
return false
end
end

CRT_FILE = "/var/lib/pcsd/pcsd.crt"
KEY_FILE = "/var/lib/pcsd/pcsd.key"
Expand Down Expand Up @@ -45,11 +52,14 @@ def is_rhel6()
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(KEY_FILE).read()),
:SSLCertName => [[ "CN", server_name ]],
:SSLOptions => OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3,
:StartCallback => Proc.new {
`python /usr/lib/pcsd/systemd-notify-fix.py`
}
}

if is_systemctl
webrick_options[:StartCallback] = Proc.new {
`python /usr/lib/pcsd/systemd-notify-fix.py`
}
end

server = ::Rack::Handler::WEBrick
trap(:INT) do
puts "Shutting down (INT)"
Expand Down

0 comments on commit f1a8b48

Please sign in to comment.