#!/sbin/openrc-run # Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 description="NSD is an authoritative-only, high performance, open source name server" extra_commands="configtest" extra_started_commands="reload" # these can be overridden in /etc/conf.d/nsd if necessary NSD_CONFIG="${NSD_CONFIG:-/etc/nsd/nsd.conf}" NSD_CHECKCONF="${NSD_CHECKCONF:-/usr/sbin/nsd-checkconf}" # NSD always writes a PID file, but writes it insecurely. OpenRC is # going to manage the process anyway, so a PID file created by daemon # is not needed. But since we can't stop it, we force nsd to write the # (insecure) PID file to a junk path. command="${NSD_BINARY:-/usr/sbin/nsd}" command_args="-c ${NSD_CONFIG} -d -P /run/${RC_SVCNAME}.insecure.pid" command_background=true pidfile="/run/${RC_SVCNAME}.pid" required_files="${NSD_CONFIG}" depend() { use logger } checkconfig() { if ! "${NSD_CHECKCONF}" "${NSD_CONFIG}"; then eerror "You have errors in your configfile (${NSD_CONFIG})" return $? fi return 0 } configtest() { ebegin "Checking ${SVCNAME} configuration" checkconfig eend $? } start_pre() { checkconfig || return $? } reload() { checkconfig || return $? ebegin "Reloading config and zone files" start-stop-daemon --signal HUP --pidfile "${pidfile}" eend $? }