From cbe2be5bf2506c8b7bf132c5b99657f5cfd9e405 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 31 May 2023 11:35:14 -0500 Subject: [PATCH] SYSTEMCTL: Check if running before stopping When uninstalling the RDC application - the user is greeted with an annoying "Failed to stop rdc.service..." message if the RDC is not running. This change makes sure RDC is active before trying to stop it. Change-Id: I6fa57bfd4b9c348514cd6c38e60ed3930d32b62c Signed-off-by: Galantsev, Dmitrii [ROCm/rdc commit: 6e52a113a2ca098bcb318ba8f3df12e6bd9c75d0] --- projects/rdc/src/DEBIAN_prerm.in | 4 ++-- projects/rdc/src/RPM_postun.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/rdc/src/DEBIAN_prerm.in b/projects/rdc/src/DEBIAN_prerm.in index ffbbab79d0..a047f2c35a 100644 --- a/projects/rdc/src/DEBIAN_prerm.in +++ b/projects/rdc/src/DEBIAN_prerm.in @@ -1,8 +1,8 @@ #!/bin/bash stop_rdc() { - if [ -d /run/systemd/system ]; then - #stop RDC if running + #stop RDC service if systemd exists and service is running + if [ -d /run/systemd/system ] && $( systemctl is-active --quiet rdc ); then systemctl stop rdc fi return 0 diff --git a/projects/rdc/src/RPM_postun.in b/projects/rdc/src/RPM_postun.in index 601c346dfe..c0b7f3c676 100755 --- a/projects/rdc/src/RPM_postun.in +++ b/projects/rdc/src/RPM_postun.in @@ -1,8 +1,8 @@ #!/bin/bash stop_rdc() { - #stop RDC if running - if [ -d /run/systemd/system ]; then + #stop RDC service if systemd exists and service is running + if [ -d /run/systemd/system ] && $( systemctl is-active --quiet rdc ); then systemctl stop rdc fi return 0