Initial resurrection kit — 81 scripts, 62 references, configs, systemd units, crons, Docker compose files, Caddy config, master README
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# wisp-vpn-keepalive.sh — Check VPN status and reconnect if down
|
||||
# Designed to run as a systemd timer every 5 minutes
|
||||
|
||||
VPN_SCRIPT="/root/.hermes/scripts/wisp-backup/home-router-vpn.sh"
|
||||
STATUS_FILE="/tmp/wisp-vpn-status"
|
||||
|
||||
# Check if VPN is up
|
||||
if "$VPN_SCRIPT" status >/dev/null 2>&1; then
|
||||
# VPN is up — write OK timestamp
|
||||
date +%s > "$STATUS_FILE"
|
||||
exit 0
|
||||
else
|
||||
# VPN is down — attempt reconnect
|
||||
LAST_OK=$(cat "$STATUS_FILE" 2>/dev/null || echo "0")
|
||||
NOW=$(date +%s)
|
||||
ELAPSED=$((NOW - LAST_OK))
|
||||
|
||||
echo "[-] WISP VPN is DOWN (was up ${ELAPSED}s ago). Attempting reconnect..."
|
||||
"$VPN_SCRIPT" up 2>&1
|
||||
|
||||
if "$VPN_SCRIPT" status >/dev/null 2>&1; then
|
||||
echo "[+] WISP VPN reconnected successfully"
|
||||
date +%s > "$STATUS_FILE"
|
||||
exit 0
|
||||
else
|
||||
echo "[-] WISP VPN reconnect failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user