#!/bin/bash # Check if WireGuard tunnel is up, restart if down PING=/bin/ping SERVICE=/usr/bin/systemctl tries=0 while [[ $tries -lt 3 ]] do if $PING -c 1 10.10.10.1 &> /dev/null then exit 0 fi tries=$((tries+1)) sleep 2 done # Failed 3 times, restart $SERVICE restart wg-quick@wg0