summaryrefslogtreecommitdiff
blob: 34af44d0b70e70be311eba114b87072033a1ba59 (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
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc6,v 1.8 2003/01/08 23:40:04 bcowan Exp $

opts="start stop reload restart"

depend() {
	need net
	use logger
	provide dns
}

checkconfig() {
	if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then
		eerror "No ${CHROOT}/etc/bind/named.conf file exists!"
	fi
	
	# In case someone doesn't have $CPU set from /etc/conf.d/named
	if [ ! $CPU ] ; then
		CPU=1
	fi

	if [ $CHROOT -a -d $CHROOT ] ; then
		PIDFILE="${CHROOT}/var/run/named/named.pid"
		KEY="${CHROOT}/etc/bind/rndc.key"
	else
		PIDFILE="/var/run/named/named.pid"
		KEY="/etc/bind/rndc.key"
	fi
}

start() {
	ebegin "Starting ${CHROOT:+chrooted }named"
	checkconfig || return 1
	start-stop-daemon --start --quiet --exec /usr/sbin/named -- -u named -n $CPU $OPTIONS ${CHROOT:+-t $CHROOT}
	eend $?
}

stop() {
	ebegin "Stopping named"
	checkconfig || return 2
	start-stop-daemon --stop --quiet --pidfile $PIDFILE
	eend $?
}

reload() {
	checkconfig || return 3
	if [ ! -f $PIDFILE ] ; then
		/etc/init.d/named start &>/dev/null
		exit
	fi

	if [ -f $KEY ] ; then
		ebegin "Reloading named"
		rndc -k $KEY reconfig &>/dev/null
		eend $?
	else /etc/init.d/named restart &>/dev/null
	fi
}

restart() {
	svc_stop
	svc_start
}