aboutsummaryrefslogtreecommitdiff
path: root/package/bind/bind.sysvinit
blob: a9babd21537a151d9626ef4827c25726652c2a12 (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
#!/bin/sh
#
# System-V init to control the bind DNS Daemon
#

NAME=named
DAEMON=/usr/sbin/$NAME

# this file contains a few tunable parameters
test -r /etc/default/named && . /etc/default/named

test -f $DAEMON || exit 0

set -e

case "$1" in
	start)
		test -z "$CHROOT" || ARGS="$ARGS -t $CHROOT"
		test -z "$SETUID" || ARGS="$ARGS -u $SETUID"
		if [ ! -f $CHROOT/etc/rndc.key ]; then
		    echo -n "Initializing $NAME control key: rndc-confgen"
		    set +e 
		    touch $CHROOT/etc/rndc.key # handle symlinks
		    rndc-confgen -a -r /dev/urandom $ARGS || echo "."
		    set -e
		fi
		test -z "$CONF" || ARGS="$ARGS -c $CONF"
		echo -n "Starting domain name daemon: $NAME"
		trap 'echo failed' 0
		start-stop-daemon -S -x $DAEMON -- $ARGS
		trap - 0
		echo "."
		;;
	stop)
		echo -n "Stopping domain name daemon: $NAME"
		rndc stop || start-stop-daemon -K -x $DAEMON
		echo "."
		;;
	restart)
		$0 stop
		sleep 2
		$0 start && exit $?
		;;
	reload|force-reload)
		rndc reload && exit $?
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|force-reload}"
		exit 1 
esac

exit 0