aboutsummaryrefslogtreecommitdiffstats
path: root/testing/unbound/unbound.initd
blob: 08944b60efafc9a05ecb772ed46820080dcfe7e4 (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: /var/cvsroot/gentoo-x86/net-dns/unbound/files/unbound.initd,v 1.1 2009/11/22 16:57:33 matsuu Exp $

opts="${opts} checkconfig reload"

UNBOUND_BINARY=${UNBOUND_BINARY:-/usr/sbin/unbound}
UNBOUND_CHECKCONF=${UNBOUND_CHECKCONF:-/usr/sbin/unbound-checkconf}
UNBOUND_ANCHOR=${UNBOUND_ANCHOR:-/usr/sbin/unbound-anchor}
UNBOUND_CONFFILE=${UNBOUND_CONFFILE:-/etc/unbound/${SVCNAME}.conf}

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

checkconfig() {
	UNBOUND_PIDFILE=$("${UNBOUND_CHECKCONF}" -o pidfile "${UNBOUND_CONFFILE}")
	UNBOUND_USER=$("${UNBOUND_CHECKCONF}" -o username "${UNBOUND_CONFFILE}")
	return $?
}

start() {
	checkconfig || return $?
	ebegin "Starting unbound"
	su -c "${UNBOUND_ANCHOR}" -s /bin/sh ${UNBOUND_USER}
	start-stop-daemon --start --pidfile "${UNBOUND_PIDFILE}" \
		--exec "${UNBOUND_BINARY}" -- -c "${UNBOUND_CONFFILE}"
	eend $?
}

stop() {
	checkconfig || return $?
	ebegin "Stopping unbound"
	start-stop-daemon --stop --pidfile "${UNBOUND_PIDFILE}"
	eend $?
}

restart() {
	checkconfig || return $?
	svc_stop
	svc_start
}

reload() {
	checkconfig || return $?
	ebegin "Reloading unbound"
	start-stop-daemon --stop --pidfile "${UNBOUND_PIDFILE}" \
		--signal HUP --oknodo
	eend $?
}