usr/bin/custom/watchdog-monitor aktualisiert
This commit is contained in:
@@ -35,14 +35,18 @@ update_watchdog_config() {
|
||||
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||
done
|
||||
echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file"
|
||||
|
||||
# Restart watchdog service since IP addresses were found
|
||||
if sudo systemctl restart watchdog; then
|
||||
echo "Watchdog service restarted successfully." >> "$log_file"
|
||||
else
|
||||
echo "Failed to restart watchdog service." >> "$log_file"
|
||||
fi
|
||||
|
||||
return 1 # Indicate that IP addresses were found
|
||||
fi
|
||||
|
||||
# Restart watchdog service
|
||||
if sudo systemctl restart watchdog; then
|
||||
echo "Watchdog service restarted successfully." >> "$log_file"
|
||||
else
|
||||
echo "Failed to restart watchdog service." >> "$log_file"
|
||||
fi
|
||||
return 0 # Indicate that no IP addresses were found
|
||||
}
|
||||
|
||||
# Main loop
|
||||
@@ -51,8 +55,11 @@ end_time=$((start_time + 300)) # 5 minutes in seconds
|
||||
interval=30 # Initial interval of 30 seconds
|
||||
|
||||
while true; do
|
||||
update_watchdog_config
|
||||
|
||||
if update_watchdog_config; then
|
||||
echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file"
|
||||
break # Exit the loop if IP addresses were found
|
||||
fi
|
||||
|
||||
current_time=$(date +%s)
|
||||
|
||||
# Check if 5 minutes have passed
|
||||
Reference in New Issue
Block a user