usr/bin/watchdog hinzugefügt
This commit is contained in:
19
usr/bin/watchdog
Normal file
19
usr/bin/watchdog
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
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"
|
||||||
|
config_file="/etc/watchdog.conf"
|
||||||
|
sudo cp "$config_file" "$config_file.bak"
|
||||||
|
sudo sed -i '/ping/d' "$config_file"
|
||||||
|
sudo sed -i '/^interval/d' "$config_file"
|
||||||
|
echo "interval = 60" | sudo tee -a "$config_file" > /dev/null
|
||||||
|
if [ ${#ip_array[@]} -eq 0 ]; then
|
||||||
|
sudo sed -i '/interval/d' "$config_file"
|
||||||
|
echo "No IP addresses found. Watchdog configuration cleared." >&2
|
||||||
|
sudo systemctl stop watchdog
|
||||||
|
else
|
||||||
|
for ip in "${ip_array[@]}"; do
|
||||||
|
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
sudo systemctl restart watchdog
|
||||||
Reference in New Issue
Block a user