Blob Blame History Raw
From 65a7f2b88f674b680160b8015cd1ee1ad61b6293 Mon Sep 17 00:00:00 2001
From: AngelaBriel <abriel@suse.com>
Date: Mon, 20 Dec 2021 10:23:24 +0100
Subject: [PATCH] The return value of 'systemctl list-unit-files <service>' is
 not reliable on all SLE15 codestreams, so it is not usable for our resource
 agents. We need to go back to parsing the command output instead and hoping,
 that the output format will not change in the future, because that will
 breake the solution again as well.

---
 heartbeat/SAPHana         | 3 ++-
 heartbeat/SAPHanaTopology | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/heartbeat/SAPHana b/heartbeat/SAPHana
index 3569b3d..ed1ca00 100755
--- a/heartbeat/SAPHana
+++ b/heartbeat/SAPHana
@@ -956,7 +956,8 @@ function chk4systemdsupport() {
     if [ -x "$SYSTEMCTL" ]; then
         if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
             rc=0
-        elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
+        elif $SYSTEMCTL list-unit-files | \
+            awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
             rc=0
         else
             rc=1
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
index 74f3e72..f5dcb30 100755
--- a/heartbeat/SAPHanaTopology
+++ b/heartbeat/SAPHanaTopology
@@ -674,7 +674,8 @@ function chk4systemdsupport() {
     if [ -x "$SYSTEMCTL" ]; then
         if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
             rc=0
-        elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
+        elif $SYSTEMCTL list-unit-files | \
+            awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
             rc=0
         else
             rc=1