From 7619846e9ce7a9e3905c7e2054f5723022013f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Thu, 28 Nov 2024 17:23:13 +0100 Subject: [PATCH] fix: add checks for active services before reloading or restarting bunkerweb and scheduler --- src/linux/scripts/postinstall.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/linux/scripts/postinstall.sh b/src/linux/scripts/postinstall.sh index d048b9287..596bf1c5b 100644 --- a/src/linux/scripts/postinstall.sh +++ b/src/linux/scripts/postinstall.sh @@ -86,9 +86,11 @@ fi # Create bunkerweb if needed if [ "$SERVICE_BUNKERWEB" != "no" ] ; then if [ -f /var/tmp/bunkerweb_upgrade ]; then - # Reload bunkerweb service - echo "Reloading bunkerweb service..." - do_and_check_cmd systemctl reload bunkerweb + if systemctl is-active --quiet bunkerweb; then + # Reload bunkerweb service + echo "Reloading bunkerweb service..." + do_and_check_cmd systemctl reload bunkerweb + fi else # Stop and disable nginx on boot echo "Stop and disable nginx on boot..." @@ -108,10 +110,12 @@ fi # Create scheduler if necessary if [ "$SERVICE_SCHEDULER" != "no" ] ; then - if [ -f /var/tmp/bunkerweb_upgrade ] && systemctl is-active --quiet bunkerweb-scheduler; then - # Reload bunkerweb-scheduler service - echo "Restarting bunkerweb-scheduler service..." - do_and_check_cmd systemctl restart bunkerweb-scheduler + if [ -f /var/tmp/bunkerweb_upgrade ]; then + if systemctl is-active --quiet bunkerweb-scheduler; then + # Reload bunkerweb-scheduler service + echo "Restarting bunkerweb-scheduler service..." + do_and_check_cmd systemctl restart bunkerweb-scheduler + fi else # Auto start BW Scheduler service on boot and start it now echo "Enabling and starting bunkerweb service..."