From 4bd0ebc0143996757097c70ff32f3ead9e8ad240 Mon Sep 17 00:00:00 2001 From: Giacomo Sanchietti Date: Fri, 28 Feb 2025 10:33:34 +0100 Subject: [PATCH] fix(node-monitor): make sure it's really stopped Prevent this error on some machines: Failed to disable unit: Unit file node-monitor.service does not exist. The error is likely caused by a race condition --- .../node/update-core.d/80node_monitor | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/imageroot/var/lib/nethserver/node/update-core.d/80node_monitor b/core/imageroot/var/lib/nethserver/node/update-core.d/80node_monitor index 558e7787a..38c9d58c5 100755 --- a/core/imageroot/var/lib/nethserver/node/update-core.d/80node_monitor +++ b/core/imageroot/var/lib/nethserver/node/update-core.d/80node_monitor @@ -10,7 +10,21 @@ set -e if systemctl -q is-active node-monitor.service; then echo "Disabling node-monitor as service" - systemctl disable --now node-monitor - rm -f /etc/systemd/system/node-monitor.service + systemctl stop node-monitor + # Wait until node-monitor is really stopped, maximum wait time 1 minute + for i in {1..60}; do + if ! systemctl -q is-active node-monitor; then + echo "node-monitor is stopped" + break + fi + sleep 1 + done + if systemctl -q is-active node-monitor; then + echo "Failed to stop node-monitor within 1 minute" + exit 1 + fi + # The disable mai fail if the the update-core has already removed the service file + systemctl disable --now node-monitor || : + rm -fv /etc/systemd/system/node-monitor.service systemctl daemon-reload fi