#!/bin/sh

set -e

if command -v modprobe >/dev/null 2>&1; then
	for m in tun wireguard tcp_bbr; do
		modprobe "$m" 2>/dev/null || true
	done
fi

if command -v systemctl >/dev/null 2>&1; then
	systemctl daemon-reload || true
	systemctl try-restart --no-block tunad.service || true
	systemctl enable --now --no-block tunad.service || true
else
	echo "systemctl not available, skipping tunad.service activation"
fi

exit 0
