summaryrefslogtreecommitdiff
blob: 39757d142f2d3b67ebba3c4655ac583b233bef24 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

description="An open-source turn-key solution for DNSSEC"

depend() {
	use logger
}

checkconfig() {
	if [ -x "${CHECKCONFIG_BIN}" ]; then
		output=$(${CHECKCONFIG_BIN} 2>&1| grep -v -E "^/etc/opendnssec/(conf|kasp).xml validates")
		if [ -n "$output" ]; then
			echo $output
		fi

		errors=$(echo $output | grep ERROR | wc -l)
		if [ $errors -gt 0 ]; then
			ewarn "$errors error(s) found in OpenDNSSEC configuration."
		fi
		return $errors
	fi
	eerror "Unable to execute ${CHECKCONFIG_BIN:-config binary}"
	# can't validate config, just die
	return 1
}


start_enforcer() {
	if [ -n "${ENFORCER_BIN}" ] && [ -x "${ENFORCER_BIN}" ]; then
		ebegin "Starting OpenDNSSEC Enforcer"
		${CONTROL_BIN} enforcer start > /dev/null
		eend $?
	else
		if [ -n "${ENFORCER_BIN}" ]; then
			eerror "OpenDNSSEC Enforcer binary not executable"
			return 1
		fi
		einfo "OpenDNSSEC Enforcer not used."
	fi
}

stop_enforcer() {
	if [ -x "${ENFORCER_BIN}" ]; then
		ebegin "Stopping OpenDNSSEC Enforcer"
		${CONTROL_BIN} enforcer stop > /dev/null
		eend $?
	fi
}

start_signer() {
	if [ -n "${SIGNER_BIN}" ] && [ -x "${SIGNER_BIN}" ]; then
		ebegin "Starting OpenDNSSEC Signer"
		${CONTROL_BIN} signer start > /dev/null 2>&1
		eend $?
	else
		if [ -n "${SIGNER_BIN}" ]; then
			eerror "OpenDNSSEC Signer binary not executable"
			return 1
		fi
		einfo "OpenDNSSEC Signer not used."
	fi
}

stop_signer() {
	if [ -x "${SIGNER_BIN}" ]; then
		ebegin "Stopping OpenDNSSEC Signer"
		${CONTROL_BIN} signer stop > /dev/null 2>&1
		eend $?
	fi
}

start() {
	checkconfig || return $?
	checkpath -d -m 0755 -o opendnssec:opendnssec /run/opendnssec
	start_enforcer || return $?
	start_signer || return $?
}

stop() {
	stop_signer
	stop_enforcer
	sleep 5
}