1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 Noah Meyerhans <frodo@morgul.net>
3 # Licensed under the terms of the GNU General Public License version 2
4 # or (at your discretion) any later later version
10 config_file
=/etc
/bind
/named.conf
11 config_dir
=$
(dirname $config_file)
12 named_options_file
=/etc
/bind
/named-rndc.conf
13 rndc_conf_file
=/etc
/bind
/rndc.conf
14 pid_file
=/var
/run
/named
/named.pid
16 logdir
=/var
/log
/named
/
17 cachedir
=/var
/cache
/bind
21 conf_local_file
=$dyndir/named.conf.
local
24 for dir
in $libdir $logdir $cachedir $dyndir; do
34 [ -z "$(ip -6 -o route show default)" ]
42 user_exists
bind 57 || user_add
bind 57
43 group_exists
bind 57 || group_add
bind 57
46 local runnamed
=$
(dirname $pid_file)
47 # with dropped privileges, we need this created for us
49 mkdir
-m 0755 $runnamed
50 chown
bind.
bind $runnamed
53 local rndc_temp
=$
(mktemp
/tmp
/rndc-confgen.XXXXXX
)
55 rndc-confgen
> $rndc_temp
58 -e '/^# options \{$/,/^\};$/{ s/^/# / }' \
60 -e '/^# End of rndc\.conf$/q' \
61 < $rndc_temp > $rndc_conf_file
64 -e '1,/^# End of rndc\.conf$/ { b done }' \
65 -e '/^# Use with the following in named.conf/ { p ; b done }' \
66 -e '/^# End of named\.conf$/ { p ; b done }' \
67 -e '/^# key /,$ { s/^# // ; p }' \
69 < $rndc_temp > $named_options_file
73 touch $conf_local_file
76 [ no_ipv6
] && args
="-4"
79 procd_set_param
command /usr
/sbin
/named
-u bind -f $args -c $config_file
80 procd_set_param
file $config_file \
81 $config_dir/bind.keys \
85 procd_set_param respawn