wg1-healthcheck.sh hinzugefügt

This commit is contained in:
nocci 2025-12-22 11:18:00 +01:00
commit 3fa770e1a1

18
wg1-healthcheck.sh Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
TARGET_IP="1.1.1.1" # oder 8.8.8.8 o.ä.
PING_COUNT=3
IFACE="wg1"
SERVICE="wg-quick@${IFACE}.service"
LOGTAG="wg1-healthcheck"
if ping -4 -c "${PING_COUNT}" -W 2 "${TARGET_IP}" >/dev/null 2>&1; then
logger -t "${LOGTAG}" "IPv4 connectivity OK to ${TARGET_IP}"
exit 0
else
logger -t "${LOGTAG}" "IPv4 connectivity FAILED to ${TARGET_IP}, restarting ${SERVICE}"
systemctl restart "${SERVICE}"
exit 1
fi