aboutsummaryrefslogtreecommitdiffstats
path: root/main/unbound/unbound.initd
blob: 136ce01ccf9ee377417295847626bd25660be7c4 (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
45
46
47
48
49
50
#!/sbin/openrc-run
supervisor=supervise-daemon

extra_commands="checkconfig configtest"
extra_started_commands="reload"

name="unbound daemon"
description="unbound is a Domain Name Server (DNS) that is used to resolve host names to IP address."
description_checkconfig="Run syntax tests for configuration files only."
description_reload="Kills all children and reloads the configuration."

# Upper case variables are here only for backward compatibility.
: ${cfgfile:=${UNBOUND_CONFFILE:-/etc/unbound/$RC_SVCNAME.conf}}

command=/usr/sbin/unbound
command_args="$command_args"
command_args_foreground="-d"

required_files="$cfgfile"

depend() {
	need net
	use logger
	provide dns
	after auth-dns entropy
}

checkconfig() {
	ebegin "Checking $cfgfile"
	/usr/sbin/unbound-checkconf -f "$cfgfile" >/dev/null
	eend $?
}

start_pre() {
	checkconfig || return 1

	local i; for i in $(/usr/sbin/unbound-checkconf -o control-interface "$cfgfile"); do
		case "$i" in
		*/*) test -d "$i" || checkpath -d -m 750 -o unbound:unbound "$(dirname "$i")" || return 1
		esac
	done
}

reload() {
	start_pre || return $?

	ebegin "Reloading $name"
	$supervisor "$RC_SVCNAME" --signal HUP
	eend $?
}