blob: ee8ef36640c708cd02714be8dc77427d87616640 (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
PDNS_CONFIGDIR="${PDNS_CONFIGDIR:-/etc/powerdns}"
PDNS_STOP_TIMEOUT="${PDNS_STOP_TIMEOUT:-10}"
[ "${RC_SVCNAME}" != "pdns" ] && PDNS_INSTANCE="${RC_SVCNAME#pdns[.-]}" || PDNS_INSTANCE=""
PDNS_CONFIG="${PDNS_CONFIGDIR}/pdns${PDNS_INSTANCE:+-${PDNS_INSTANCE}}.conf"
PDNS_CHROOTDIR="$( awk -F = '$1 == "chroot" { print $2 }' "${PDNS_CONFIG}" )"
PDNS_SOCKETDIR="$( awk -F = '$1 == "socket-dir" { print $2 }' "${PDNS_CONFIG}" )"
[ -z "${PDNS_SOCKETDIR}" -a -z "${PDNS_CHROOTDIR}" ] && PDNS_SOCKETDIR="/var/run/pdns"
name="PowerDNS Authoritative Server${PDNS_INSTANCE:+ (${PDNS_INSTANCE})}"
description="Authoritative name server"
extra_started_commands="dump ping"
extra_stopped_commands="monitor"
description_dump="Dumps all statistic variables"
description_ping="Ping the PowerDNS instance"
description_monitor="Starts in foreground with logging and console enabled"
command="/usr/sbin/pdns_server"
command_args="--config-dir=${PDNS_CONFIGDIR}${PDNS_INSTANCE:+ --config-name=${PDNS_INSTANCE}} --write-pid=yes"
command_args_foreground="--daemon=no"
command_args_background="--daemon=yes"
yesno ${rc_verbose} || command_args_background="${command_args_background} >/dev/null 2>&1"
pidfile="${PDNS_CHROOTDIR}/${PDNS_SOCKETDIR}/pdns${PDNS_INSTANCE:+-${PDNS_INSTANCE}}.pid"
control_command="/usr/bin/pdns_control"
control_command_args="${command_args}"
depend() {
need net
use mysql postgresql
}
status() {
default_status || return
_ping || return 32
}
stop() {
default_stop || return
_ping || return 0
wait_for_stop
}
wait_for_stop() {
einfon "Waiting for ${name} to stop"
local timeout="${PDNS_STOP_TIMEOUT}"
while [ "${timeout}" -gt 0 ]; do
sleep 1
if ! _ping; then
echo
return 0
fi
: $(( timeout -= 1 ))
printf .
done
echo
return 1
}
dump() {
einfo "Dumping ${name} variables"
${control_command} ${control_command_args} list
}
_ping() {
${control_command} ${control_command_args} rping >/dev/null 2>&1
}
ping() {
ebegin "Pinging ${name}"
_ping
eend $?
}
monitor() {
einfo "Starting ${name} in monitor mode"
echo
echo '************************************************'
echo '* Use "QUIT" or Ctrl-C to end monitoring mode! *'
echo '************************************************'
echo
${command} \
${command_args} \
${command_args_foreground} \
--guardian=no \
--control-console=yes \
--loglevel=9 \
--log-dns-details=yes \
--query-logging=yes
return 0
}
|