Blame SOURCES/bz2043021-3-SAPHana-SAPHanaTopology-fix-unit-test-issue.patch

d18f68
From 65a7f2b88f674b680160b8015cd1ee1ad61b6293 Mon Sep 17 00:00:00 2001
d18f68
From: AngelaBriel <abriel@suse.com>
d18f68
Date: Mon, 20 Dec 2021 10:23:24 +0100
d18f68
Subject: [PATCH] The return value of 'systemctl list-unit-files <service>' is
d18f68
 not reliable on all SLE15 codestreams, so it is not usable for our resource
d18f68
 agents. We need to go back to parsing the command output instead and hoping,
d18f68
 that the output format will not change in the future, because that will
d18f68
 breake the solution again as well.
d18f68
d18f68
---
d18f68
 heartbeat/SAPHana         | 3 ++-
d18f68
 heartbeat/SAPHanaTopology | 3 ++-
d18f68
 2 files changed, 4 insertions(+), 2 deletions(-)
d18f68
d18f68
diff --git a/heartbeat/SAPHana b/heartbeat/SAPHana
d18f68
index 3569b3d..ed1ca00 100755
d18f68
--- a/heartbeat/SAPHana
d18f68
+++ b/heartbeat/SAPHana
d18f68
@@ -956,7 +956,8 @@ function chk4systemdsupport() {
d18f68
     if [ -x "$SYSTEMCTL" ]; then
d18f68
         if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
d18f68
             rc=0
d18f68
-        elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
d18f68
+        elif $SYSTEMCTL list-unit-files | \
d18f68
+            awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
d18f68
             rc=0
d18f68
         else
d18f68
             rc=1
d18f68
diff --git a/heartbeat/SAPHanaTopology b/heartbeat/SAPHanaTopology
d18f68
index 74f3e72..f5dcb30 100755
d18f68
--- a/heartbeat/SAPHanaTopology
d18f68
+++ b/heartbeat/SAPHanaTopology
d18f68
@@ -674,7 +674,8 @@ function chk4systemdsupport() {
d18f68
     if [ -x "$SYSTEMCTL" ]; then
d18f68
         if [ -f /etc/systemd/system/"$systemd_unit_name" ]; then
d18f68
             rc=0
d18f68
-        elif $SYSTEMCTL list-unit-files "$systemd_unit_name" >/dev/null 2>&1; then
d18f68
+        elif $SYSTEMCTL list-unit-files | \
d18f68
+            awk '$1 == service { found=1 } END { if (! found) {exit 1}}' service="${systemd_unit_name}.service"; then
d18f68
             rc=0
d18f68
         else
d18f68
             rc=1