summaryrefslogtreecommitdiffstats
path: root/extra/bind/bind.initd
diff options
context:
space:
mode:
authorCarlo Lanmdeter <clandmeter@gmail>2009-02-22 22:18:49 +0000
committerCarlo Lanmdeter <clandmeter@gmail>2009-02-22 22:18:49 +0000
commitc59bfb5f16a44fe9facdf9ae575e604c0f1953f6 (patch)
tree12f14c2b77c1a65bc1ae9c610a3cf9be85ca4c95 /extra/bind/bind.initd
parentc0881272b451d57c536f4046bd24ff66b7491b50 (diff)
downloadaports-c59bfb5f16a44fe9facdf9ae575e604c0f1953f6.tar.bz2
aports-c59bfb5f16a44fe9facdf9ae575e604c0f1953f6.tar.xz
extra/bind: new aport
Diffstat (limited to 'extra/bind/bind.initd')
-rw-r--r--extra/bind/bind.initd83
1 files changed, 83 insertions, 0 deletions
diff --git a/extra/bind/bind.initd b/extra/bind/bind.initd
new file mode 100644
index 000000000..1d48ff5e6
--- /dev/null
+++ b/extra/bind/bind.initd
@@ -0,0 +1,83 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r5,v 1.1 2007/06/02 22:34:48 voxus 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
+
+ # as suggested in bug #107724
+ [ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\
+ egrep -v \
+ "^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" \
+ ${CHROOT}/etc/bind/named.conf \
+ | egrep -o -m1 "pid\-file +\".+\" *;" \
+ | cut -d\" -f2
+ )
+
+ KEY="${CHROOT}/etc/bind/rndc.key"
+}
+
+init_rndc_key() {
+ [ -f "$KEY" ] && return
+ if [ -c /dev/urandom ]; then
+ einfo "Using /dev/urandom for generating rndc.key"
+ /usr/sbin/rndc-confgen -r /dev/urandom -a -u named -c "$KEY"
+ else
+ einfo "Using /dev/random for generating rndc.key"
+ /usr/sbin/rndc-confgen -a -u named -c "$KEY"
+ fi
+}
+
+start() {
+ ebegin "Starting ${CHROOT:+chrooted }named"
+ checkconfig || return 1
+ init_rndc_key
+ start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
+ --nicelevel ${NAMED_NICELEVEL:-0} \
+ --exec /usr/sbin/named \
+ -- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${CHROOT:+chrooted }named"
+ checkconfig || return 2
+ if [ -f $KEY ] ; then
+ rndc -k $KEY stop &>/dev/null
+ else
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+ --exec /usr/sbin/named -- stop
+ fi
+ 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.conf and zone files"
+ rndc -k $KEY reload &>/dev/null
+ eend $?
+ else /etc/init.d/named restart &>/dev/null
+ fi
+}