#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2026 Lorenzo Puliti <plorenzo@disroot.org>
#License: BSD-3-Clause

exec 2>&1

#run it as is to use the default config; to create a '2' instance do:
#cp /etc/powerdns/pdns.conf /etc/powerdns/pdns-2.conf
#cpsv p pdns@default pdns@2 ; update-service --add pdns@2

INSTANCE=${PWD##*@}; CONFIG=pdns-${PWD##*@};
if [ "$INSTANCE" = 'default' ]; then INSTANCE= ; CONFIG=pdns; fi

#config check
[ -r "/etc/powerdns/$CONFIG.conf" ] || exit 162
##bin##  --config=check --config-name=${INSTANCE:-} || exit 162

exec ##bin## --config-name=${INSTANCE:-}  --guardian=no --daemon=no --disable-syslog --log-timestamp=no --write-pid=no --setuid=pdns --setgid=pdns
#NOTE reloading the service restart it instead
