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

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