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
This commit is contained in:
Leo Vandewoestijne 2024-08-07 17:37:28 +02:00 committed by Fernando Apesteguía
parent a840d97b16
commit 42b2996954
5 changed files with 85 additions and 42 deletions

View File

@ -1,6 +1,5 @@
PORTNAME= knot-resolver PORTNAME= knot-resolver
DISTVERSION= 5.7.2 DISTVERSION= 5.7.3
PORTREVISION= 1
CATEGORIES= dns CATEGORIES= dns
MASTER_SITES= https://secure.nic.cz/files/knot-resolver/ \ MASTER_SITES= https://secure.nic.cz/files/knot-resolver/ \
https://dns.company/downloads/knot-resolver/ https://dns.company/downloads/knot-resolver/

View File

@ -1,3 +1,3 @@
TIMESTAMP = 1713104201 TIMESTAMP = 1722850725
SHA256 (knot-resolver-5.7.2.tar.xz) = 5f6a227390fcd4c2d0a8028a652b55a9d863ec7be01298fe038df1d273fb9a0f SHA256 (knot-resolver-5.7.3.tar.xz) = efc6e45ffc5efd98921ea5cd3fece166a1a5ce9eaa12d41b46268964353dbedb
SIZE (knot-resolver-5.7.2.tar.xz) = 1928336 SIZE (knot-resolver-5.7.3.tar.xz) = 1930732

View File

@ -18,16 +18,58 @@ name=krescachegc
rcvar=krescachegc_enable rcvar=krescachegc_enable
load_rc_config ${name} load_rc_config ${name}
load_rc_config_var kresd rundir
load_rc_config_var kresd user
# set defaults : ${krescachegc_enable:="NO"}
krescachegc_enable=${krescachegc_enable:-"NO"}
: ${krescachegc_svcj_options:="net_basic"} : ${krescachegc_svcj_options:="net_basic"}
krescachegc_millis=${krescachegc_millis:-"1000"} : ${krescachegc_millis:="1000"}
: ${kresd_rundir:="/var/run/kresd"}
: ${kresd_user:="%%USERS%%"}
pidfile="%%RUNDIR%%/${name}.pid"
procname="%%PREFIX%%/sbin/kres-cache-gc" procname="%%PREFIX%%/sbin/kres-cache-gc"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
command=/usr/sbin/daemon command=/usr/sbin/daemon
command_args="-c -f -S -r -P ${pidfile} -T ${name} -u %%USERS%% -- ${procname} -d ${krescachegc_millis}" command_args="-c -f -r -S -u ${kresd_user} -T ${name} -- ${procname} -c ${kresd_rundir} -d ${krescachegc_millis}"
krescachegc_start() {
/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
}
krescachegc_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}
}
krescachegc_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" run_rc_command "$1"

View File

@ -20,57 +20,59 @@ rcvar=kresd_enable
load_rc_config ${name} load_rc_config ${name}
# set defaults : ${kresd_enable:="NO"}
kresd_enable=${kresd_enable:-"NO"}
: ${kresd_svcj_options:="net_basic"} : ${kresd_svcj_options:="net_basic"}
kresd_config=${kresd_config:-"%%ETCDIR%%/${name}.conf"} : ${kresd_config:="%%ETCDIR%%/${name}.conf"}
kresd_user="%%USERS%%" : ${kresd_user:="%%USERS%%"}
kresd_group="%%GROUPS%%" : ${kresd_group:="%%GROUPS%%"}
kresd_rundir="/var/run/${name}" : ${kresd_rundir:="%%RUNDIR%%"}
pidfile="${kresd_rundir}/${name}.pid"
procname="%%PREFIX%%/sbin/${name}" procname="%%PREFIX%%/sbin/${name}"
required_files="${kresd_config}" required_files="${kresd_config}"
start_cmd="${name}_start" start_cmd="${name}_start"
status_cmd="${name}_status"
stop_cmd="${name}_stop" stop_cmd="${name}_stop"
command="/usr/sbin/daemon" command="/usr/sbin/daemon"
command_args="-c -f -S -r -P ${pidfile} -T ${name} -- ${procname} -c ${kresd_config} -n -q ${kresd_rundir}" command_args="-c -f -r -S -T ${name} -- ${procname} -c ${kresd_config} -n -q ${kresd_rundir}"
kresd_start() { kresd_start() {
if [ ! -d /var/run/${name} ]; then if [ ! -d /var/run/${name} ]; then
install -d -o ${kresd_user} -g ${kresd_group} -m 700 ${kresd_rundir} install -d -o ${kresd_user} -g ${kresd_group} -m 700 ${kresd_rundir}
fi fi
if [ ! -f "${pidfile}" ]; then /bin/pgrep -f ${procname} > /dev/null && status="$?" || status="$?"
if [ "${status}" -eq 0 ]; then
echo "${name} already seems to be running."
else
echo "starting ${name}..." && \ echo "starting ${name}..." && \
${command} ${command_args} ${command} ${command_args}
echo -e "\e[1A\e[K${name} started." echo -e "\e[1A\e[K${name} started."
else
echo "${name} already seems to be running."
fi
}
kresd_stop() {
if [ -f "${pidfile}" ]; then
echo "stopping ${name}..." && \
for pid in `ps waux | grep ${procname} | grep daemon | awk '{print $2}'`; do \
kill -TERM $pid
done
echo -e "\e[1A\e[K${name} stopped."
else
echo "${name} seems to be not running."
fi fi
} }
kresd_status() { kresd_status() {
if [ -e "${pidfile}" ]; then /bin/pgrep -f ${procname} > /dev/null && status="$?" || status="$?"
echo "${name} is running on pid $(cat $pidfile)." if [ "${status}" -eq 0 ]; then
return 1 echo "${name} is running:"
echo
/bin/ps -p $(/bin/pgrep -f ${procname})
else else
echo "${name} is not running." echo "${name} is not running"
return 0
fi 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" run_rc_command "$1"

View File

@ -96,4 +96,4 @@ sbin/kres-cache-gc
sbin/kresc sbin/kresc
sbin/kresd sbin/kresd
@dir(%%USERS%%,%%GROUPS%%,0755) %%ETCDIR%% @dir(%%USERS%%,%%GROUPS%%,0755) %%ETCDIR%%
@dir(%%USERS%%,%%GROUPS%%,0660) %%RUNDIR%% @dir(%%USERS%%,%%GROUPS%%,0700) %%RUNDIR%%