#!/sbin/openrc-run # Copyright 1999-2024 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_ARGS="${NSD_ARGS:--d -P ''}" NSD_CONFBASE="${NSD_CONFBASE:-/etc/nsd}" NSD_CONFNAME="${NSD_CONFNAME:-${RC_SVCNAME}.conf}" # The conf.d defaults shipped with nsd-4.9.1+ will run it in the foreground # and tell it not to create a PID file, as we allow OpenRC to handle those # details. config_file="${NSD_CONFBASE}/${NSD_CONFNAME}" checkconf="/usr/sbin/nsd-checkconf" command="/usr/sbin/nsd" command_args="-c ${config_file} ${NSD_ARGS}" command_background=true pidfile="/run/${RC_SVCNAME}.pid" required_files="${config_file}" depend() { use logger } checkconfig() { if ! "${checkconf}" "${config_file}"; then eerror "You have errors in your configfile (${config_file})" return $? fi return 0 } configtest() { ebegin "Checking ${RC_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 $? }