freebsd-ports/dns/knot-resolver/files/kresd.in
Leo Vandewoestijne 42b2996954 dns/knot-resolver: fixing rc scripts krescachegc and kresd
* kresd.i lacked activation of defined status_cmd="${name}_status"

 * dns/knot-resolver/files/krescachegc.in needed full clean-up:

	* daemon didn't start due to missing '-c <resolver_cache>'
	* missing 'start', 'stop' and 'status' functionality added

PR:		277540
Reported by:	trashcan@ellael.org
2024-08-08 16:36:09 +02:00

78 lines
1.8 KiB
Bash

#!/bin/sh
# PROVIDE: kresd
# REQUIRE: NETWORKING
# BEFORE: SERVERS
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable knot-resolver:
#
# kresd_enable="YES": Set to YES to enable kresd.
# Set to NO by default.
# kresd_config="": Set to %%ETCDIR%%/kresd.conf
# by default.
#
. /etc/rc.subr
name=kresd
rcvar=kresd_enable
load_rc_config ${name}
: ${kresd_enable:="NO"}
: ${kresd_svcj_options:="net_basic"}
: ${kresd_config:="%%ETCDIR%%/${name}.conf"}
: ${kresd_user:="%%USERS%%"}
: ${kresd_group:="%%GROUPS%%"}
: ${kresd_rundir:="%%RUNDIR%%"}
procname="%%PREFIX%%/sbin/${name}"
required_files="${kresd_config}"
start_cmd="${name}_start"
status_cmd="${name}_status"
stop_cmd="${name}_stop"
command="/usr/sbin/daemon"
command_args="-c -f -r -S -T ${name} -- ${procname} -c ${kresd_config} -n -q ${kresd_rundir}"
kresd_start() {
if [ ! -d /var/run/${name} ]; then
install -d -o ${kresd_user} -g ${kresd_group} -m 700 ${kresd_rundir}
fi
/bin/pgrep -f ${procname} > /dev/null && status="$?" || status="$?"
if [ "${status}" -eq 0 ]; then
echo "${name} already seems to be running."
else
echo "starting ${name}..." && \
${command} ${command_args}
echo -e "\e[1A\e[K${name} started."
fi
}
kresd_status() {
/bin/pgrep -f ${procname} > /dev/null && status="$?" || status="$?"
if [ "${status}" -eq 0 ]; then
echo "${name} is running:"
echo
/bin/ps -p $(/bin/pgrep -f ${procname})
else
echo "${name} is not running"
fi
return ${status}
}
kresd_stop() {
/bin/pgrep -f ${procname} > /dev/null && status="$?" || status="$?"
if [ "${status}" -eq 0 ]; then
echo "stopping ${name}..." && \
/bin/pkill -TERM -f ${procname}
echo -e "\e[1A\e[K${name} stopped."
else
echo "${name} is not running"
fi
return ${status}
}
run_rc_command "$1"