1
0

profiles/wg-clerie: Convert systemd timer into a service with sleep

This commit is contained in:
2025-05-08 11:34:05 +02:00
parent 1c087b0c9f
commit 69ccc0c692
2 changed files with 36 additions and 34 deletions

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
prev_endpoint=""
while true; do
if ! wg show wg-clerie endpoints &>/dev/null; then
if [[ "${prev_endpoint}" != "" ]]; then
echo "Interface wg-clerie unavailable, doing nothing"
prev_endpoint=""
fi
sleep 5
continue
fi
if ip route get 2a01:4f8:c0c:15f1::1 ipproto udp dport 51820 &>/dev/null; then
new_endpoint="[2a01:4f8:c0c:15f1::1]:51820"
else
new_endpoint="78.47.183.82:51820"
fi
if [[ "${new_endpoint}" != "${prev_endpoint}" ]]; then
echo "Switching endpoint for wg-clerie to ${new_endpoint}"
wg set wg-clerie peer "2p1Jqs3bkXbXHFWE6vp1yxHIFoUaZQEARS2nJzbkuBA=" endpoint "${new_endpoint}"
prev_endpoint="${new_endpoint}"
fi
sleep 5
done