diff options
author | Tomas Chvatal <scarabeus@gentoo.org> | 2009-11-12 08:37:18 +0000 |
---|---|---|
committer | Tomas Chvatal <scarabeus@gentoo.org> | 2009-11-12 08:37:18 +0000 |
commit | 012c5be1e84ab8fc2cf4d2af182c5f40df300930 (patch) | |
tree | 12329b1628a1ed3ca5c3d9f06dbb221c8dc53084 /net-dns/bind/files | |
parent | Fix X_ShmAttach not declared. Bug #292508 (diff) | |
download | gentoo-2-012c5be1e84ab8fc2cf4d2af182c5f40df300930.tar.gz gentoo-2-012c5be1e84ab8fc2cf4d2af182c5f40df300930.tar.bz2 gentoo-2-012c5be1e84ab8fc2cf4d2af182c5f40df300930.zip |
Fix initscript bugs #279568 and #257632.
(Portage version: 2.2_rc49/cvs/Linux x86_64)
Diffstat (limited to 'net-dns/bind/files')
-rw-r--r-- | net-dns/bind/files/named.confd-r3 | 20 | ||||
-rw-r--r-- | net-dns/bind/files/named.init-r7 | 140 |
2 files changed, 160 insertions, 0 deletions
diff --git a/net-dns/bind/files/named.confd-r3 b/net-dns/bind/files/named.confd-r3 new file mode 100644 index 000000000000..02fa8980c9a5 --- /dev/null +++ b/net-dns/bind/files/named.confd-r3 @@ -0,0 +1,20 @@ +# 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, run: +# emerge --config =<bind-version> +# and un-comment the following line. +# You can specify a different chroot directory but MAKE SURE it's empty. +# CHROOT="/chroot/dns" + +# Default pid file location +PIDFILE="${CHROOT}/var/run/named/named.pid" + +# Scheduling priority: 19 is the lowest and -20 is the highest. +# +NAMED_NICELEVEL="0" diff --git a/net-dns/bind/files/named.init-r7 b/net-dns/bind/files/named.init-r7 new file mode 100644 index 000000000000..0ad8dca54cb1 --- /dev/null +++ b/net-dns/bind/files/named.init-r7 @@ -0,0 +1,140 @@ +#!/sbin/runscript +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r7,v 1.1 2009/11/12 08:37:16 scarabeus Exp $ + +opts="start stop reload restart" + +depend() { + need net + use logger + after pg_autovacuum postgresql mysql ldap + provide dns +} + +_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 +} + +checkconfig() { + if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then + eerror "No ${CHROOT}/etc/bind/named.conf file exists!" + fi + + # In case someone have $CPU set in /etc/conf.d/named + if [ ${CPU} ] ; then + CPU="-n ${CPU}" + 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" +} + +start() { + ebegin "Starting ${CHROOT:+chrooted }named" + + if [[ -n ${CHROOT} ]]; + 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 + + checkconfig || return 1 + + start-stop-daemon --start --quiet --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 [ -f $KEY ] ; then + rndc -k $KEY stop &>/dev/null + else + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --exec /usr/sbin/named -- stop + fi + + if [[ -n ${CHROOT} ]]; + then + einfo "Umounting chroot dirs" + + # just to be sure everything gets clean + while [[ -n $(fuser ${CHROOT} 2>&1) ]] + 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() { + 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 +} |