5
# Required-Start: $remote_fs
6
# Required-Stop: $remote_fs
7
# Should-Start: $network $syslog
8
# Should-Stop: $network $syslog
9
# Default-Start: 2 3 4 5
11
# Short-Description: Start and stop bind9
12
# Description: bind9 is a Domain Name Server (DNS)
13
# which translates ip addresses to and from internet names
16
PATH=/sbin:/bin:/usr/sbin:/usr/bin
18
# for a chrooted server: "-u bind -t /var/lib/named"
19
# Don't modify this line, change or create /etc/default/bind9.
23
test -f /etc/default/bind9 && . /etc/default/bind9
25
test -x /usr/sbin/rndc || exit 0
27
. /lib/lsb/init-functions
28
PIDFILE=/var/run/named/named.pid
31
if [ -x /usr/bin/uname ] && [ "X$(/usr/bin/uname -o)" = XSolaris ]; then
36
if [ -z "$(/sbin/ifconfig $IFCONFIG_OPTS)" ]; then
37
#log_action_msg "No networks configured."
45
log_daemon_msg "Starting domain name service..." "bind9"
47
modprobe capability >/dev/null 2>&1 || true
49
# dirs under /var/run can go away on reboots.
50
mkdir -p /var/run/named
51
chmod 775 /var/run/named
52
chown root:bind /var/run/named >/dev/null 2>&1 || true
54
if [ ! -x /usr/sbin/named ]; then
55
log_action_msg "named binary missing - not starting"
59
if ! check_network; then
60
log_action_msg "no networks configured"
64
if start-stop-daemon --start --oknodo --quiet --exec /usr/sbin/named \
65
--pidfile ${PIDFILE} -- $OPTIONS; then
66
if [ "X$RESOLVCONF" != "Xno" ] && [ -x /sbin/resolvconf ] ; then
67
echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.named
76
log_daemon_msg "Stopping domain name service..." "bind9"
77
if ! check_network; then
78
log_action_msg "no networks configured"
82
if [ "X$RESOLVCONF" != "Xno" ] && [ -x /sbin/resolvconf ] ; then
83
/sbin/resolvconf -d lo.named
85
pid=$(/usr/sbin/rndc stop -p | awk '/^pid:/ {print $2}') || true
86
if [ -z "$pid" ]; then # no pid found, so either not running, or error
87
pid=$(pgrep -f ^/usr/sbin/named) || true
88
start-stop-daemon --stop --oknodo --quiet --exec /usr/sbin/named \
89
--pidfile ${PIDFILE} -- $OPTIONS
91
if [ -n "$pid" ]; then
94
while kill -$sig $pid 2>/dev/null; do
96
echo "waiting for pid $pid to die"
98
if [ $n -eq 11 ]; then
99
echo "giving up on pid $pid with kill -0; trying -9"
102
if [ $n -gt 20 ]; then
103
echo "giving up on pid $pid"
114
log_daemon_msg "Reloading domain name service..." "bind9"
115
if ! check_network; then
116
log_action_msg "no networks configured"
120
/usr/sbin/rndc reload >/dev/null && log_end_msg 0 || log_end_msg 1
124
if ! check_network; then
125
log_action_msg "no networks configured"
135
status_of_proc -p ${PIDFILE} /usr/sbin/named bind9 2>/dev/null || ret=$?
140
log_action_msg "Usage: /etc/init.d/bind9 {start|stop|reload|restart|force-reload|status}"