summaryrefslogtreecommitdiff
blob: 244f8f3c650f3edd18f6b90860b3e7eab2de44e3 (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
51
52
53
54
#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

opts="start stop reload"
description="Unbound is a validating, recursive and caching DNS resolver"
description_start="Start the server"
description_stop="Stop the server"
description_reload="Reload the server"

config_file=${config_file:-/etc/unbound/unbound.conf}
my_unbound_checkconf=/usr/sbin/unbound-checkconf
my_unbound_control=/usr/sbin/unbound-control
my_unbound_control_setup=/usr/sbin/unbound-control-setup

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

_checkconf() {
	if ! ${my_unbound_checkconf} "${config_file}" > /dev/null; then
		eerror "You have errors in your configfile (${config_file})"
		return 1
	fi
	return 0
}

_running() {
	${my_unbound_control} -c ${config_file} status > /dev/null 2>&1
}

start() {
	_checkconf || return 1

	ebegin "Starting unbound"
	${my_unbound_control} -c ${config_file} start > /dev/null
	_running
	eend $?
}

stop() {
	ebegin "Stopping unbound"
	${my_unbound_control} -c ${config_file} stop > /dev/null
	eend $?
}

reload() {
	ebegin "Reloading unbound"
	${my_unbound_control} -c ${config_file} reload > dev/null
	eend $?
}