Skip to content

Commit

Permalink
Check if systemd is currently running (Fixes #118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjelinek committed Aug 25, 2017
1 parent fbfe34f commit 604692f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
### Fixed
- Fixed some crashes when pcs encounters a non-ascii character in environment
variables, command line arguments and so on ([rhbz#1435697])
- Fixed detecting if systemd is in use ([ghissue#118])

[ghissue#118]: https://github.com/ClusterLabs/pcs/issues/118
[rhbz#1435697]: https://bugzilla.redhat.com/show_bug.cgi?id=1435697


Expand Down
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,14 @@ ifeq ($(PYTHON_SITELIB), /usr/lib/python2.7/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif

# Check for systemd presence, add compatibility with Debian based distros
IS_SYSTEMCTL=false

ifeq ($(IS_DEBIAN),true)
IS_SYSTEMCTL = $(shell if [ -d /var/run/systemd/system ] ; then echo true ; else echo false; fi)
ifeq ($(IS_SYSTEMCTL),false)
ifeq ($(SYSTEMCTL_OVERRIDE),true)
IS_SYSTEMCTL=true
endif
endif
# Check for systemd presence
ifeq ($(SYSTEMCTL_OVERRIDE),true)
IS_SYSTEMCTL=true
else
ifeq ("$(wildcard /usr/bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
ifeq ($(SYSTEMCTL_OVERRIDE),false)
IS_SYSTEMCTL=false
else
ifeq ("$(wildcard /bin/systemctl)","/usr/bin/systemctl")
IS_SYSTEMCTL=true
endif
IS_SYSTEMCTL = $(shell if [ -d /run/systemd/system ] || [ -d /var/run/systemd/system ] ; then echo true ; else echo false; fi)
endif
endif

Expand Down
12 changes: 8 additions & 4 deletions pcsd/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ def is_rhel6()

def is_systemctl()
systemctl_paths = [
'/usr/bin/systemctl',
'/bin/systemctl',
'/var/run/systemd/system',
'/run/systemd/system',
'/var/run/systemd/system',
]
systemctl_paths.each { |path|
return true if File.exist?(path)
return true if File.directory?(path)
}
return false
end
Expand Down Expand Up @@ -78,6 +76,12 @@ def configure_logger(log_device)
else
logger.debug "Did not detect RHEL 6"
end

if ISSYSTEMCTL
logger.debug "Detected systemd is in use"
else
logger.debug "Detected systemd is not in use"
end
return logger
end

0 comments on commit 604692f

Please sign in to comment.