Your message dated Thu, 19 Jul 2012 10:43:52 +0200
with message-id 
<CALjhHG8wYPimqkB=21h1lr+_hurkkt2-5edehm3z5npardu...@mail.gmail.com>
and subject line Closing old bug wishlist
has caused the Debian Bug report #282470,
regarding nsd: [PATCH] Support running multiple instances
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
282470: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=282470
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: nsd
Version: 2.1.4-1
Severity: wishlist
Tags: patch

Hi. I want to run two instances of nsd, bound to different IP addresses.
Here's a patch that adds generic multi-instance support to nsd, please
integrate it or request improvements you want to see before integration.
I'll gladly explain any weird-looking parts. Thank you.
--- nsd-2.1.4-orig/debian/README.instances	1970-01-01 02:00:00.000000000 +0200
+++ nsd-2.1.4/debian/README.instances	2004-11-22 13:21:20.000000000 +0200
@@ -0,1 +1,41 @@
+Multiple instance support
+-------------------------
+
+The Debian init scripts support running multiple instance of nsd.
+
+To activate this support, create an instance-specific configuration
+file "/etc/default/nsd.<name>", replacing <name> with the name you
+want to give to a specific instance. Names can contain characters
+[a-z] only. You can create multiple such files -- that's the whole
+point of this feature.
+
+
+You should probably add something to the variable $flags in the
+instance configuration file, to stop all the instances from trying
+to bind to 0.0.0.0:53. Like this:
+
+	flags="$flags -a 127.0.0.1"
+
+or this:
+
+	flags="$flags -p 5301"
+
+
+By default, different instances use different zonefiles, databases,
+etc. You will need to create "/etc/nsd/nsd.<name>.zones" for each of
+your instances, or override this behaviour in the configuration files.
+
+
+Note that to run two instances of nsd, you need to create _two_
+instance-specific configuration files. The default instance is
+disabled as soon if you use this feature. The "/etc/default/nsd" file
+acts as shared configuration for all the instances.
+
+
+nsdc(8) has been enhanced so it knows how to deal with a specific
+instance. Run it like this:
+
+	  nsdc <command> <name>
+
+to perform <command> on instance <name>.
--- nsd-2.1.4-orig/debian/init.d	2004-11-20 17:43:06.000000000 +0200
+++ nsd-2.1.4/debian/init.d	2004-11-22 13:00:03.000000000 +0200
@@ -5,60 +5,124 @@
 NAME=nsd
 DESC="domain name service"
 
+# this sourcing is here only if the admin overrode NSDC
 NSDC=/usr/sbin/nsdc
+test -f /etc/default/nsd && . /etc/default/nsd
+test -x "${NSDC}" || exit 0
+
+set -e
 
-dbfile=/etc/nsd/nsd.db
-rebuild=false
-pidfile=/var/run/nsd.pid
+readconfig () {
+	INSTANCE="$1"
 
-test -f /etc/default/nsd && . /etc/default/nsd
-test -x ${NSDC} || exit 0
+	NSDC=/usr/sbin/nsdc
+	dbfile="/etc/nsd/nsd${INSTANCE:+.$INSTANCE}.db"
+	rebuild=false
+	pidfile="/var/run/nsd${INSTANCE:+.$INSTANCE}.pid"
+
+	test -f /etc/default/nsd && . /etc/default/nsd
+	if [ -n "$INSTANCE" ]; then
+		test -f "/etc/default/nsd.$INSTANCE" && . "/etc/default/nsd.$INSTANCE"
+	fi
+	[ ! -d /proc/sys/net/ipv6/ ] && flags="${flags} -4"
+}
 
-COUNTER=0
+announce () {
+	NAME="$1"
+	INSTANCE="$2"
+
+	echo -n " $NAME"
+	if [ -n "$INSTANCE" ]; then
+		echo -n "/$INSTANCE"
+	fi
+}
 
-[ ! -d /proc/sys/net/ipv6/ ] && flags="${flags} -4"
+COMMAND="$1"; shift
 
-set -e
+# If no instance given ("/etc/init.d/nsd stop instance"), and
+# instance-specific files are found, process all instances.
+# Note this does not include the default instance -- if you use
+# instances, then you want to set a name for each of them.
+
+# The default instance is denoted with the empty string, and is
+# special cased to behave the same way as a single instance alone used
+# to.
+
+# Other instances are detected by the existence of
+# "/etc/default/nsd.$INSTANCE".  The instance name must start with
+# [a-z] and contain only [a-z0-9]. This way we easily avoid any *~
+# backup files and *.dpkg-old.
+
+if [ -z "$1" ]; then
+	set -- $(find /etc/default -maxdepth 1 \( -regex '.*/nsd.[a-z][a-z0-9]*' \) -printf '%P\n'|sed -n 's/^nsd\.//p;')
+	if [ "$#" = "0" ]; then
+		# only the default instance exists
+		set -- ''
+	fi
+fi
 
-case "$1" in
+FAILED=""
+
+case "$COMMAND" in
   start)
-	if ${rebuild} && [ "${zonesfile}" -nt "${dbfile}" ]; then ${NSDC} rebuild; fi
-	echo -n "Starting $DESC: $NAME..."
-	start-stop-daemon --start --quiet --pidfile ${pidfile} --exec ${DAEMON} -- -f ${dbfile} ${flags} 2>/dev/null
-	while [ ! -s ${pidfile} ]; do
-		echo -n ".";
-		sleep 1
-		if [ ${COUNTER} = "5" ]; then
-			break
+	echo -n "Starting $DESC:"
+	for INSTANCE in "$@"; do
+		readconfig "$INSTANCE"
+
+		if ${rebuild} && [ "${zonesfile}" -nt "${dbfile}" ]; then
+			announce rebuild "$INSTANCE"
+			"${NSDC}" rebuild "$INSTANCE"
+		fi
+
+		announce "$NAME" "$INSTANCE"
+		start-stop-daemon --start --quiet --pidfile "${pidfile}" --exec "${DAEMON}" -- -P "${pidfile}" -f "${dbfile}" ${flags} 2>/dev/null
+		COUNTER=0
+		while [ ! -s "${pidfile}" ]; do
+			# avoid printing dots for the first time, to make
+			# normal-case output pretty
+			[ "$COUNTER" = "0" ] || echo -n "."
+			sleep 1
+			if [ "${COUNTER}" = "5" ]; then
+				break
+			fi
+			COUNTER="$((${COUNTER}+1))"
+		done
+		if [ ! -s "${pidfile}" ]; then
+			echo " failed"
+			FAILED=true
 		fi
-		COUNTER=$((${COUNTER}+1))
+		"${NSDC}" notify "$INSTANCE"
 	done
-	if [ ! -s ${pidfile} ]; then
-		echo "failed."
-		exit 1
-	fi
-	${NSDC} notify
-	echo "done."
+	echo "."
 	;;
   stop)
-	echo -n "Stopping $DESC: $NAME"
-	start-stop-daemon --stop --oknodo --pidfile /var/run/nsd.pid --exec ${DAEMON}
+	echo -n "Stopping $DESC:"
+	for INSTANCE in "$@"; do
+		readconfig "$INSTANCE"
+		announce "$NAME" "$INSTANCE"
+		start-stop-daemon --stop --oknodo --pidfile "${pidfile}" --exec "${DAEMON}"
+	done
 	echo "."
 	;;
   reload|force-reload)
-	echo -n "Reloading $DESC: $NAME"
-	start-stop-daemon --stop --quiet --signal HUP --pidfile /var/run/nsd.pid --exec $DAEMON
-	${NSDC} notify
+	echo -n "Reloading $DESC:"
+	for INSTANCE in "$@"; do
+		readconfig "$INSTANCE"
+		announce "$NAME" "$INSTANCE"
+		start-stop-daemon --stop --quiet --signal HUP --pidfile "${pidfile}" --exec "${DAEMON}"
+		"${NSDC}" notify "$INSTANCE"
+	done
 	echo "."
 	;;
   restart)
-	${0} stop
-	${0} start
+	"${0}" stop "$@"
+	"${0}" start "$@"
 	;;
   *)
-	${NSDC} ${1}
+	"${NSDC}" "${1}" "$@"
 	;;
 esac
 
+[ -z "$FAILED" ] || exit 1
 exit $?
--- nsd-2.1.4-orig/debian/nsd.default	2004-11-20 17:43:06.000000000 +0200
+++ nsd-2.1.4/debian/nsd.default	2004-11-20 18:14:43.000000000 +0200
@@ -11,14 +11,14 @@
 flags="-u nsd"
 
 # Pathname of the database
-dbfile="/var/lib/nsd/nsd.db"
+dbfile="/var/lib/nsd/nsd${INSTANCE:+.$INSTANCE}.db"
 
 # List of the configured zones
-zonesfile="/etc/nsd/nsd.zones"
+zonesfile="/etc/nsd/nsd${INSTANCE:+.$INSTANCE}.zones"
 
 # The directory containing NSD keys
-keysdir="/etc/nsd/keys"
+keysdir="/etc/nsd/keys${INSTANCE:+.$INSTANCE}"
 
 # Pathname of nsd-notify binary
 notify="/usr/sbin/nsd-notify"
--- nsd-2.1.4-orig/nsdc.sh.in	2004-11-03 10:50:35.000000000 +0200
+++ nsd-2.1.4/nsdc.sh.in	2004-11-22 13:02:43.000000000 +0200
@@ -62,10 +62,14 @@
 #
 # Read in configuration file if any
 #
+INSTANCE="$2"
 if [ -f ${configfile} ]
 then
 	. ${configfile}
 fi
+if [ -n "$INSTANCE" ] && [ -f "${configfile}.$INSTANCE" ]; then
+	. "${configfile}.$INSTANCE"
+fi
 
 #
 # You sure heard this many times before: NO USER SERVICEABLE PARTS BELOW
--- nsd-2.1.4-orig/nsdc.8	2004-11-03 11:44:03.000000000 +0200
+++ nsd-2.1.4/nsdc.8	2004-11-22 13:18:44.000000000 +0200
@@ -43,6 +43,7 @@
 .Sh SYNOPSIS
 .Nm nsdc
 .Ar start|stop|reload|rebuild|restart|running|update|notify
+.Ar [INSTANCE]
 .Sh DESCRIPTION
 .Ic Nsdc
 is the shell script that used to control
@@ -64,7 +65,7 @@
 At every invokation
 .Ic nsdc
 will try to source
-.Pa /etc/nsd/nsdc.conf
+.Pa /etc/default/nsd
 configuration file (shell script) where default configuration settings 
 can be overwritten. An example of such configuration file is distributed
 with the
@@ -72,6 +73,12 @@
 package as
 .Pa nsdc.conf.sample
 .Pp
+If the instance argument is given,
+.Ic nsdc
+will try to source
+.Pa /etc/default/nsd.INSTANCE
+configuration file (shell script) for instance-specific configuration.
+.Pp
 Possible
 .Ic nsdc
 applications are:
@@ -140,7 +147,7 @@
 database
 .It Pa /var/run/nsd.pid
 the process id of the name server.
-.It Pa /etc/nsd/nsdc.conf
+.It Pa /etc/default/nsd
 Optional configuration file for nsdc to overwrite default pathnames
 and
 .Ic NSD

--- End Message ---
--- Begin Message ---
Hi,

since this won't be implemented, I am closing the bug report.

O.
-- 
Ondřej Surý <[email protected]>

--- End Message ---

Reply via email to