#!/bin/sh set -eu wg show wg0 >/dev/null ip link show wg0 | grep -q 'state UNKNOWN\|state UP' latest=$(wg show wg0 latest-handshakes | cut -f2 | head -n 1) now=$(date +%s) [ "${latest:-0}" -gt 0 ] [ $((now - latest)) -lt 180 ] kill -0 1