summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2010-09-23 17:49:44 +0000
committerChristian Ruppert <idl0r@gentoo.org>2010-09-23 17:49:44 +0000
commitcb6d9a20e4ae3e3f28656a2b8a83a0e4882b9cbc (patch)
tree9ccb443b2a372a4103f3d56317a35c8708e10f39 /net-dns/bind
parentRemove Debian -line from admin/nasm to fix building wrt #318155 by Jochen Sch... (diff)
downloadgentoo-2-cb6d9a20e4ae3e3f28656a2b8a83a0e4882b9cbc.tar.gz
gentoo-2-cb6d9a20e4ae3e3f28656a2b8a83a0e4882b9cbc.tar.bz2
gentoo-2-cb6d9a20e4ae3e3f28656a2b8a83a0e4882b9cbc.zip
named.confd-r4: New CHROOT_NOMOUNT option to allow one to use the old chroot start behaviour. Add rc_named_use and rc_named_after options to ensure MySQL, PostgreSQL or LDAP will be started first, see bug 295260 and bug 295619.
named.init-r8: Some cleanup. Make the init script POSIX compliant, bug 338353. Add a named-checkconf call to ensure named.conf is valid. Use the new CHROOT_NOMOUNT option to avoid using mount for a chroot named. Some improvements, esp. reload(), bug 335398. (Portage version: 2.2_rc86/cvs/Linux x86_64)
Diffstat (limited to 'net-dns/bind')
-rw-r--r--net-dns/bind/ChangeLog12
-rw-r--r--net-dns/bind/files/named.confd-r446
-rw-r--r--net-dns/bind/files/named.init-r8187
3 files changed, 244 insertions, 1 deletions
diff --git a/net-dns/bind/ChangeLog b/net-dns/bind/ChangeLog
index 3b0f31f71cbf..2bbb3af8bc05 100644
--- a/net-dns/bind/ChangeLog
+++ b/net-dns/bind/ChangeLog
@@ -1,6 +1,16 @@
# ChangeLog for net-dns/bind
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/ChangeLog,v 1.292 2010/09/23 12:11:05 idl0r Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/ChangeLog,v 1.293 2010/09/23 17:49:44 idl0r Exp $
+
+ 23 Sep 2010; Christian Ruppert <idl0r@gentoo.org> +files/named.confd-r4,
+ +files/named.init-r8:
+ named.confd-r4: New CHROOT_NOMOUNT option to allow one to use the old chroot
+ start behaviour. Add rc_named_use and rc_named_after options to ensure MySQL,
+ PostgreSQL or LDAP will be started first, see bug 295260 and bug 295619.
+ named.init-r8: Some cleanup. Make the init script POSIX compliant, bug
+ 338353. Add a named-checkconf call to ensure named.conf is valid. Use the new
+ CHROOT_NOMOUNT option to avoid using mount for a chroot named. Some
+ improvements, esp. reload(), bug 335398.
23 Sep 2010; Christian Ruppert <idl0r@gentoo.org> bind-9.6.2_p2.ebuild,
bind-9.7.1_p2.ebuild:
diff --git a/net-dns/bind/files/named.confd-r4 b/net-dns/bind/files/named.confd-r4
new file mode 100644
index 000000000000..6fdb00e238d0
--- /dev/null
+++ b/net-dns/bind/files/named.confd-r4
@@ -0,0 +1,46 @@
+# Set various named options here.
+#
+OPTIONS=""
+
+# Set this to the number of processors you want bind to use.
+# Leave this unchanged if you want bind to automatically detect the number
+#CPU="1"
+
+# If you wish to run bind in a chroot:
+# 1) un-comment the CHROOT= assignment, below. You may use
+# a different chroot directory but MAKE SURE it's empty.
+# 2) run: emerge --config =<bind-version>
+#
+#CHROOT="/chroot/dns"
+
+# Uncomment the line below to avoid that the init script mounts the needed paths
+# into the chroot directory.
+# You have to copy all needed config files by hand if you say CHROOT_NOMOUNT="1".
+#CHROOT_NOMOUNT="1"
+
+# RNDC needs to be told what server we're using sometimes.
+#SERVER="-s 127.0.0.1"
+# rndc key to use
+RNDC_KEY="${CHROOT}/etc/bind/rndc.key"
+
+# Default pid file location
+PIDFILE="${CHROOT}/var/run/named/named.pid"
+
+# Scheduling priority: 19 is the lowest and -20 is the highest.
+# Default: 0
+#NAMED_NICELEVEL="0"
+
+# Uncomment rc_named_use/rc_named_after for the database you need.
+# Its necessary to ensure the database backend will be started before named.
+
+# MySQL
+#rc_named_use="mysql"
+#rc_named_after="mysql"
+
+# PostgreSQL
+#rc_named_use="pg_autovacuum postgresql"
+#rc_named_after="pg_autovacuum postgresql"
+
+# LDAP
+#rc_named_use="ldap"
+#rc_named_after="ldap"
diff --git a/net-dns/bind/files/named.init-r8 b/net-dns/bind/files/named.init-r8
new file mode 100644
index 000000000000..b1c5cef4333e
--- /dev/null
+++ b/net-dns/bind/files/named.init-r8
@@ -0,0 +1,187 @@
+#!/sbin/runscript
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r8,v 1.1 2010/09/23 17:49:44 idl0r Exp $
+
+opts="start stop reload restart"
+
+depend() {
+ need net
+ use logger
+ provide dns
+}
+
+NAMED_CONF=${CHROOT}/etc/bind/named.conf
+
+_mount() {
+ local from
+ local to
+ local opts
+
+ if [ "${#}" -lt 3 ]; then
+ eerror "_mount(): to few arguments"
+ return 1
+ fi
+
+ from=$1
+ to=$2
+ shift 2
+
+ opts="${*}"
+ shift $#
+
+ if [ -z "$(grep ${to} /proc/mounts)" ]; then
+ einfo "mounting ${from} to ${to}"
+ mount ${from} ${to} ${opts} || return 1
+ fi
+}
+
+_umount() {
+ local dir=$1
+
+ if [ -n "$(grep ${dir} /proc/mounts)" ]; then
+ einfo "umount ${dir}"
+ umount ${dir}
+ fi
+}
+
+check_chroot() {
+ if [ -n "${CHROOT}" ]; then
+ [ ! -d "${CHROOT}" ] && return 1
+ [ ! -d "${CHROOT}/dev" ] || [ ! -d "${CHROOT}/etc" ] || [ ! -d "${CHROOT}/var" ] && return 1
+ [ ! -d "${CHROOT}/var/run" ] || [ ! -d "${CHROOT}/var/log" ] && return 1
+ [ ! -d "${CHROOT}/etc/bind" ] || [ ! -d "${CHROOT}/var/bind" ] && return 1
+ [ ! -d "${CHROOT}/var/log/named" ] && return 1
+ [ ! -e "${CHROOT}/etc/localtime" ] && return 1
+ [ ! -c "${CHROOT}/dev/null" ] || [ ! -c "${CHROOT}/dev/zero" ] && return 1
+ [ ! -c "${CHROOT}/dev/random" ] && [ ! -c "${CHROOT}/dev/urandom" ] && return 1
+ fi
+
+ return 0
+}
+
+checkconfig() {
+ if [ ! -f "${NAMED_CONF}" ] ; then
+ eerror "No ${NAMED_CONF} file exists!"
+ fi
+
+ named-checkconf -z -j ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF/${CHROOT}} 1>/dev/null || {
+ eerror "named-checkconf failed! Please fix your config first."
+ return 1
+ }
+
+ # 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
+ )
+ [ -z "${PIDFILE}" ] && PIDFILE=${CHROOT}/var/run/named/named.pid
+
+ return 0
+}
+
+start() {
+ local piddir
+
+ ebegin "Starting ${CHROOT:+chrooted }named"
+
+ if [ -n "${CHROOT}" ]; then
+ check_chroot || {
+ eend 1
+ eerror "Your chroot dir ${CHROOT} is inconsistent, please run 'emerge --config net-dns/bind' first"
+ return 1
+ }
+
+ if [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
+ einfo "Mounting chroot dirs"
+ _mount /etc/bind ${CHROOT}/etc/bind -o bind
+ _mount /var/bind ${CHROOT}/var/bind -o bind
+ _mount /var/log/named ${CHROOT}/var/log/named -o bind
+ fi
+ fi
+
+ checkconfig || {
+ eend 1
+ return 1
+ }
+
+ # create piddir (usually /var/run/named) if necessary
+ piddir="${PIDFILE%/*}"
+ if [ ! -d "${piddir}" ]; then
+ checkpath -q -d -o root:named -m 0770 "${piddir}" || {
+ eend 1
+ return 1
+ }
+ fi
+
+ # In case someone have $CPU set in /etc/conf.d/named
+ if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then
+ CPU="-n ${CPU}"
+ fi
+
+ start-stop-daemon --start --pidfile ${PIDFILE} \
+ --nicelevel ${NAMED_NICELEVEL:-0} \
+ --exec /usr/sbin/named \
+ -- -u named ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
+ eend $?
+}
+
+stop() {
+ local reported=0
+
+ ebegin "Stopping ${CHROOT:+chrooted }named"
+ checkconfig || return 2
+ if [ -n "${RNDC_KEY}" ] && [ -f "${RNDC_KEY}" ]; then
+ rndc $SERVER -k $RNDC_KEY stop 1>/dev/null
+ else
+ # -R 10, bug 335398
+ start-stop-daemon --stop --retry 10 --pidfile $PIDFILE \
+ --exec /usr/sbin/named
+ fi
+
+ if [ -n "${CHROOT}" ] && [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
+ einfo "Umounting chroot dirs"
+
+ # just to be sure everything gets clean
+ while [ -n "$(fuser ${CHROOT} 2>/dev/null)" ]; do
+ if [ "${reported}" -eq 0 ]; then
+ einfo "Waiting until all named processes are stopped"
+ reported=1
+ fi
+ sleep 1
+ done
+
+ _umount ${CHROOT}/etc/bind
+ _umount ${CHROOT}/var/log/named
+ _umount ${CHROOT}/var/bind
+ fi
+
+ eend $?
+}
+
+reload() {
+ local ret
+
+ # checkconf also gives us the pidfile.
+ checkconfig || return 3
+
+ ebegin "Reloading named.conf and zone files"
+ if [ -n "${RNDC_KEY}" ] && [ -f "${RNDC_KEY}" ] ; then
+ rndc $SERVER -k $RNDC_KEY reload 1>/dev/null
+ ret=$?
+ elif [ -n "${PIDFILE}" ]; then
+ start-stop-daemon --pidfile $PIDFILE --signal HUP
+ ret=$?
+ else
+ ewarn "Neither an rndc key has been specified nor a pidfile... this is"
+ ewarn "a fallback mode. Please check your installation!"
+
+ $RC_SERVICE restart
+ ret=$?
+ fi
+
+ eend $ret
+}