summaryrefslogtreecommitdiff
path: root/etc/rc.d/unbound
blob: c591b0b1b45e1083d42d24922162f7db547b8fa6 (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
#!/bin/sh
#
# $OpenBSD: unbound,v 1.2 2014/12/29 11:17:43 ajacoutot Exp $

daemon="/usr/sbin/unbound"
daemon_flags="-c /var/unbound/etc/unbound.conf"

. /etc/rc.d/rc.subr

pexp="unbound${daemon_flags:+ ${daemon_flags}}"

rc_pre() {
	if grep '^[[:space:]]*control-enable:[[:space:]]*yes' \
	    /var/unbound/etc/unbound.conf > /dev/null 2>&1 && \
	    ! [[ -f /var/unbound/etc/unbound_server.key ||
	    -f /var/unbound/etc/unbound_server.pem ||
	    -f /var/unbound/etc/unbound_control.key ||
	    -f /var/unbound/etc/unbound_control.pem ]]; then
		/usr/sbin/unbound-control-setup 2> /dev/null
	fi
	if grep '^[[:space:]]*auto-trust-anchor-file:' \
            /var/unbound/etc/unbound.conf > /dev/null 2>&1; then
		/usr/sbin/unbound-anchor -v || true
	fi
}

rc_start() {
	/usr/sbin/unbound-checkconf > /dev/null && \
	    ${rcexec} "unbound ${daemon_flags}"
}

rc_cmd $1