aboutsummaryrefslogtreecommitdiffstats
path: root/main/nsd/nsd.initd
blob: d1ac1c7c8f0d4e45a0fe56af86fe3501adf8d3ab (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
#!/sbin/openrc-run

name="NSD"

extra_commands="checkconfig"
extra_started_commands="reload reopen"

description="An authoritative-only, high performance, open source name server"
description_checkconfig="Checks NSD configuration file for errors"
description_reload="Reloads NSD config file and modified zone files from disk"
description_reopen="Reopen NSD log file (for logrotate)"

: ${cfgfile:=${NSD_CONFIG:-"/etc/nsd/nsd.conf"}}  # NSD_CONFIG is for backward compatibility

command="/usr/sbin/nsd"
command_args="-c $cfgfile -d -P '' ${command_args:-}"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"
start_stop_daemon_args="--wait 50"

required_files="$cfgfile"

depend() {
	need net
	use logger
}

start_pre() {
	checkconfig
}

checkconfig() {
	ebegin "Checking $name config file"
	/usr/sbin/nsd-checkconf "$cfgfile"
	eend $?
}

reload() {
	ebegin "Reloading $name config file and all zones"
	/usr/sbin/nsd-control reconfig && /usr/sbin/nsd-control reload
	eend $?
}

reopen() {
	ebegin "Reopening $name log file"
	/usr/sbin/nsd-control log_reopen
	eend $?
}