source: npl/internetserver/bind/rc.bind @ 76ea60c

Last change on this file since 76ea60c was ebc5ae5, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

upgraded dhcpd to 4.3.6 for better ipv6 support

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[ebc5ae5]1#!/bin/sh
2# Start/stop/restart the BIND name server daemon (named).
3
4
5# Start bind. In the past it was more secure to run BIND as a non-root
6# user (for example, with '-u daemon'), but the modern version of BIND
7# knows how to use the kernel's capability mechanism to drop all root
8# privileges except the ability to bind() to a privileged port and set
9# process resource limits, so -u should not be needed.  If you wish to
10# use it anyway, chown the /var/run/named and /var/named directories to
11# the non-root user. The command options can be set like this in
12# /etc/default/named :
13#       NAMED_OPTIONS="-u daemon"
14# So you will not have to edit this script.
15
16# You might also consider running BIND in a "chroot jail",
17# a discussion of which may be found in
18# /usr/doc/Linux-HOWTOs/Chroot-BIND-HOWTO.
19 
20# One last note:  rndc has a lot of other nice features that it is not
21# within the scope of this start/stop/restart script to support.
22# For more details, see "man rndc" or just type "rndc" to see the options.
23
24# Load command defaults:
25if [ -f /etc/default/named ] ; then . /etc/default/named ; fi
26if [ -f /etc/default/rndc ] ; then . /etc/default/rndc ; fi
27
28# Sanity check.  If /usr/sbin/named is missing then it
29# doesn't make much sense to try to run this script:
30if [ ! -x /usr/sbin/named ]; then
31  echo "/etc/rc.d/rc.bind:  no /usr/sbin/named found (or not executable); cannot start."
32  exit 1
33fi
34
35# Start BIND.  As many times as you like.  ;-)
36# Seriously, don't run "rc.bind start" if BIND is already
37# running or you'll get more than one copy running.
38bind_start() {
39  if [ -x /usr/sbin/named ]; then
40    echo "Starting BIND:  /usr/sbin/named $NAMED_OPTIONS"
41    /usr/sbin/named $NAMED_OPTIONS
42    sleep 1
43  fi
44  if ! ps axc | grep -q named ; then
45    echo "WARNING:  named did not start."
46    echo "Attempting to start named again:  /usr/sbin/named $NAMED_OPTIONS"
47    /usr/sbin/named $NAMED_OPTIONS
48    sleep 1
49    if ps axc | grep -q named ; then
50      echo "SUCCESS:  named started."
51    else
52      echo "FAILED:  Sorry, a second attempt to start named has also failed."
53      echo "There may be a configuration error that needs fixing.  Good luck!"
54    fi
55  fi
56}
57
58# Stop all running copies of BIND (/usr/sbin/named):
59bind_stop() {
60  echo "Stopping BIND:  /usr/sbin/rndc $RDNC_OPTIONS stop"
61  /usr/sbin/rndc $RDNC_OPTIONS stop
62  # A problem with using "/usr/sbin/rndc stop" is that if you
63  # managed to get multiple copies of named running it will
64  # only stop one of them and then can't stop the others even
65  # if you run it again.  So, after doing things the nice way
66  # we'll do them the old-fashioned way.  If you don't like
67  # it you can comment it out, but unless you have a lot of
68  # other programs you run called "named" this is unlikely
69  # to have any ill effects:
70  sleep 1
71  if ps axc | grep -q named ; then
72    echo "Using "killall named" on additional BIND processes..."
73    /bin/killall named 2> /dev/null
74  fi
75}
76
77# Reload BIND:
78bind_reload() {
79  /usr/sbin/rndc $RDNC_OPTIONS reload
80}
81
82# Restart BIND:
83bind_restart() {
84  bind_stop
85  bind_start
86}
87
88# Get BIND status:
89bind_status() {
90  /usr/sbin/rndc $RDNC_OPTIONS status
91}
92
93case "$1" in
94'start')
95  bind_start
96  ;;
97'stop')
98  bind_stop
99  ;;
100'reload')
101  bind_reload
102  ;;
103'restart')
104  bind_restart
105  ;;
106'status')
107  bind_status
108  ;;
109*)
110  echo "usage $0 start|stop|reload|restart|status"
111esac
112
Note: See TracBrowser for help on using the repository browser.