From 3fa770e1a1445e0141208a4f5f8e77be992de3f0 Mon Sep 17 00:00:00 2001 From: nocci Date: Mon, 22 Dec 2025 11:18:00 +0100 Subject: [PATCH] =?UTF-8?q?wg1-healthcheck.sh=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wg1-healthcheck.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 wg1-healthcheck.sh diff --git a/wg1-healthcheck.sh b/wg1-healthcheck.sh new file mode 100644 index 0000000..90105d0 --- /dev/null +++ b/wg1-healthcheck.sh @@ -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