From 0378024409747950f90a177f650cb4d2e39c77c9 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:22:34 +0100 Subject: [PATCH] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index d6b6535..a7e9d63 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -23,18 +23,21 @@ update_watchdog_config() { sudo cp "$config_file" "$config_file.bak" log "Backup of $config_file created successfully." - # Clean existing configurations - sudo sed -i '/ping/d' "$config_file" - sudo sed -i '/^interval/d' "$config_file" - - # Set interval - echo "interval = 58" | sudo tee -a "$config_file" > /dev/null + # Write static configuration to file + { + echo "realtime = yes" + echo "priority = 1" + echo "interface = eth0" + echo "interval = 58" + echo "ping-count = 1" + } | sudo tee "$config_file" > /dev/null + log "Static configuration written to $config_file." if [ ${#ip_array[@]} -eq 0 ]; then log "No IP addresses found. Watchdog configuration cleared." return 1 # No IP addresses to configure else - # Insert IPs into config + # Append IPs to config for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done @@ -43,6 +46,14 @@ update_watchdog_config() { # Restart watchdog service if sudo systemctl restart watchdog; then log "Watchdog service restarted successfully." + + # Stop watchdog-monitor service + 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 else log "Failed to restart watchdog service."