summaryrefslogtreecommitdiff
path: root/net-dns/knot/files/knot-3.init
blob: 907c328a58d02ae40bacc1a011a4ea5037e5b523 (plain)
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
#!/sbin/openrc-run
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

: ${KNOT_USER:=knot}
: ${KNOT_GROUP:=knot}
: ${KNOT_PIDFILE:=/run/knot.pid}
: ${KNOT_CONFIG:=/etc/knot/knot.conf}

name="knot"
description="High-performance authoritative-only DNS server"
command="/usr/sbin/knotd"
command_args="-c ${KNOT_CONFIG}"
command_user="${KNOT_USER}:${KNOT_GROUP}"
command_background=true
pidfile="${KNOT_PIDFILE}"

extra_commands="checkconfig"
extra_started_commands="reload"

capabilities="^cap_net_bind_service,^cap_setpcap"

checkconfig() {
	/usr/sbin/knotc conf-check 1>/dev/null || return 1
}

reload() {
	checkconfig || return 1
	ebegin "Reloading ${SVCNAME}"
	start-stop-daemon --signal HUP --pidfile $pidfile
	eend $?
}

start_pre() {
	if [ "${RC_CMD}" != "restart" ]; then
		checkconfig || return 1
	fi
}

stop_pre() {
	if [ "${RC_CMD}" != "restart" ]; then
		checkconfig || return 1
	fi
}