stable #2

Merged
alientim merged 89 commits from stable into dev 2024-11-15 10:37:11 +01:00
Showing only changes of commit 63a40835b6 - Show all commits

View File

@@ -12,7 +12,8 @@ update_watchdog_config() {
watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \
awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";')
IFS=' ' read -r -a ip_array <<< "$watchdog"
# Split the watchdog IPs into an array
IFS=',' read -r -a ip_array <<< "$watchdog"
# Backup current configuration
if sudo cp "$config_file" "$config_file.bak"; then
@@ -28,13 +29,12 @@ update_watchdog_config() {
# Set interval
echo "interval = 59" | sudo tee -a "$config_file" > /dev/null
if [ ${#ip_array[@]} -eq 0 ]; then
echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file"
else
# Check if IP addresses are found and add them to the config
if [ ${#ip_array[@]} -gt 0 ]; then
for ip in "${ip_array[@]}"; do
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
echo "Configured watchdog to ping: $ip" >> "$log_file"
done
echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file"
# Restart watchdog service since IP addresses were found
if sudo systemctl restart watchdog; then
@@ -42,13 +42,14 @@ update_watchdog_config() {
else
echo "Failed to restart watchdog service." >> "$log_file"
fi
return 1 # Indicate that IP addresses were found
fi
echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file"
return 0 # Indicate that no IP addresses were found
}
# Main loop
start_time=$(date +%s)
end_time=$((start_time + 300)) # 5 minutes in seconds