wg1-healthcheck.sh hinzugefügt
This commit is contained in:
commit
3fa770e1a1
1 changed files with 18 additions and 0 deletions
18
wg1-healthcheck.sh
Normal file
18
wg1-healthcheck.sh
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue