File 0035-Low-Refactor-systemd-detection.patch of Package resource-agents.11561

From 2727e58d7829c62d0aae55def64dcdb826191808 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Mon, 19 Feb 2018 11:57:44 +0100
Subject: [PATCH 31/33] Low: Refactor systemd detection

Introduce a common helper function to express the semantics of the call
and allow easier modifications.
---
 heartbeat/LVM               | 2 +-
 heartbeat/clvm              | 2 +-
 heartbeat/ocf-shellfuncs.in | 9 +++++++++
 heartbeat/tomcat            | 5 ++++-
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/heartbeat/LVM b/heartbeat/LVM
index 3db61d9f..1a1546de 100755
--- a/heartbeat/LVM
+++ b/heartbeat/LVM
@@ -418,7 +418,7 @@ LVM_start() {
 
 	# systemd drop-in to stop process before storage services during
 	# shutdown/reboot
-	if ps -p 1 | grep -q systemd ; then
+	if systemd_is_running ; then
 		systemd_drop_in "99-LVM" "After" "blk-availability.service"
 	fi
 
diff --git a/heartbeat/clvm b/heartbeat/clvm
index 1197baf9..9525e410 100755
--- a/heartbeat/clvm
+++ b/heartbeat/clvm
@@ -364,7 +364,7 @@ clvmd_start()
 
 	# systemd drop-in to stop process before storage services during
 	# shutdown/reboot
-	if ps -p 1 | grep -q systemd ; then
+	if systemd_is_running ; then
 		systemd_drop_in "99-clvmd" "After" "blk-availability.service"
 	fi
 
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
index 695c62e6..670bdda4 100644
--- a/heartbeat/ocf-shellfuncs.in
+++ b/heartbeat/ocf-shellfuncs.in
@@ -606,6 +606,15 @@ dirname()
 	return 0
 }
 
+# usage: systemd_is_running
+# returns:
+#    0  PID 1 is systemd
+#    1  otherwise
+systemd_is_running()
+{
+	[ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ]
+}
+
 # usage: systemd_drop_in <name> <After|Before> <dependency.service>
 systemd_drop_in()
 {
diff --git a/heartbeat/tomcat b/heartbeat/tomcat
index 07a7ce41..e5220e33 100755
--- a/heartbeat/tomcat
+++ b/heartbeat/tomcat
@@ -618,7 +618,10 @@ LOGGING_CONFIG="${OCF_RESKEY_logging_config}"
 LOGGING_MANAGER="${OCF_RESKEY_logging_manager}"
 
 if [ -z "${TOMCAT_START_SCRIPT}" ]; then
-	if [ -e "$CATALINA_HOME/bin/catalina.sh" ]; then
+	if ocf_is_true $OCF_RESKEY_force_systemd && \
+	     systemd_is_running; then
+		SYSTEMD=1
+	elif [ -e "$CATALINA_HOME/bin/catalina.sh" ]; then
 		TOMCAT_START_SCRIPT="$CATALINA_HOME/bin/catalina.sh"
 	elif [ -e "/usr/sbin/tomcat" ]; then
 		REDIRECT_DEFAULT_CONFIG=1
-- 
2.16.4

openSUSE Build Service is sponsored by