#!/bin/sh /etc/rc.common

START=99

USE_PROCD=1
PROG=/usr/bin/coredns
CONF=coredns

start_service() {
	local corefile

	config_load "$CONF"
	config_get corefile daemon config /etc/Corefile

	procd_open_instance

	procd_add_jail coredns log procfs sysfs
	procd_add_jail_mount /etc/TZ
	procd_add_jail_mount /etc/ssl/certs
	procd_add_jail_mount "$corefile"
	config_list_foreach daemon ro_mount procd_add_jail_mount

	procd_set_param command "$PROG" -conf "$corefile"
	procd_set_param respawn
	procd_set_param stdout 1
	procd_set_param stderr 1

	procd_close_instance
}
