#!/bin/sh
# kemangVPN: strongSwan resolve plugin hook (charon.plugins.resolve.resolvconf.path).
# charon runs "kv-resolvconf -a IFACE" with "nameserver ADDR" lines on stdin for each DNS server pushed by the
# IKEv2 server. We only record them; kemangvpnd applies them through systemd-resolved on the link kvike0 and
# deletes the file on disconnect. Nothing else on the system is touched.
F=/run/kemangvpn/ikev2-resolv.conf
case "$1" in
    -a) mkdir -p /run/kemangvpn && umask 077 && cat >> "$F" ;;
    *) cat >/dev/null ;;
esac
exit 0
