From 987f075e80c57f785f561230526b9019f701612a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 8 Apr 2024 00:28:45 +0200 Subject: [PATCH] Use systemd is-active instead of systemd status --- hooks/post_iptable_rules | 3 +-- scripts/backup | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hooks/post_iptable_rules b/hooks/post_iptable_rules index b47e590..d44f347 100644 --- a/hooks/post_iptable_rules +++ b/hooks/post_iptable_rules @@ -1,7 +1,6 @@ #/bin/bash -if [[ $(systemctl status __APP__.service | grep "Active" | cut -d'(' -f2 | cut -d ')' -f1) = 'running' ]] -then +if systemctl is-active __APP__.service --quiet; then systemctl stop monitorix.service sleep 1 pkill -f "monitorix-httpd listening on" || true diff --git a/scripts/backup b/scripts/backup index ab04045..ce158a9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ load_vars #================================================= # STOP SYSTEMD SERVICE #================================================= -if [[ ! "$(systemctl status $app.service)" =~ "Active: inactive (dead)" ]]; then +if systemctl is-active $app.service --quiet; then ynh_print_warn --message="It's highly recommended to make your backup when the service is stopped. Please stop $app service with this command before to run the backup 'systemctl stop $app.service'" fi