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

: ${KNOT_USER:=knot}
: ${KNOT_GROUP:=knot}
: ${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="/run/${RC_SVCNAME}.pid"

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
}