From 514cc91ed5b0869cb99853832225e99d07721daf Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:41:05 +0100 Subject: [PATCH] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index a7e9d63..3797fe1 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -43,22 +43,30 @@ update_watchdog_config() { done log "Configured watchdog to ping: ${ip_array[*]}" - # Restart watchdog service - if sudo systemctl restart watchdog; then - log "Watchdog service restarted successfully." + # Attempt to restart watchdog service + if ! sudo systemctl restart watchdog; then + log "Failed to restart watchdog service. Attempting to stop and start." - # Stop watchdog-monitor service - if sudo systemctl stop watchdog-monitor; then - log "watchdog-monitor service stopped successfully." + # Fallback: stop then start the service + sudo systemctl stop watchdog + if sudo systemctl start watchdog; then + log "Watchdog service started successfully after stop." else - log "Failed to stop watchdog-monitor service." + log "Failed to start watchdog service after stop." + return 1 fi - - return 0 # Successful restart else - log "Failed to restart watchdog service." - return 1 # Failed restart + log "Watchdog service restarted successfully." fi + + # Stop watchdog-monitor service if restart/start was successful + if sudo systemctl stop watchdog-monitor; then + log "watchdog-monitor service stopped successfully." + else + log "Failed to stop watchdog-monitor service." + fi + + return 0 # Successful restart/start fi }