blob: 9cc3d309a43f73e7d576069d5f2d19dbac307af1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/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}
# set defaults
kresd_enable=${kresd_enable:-"NO"}
kresd_config=${kresd_config:-"%%ETCDIR%%/${name}.conf"}
kresd_user="%%USERS%%"
kresd_group="%%GROUPS%%"
kresd_rundir="/var/run/${name}"
pidfile="${kresd_rundir}/${name}.pid"
procname="%%PREFIX%%/sbin/${name}"
required_files="${kresd_config}"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
command="/usr/sbin/daemon"
command_args="-c -f -S -r -P ${pidfile} -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
if [ ! -f "${pidfile}" ]; then
echo "starting ${name}..." && \
${command} ${command_args}
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
}
kresd_status() {
if [ -e "${pidfile}" ]; then
echo "${name} is running on pid $(cat $pidfile)."
return 1
else
echo "${name} is not running."
return 0
fi
}
run_rc_command "$1"
|