#!/sbin/openrc-run # Copyright 1999-2018 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 KNOT_DATADIR="${KNOT_DATADIR:-/var/lib/knot}" extra_commands="configtest" extra_started_commands="reload" description_configtest="Run Knot' internal config check" description_reload="Reload configuration and changed zones" name="${name:-Knot DNS}" knotc="/usr/sbin/knotc" command="/usr/sbin/knotd" command_background=true pidfile="/run/${RC_SVCNAME}.pid" required_files="/etc/knot/knot.conf" depend() { need net } start_pre() { checkpath -d -m 0750 -o "knot:knot" "${KNOT_DATADIR}" if [ "${RC_CMD}" != "restart" ]; then configtest || return 1 fi } stop_pre() { if [ "${RC_CMD}" = "restart" ]; then configtest || return 1 fi } stop() { ebegin "Stopping ${name}" if ! ${knotc} stop >/dev/null 2>&1; then # In case remote control is not working if [ -f "${pidfile}" ]; then start-stop-daemon --stop --pidfile "${pidfile}" fi fi eend $? } reload() { configtest || return 1 ebegin "Reloading ${name}" ${knotc} reload >/dev/null 2>&1 eend $? } configtest() { ebegin "Checking ${name} configuration" if ! ${knotc} conf-check >/dev/null 2>&1; then ${knotc} conf-check fi eend $? "Failed, please correct the errors above" }