blob: 312e297fb4b8ff1112d185742bf2c3c830afb3e8 (
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
|
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 Noah Meyerhans <frodo@morgul.net>
# Licensed under the terms of the GNU General Public License version 2
# or (at your discretion) any later later version
USE_PROCD=1
START=22
config_file=/etc/bind/named.conf
config_dir=$(dirname $config_file)
named_options_file=/etc/bind/named-rndc.conf
rndc_conf_file=/etc/bind/rndc.conf
pid_file=/var/run/named/named.pid
logdir=/var/log/named/
cachedir=/var/cache/bind
libdir=/var/lib/bind
dyndir=/tmp/bind
conf_local_file=$dyndir/named.conf.local
fix_perms() {
for dir in $libdir $logdir $cachedir $dyndir; do
test -e "$dir" || {
mkdir -p "$dir"
chgrp bind "$dir"
chmod g+w "$dir"
}
done
}
no_ipv6() {
[ -z "$(ip -6 -o route show default)" ]
}
reload_service() {
rndc -q reload
}
start_service() {
user_exists bind 57 || user_add bind 57
group_exists bind 57 || group_add bind 57
fix_perms
local runnamed=$(dirname $pid_file)
# with dropped privileges, we need this created for us
[ -d $runnamed ] || {
mkdir -m 0755 $runnamed
chown bind.bind $runnamed
}
local rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
rndc-confgen > $rndc_temp
sed -r -n \
-e '/^# options \{$/,/^\};$/{ s/^/# / }' \
-e p \
-e '/^# End of rndc\.conf$/q' \
< $rndc_temp > $rndc_conf_file
sed -r -n \
-e '1,/^# End of rndc\.conf$/ { b done }' \
-e '/^# Use with the following in named.conf/ { p ; b done }' \
-e '/^# End of named\.conf$/ { p ; b done }' \
-e '/^# key /,$ { s/^# // ; p }' \
-e ': done' \
< $rndc_temp > $named_options_file
rm -f $rndc_temp
touch $conf_local_file
local args=
[ no_ipv6 ] && args="-4"
procd_open_instance
procd_set_param command /usr/sbin/named -u bind -f $args -c $config_file
procd_set_param file $config_file \
$config_dir/bind.keys \
$named_options_file \
$conf_local_file \
$config_dir/db.*
procd_set_param respawn
procd_close_instance
}
|