Bug 176156 - Add multi-instance support to dns/nsd rc script
Summary: Add multi-instance support to dns/nsd rc script
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Beech Rintoul
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-15 05:20 UTC by Darren Pilgrim
Modified: 2013-02-25 22:10 UTC (History)
0 users

See Also:


Attachments
file.diff (1.99 KB, patch)
2013-02-15 05:20 UTC, Darren Pilgrim
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darren Pilgrim 2013-02-15 05:20:00 UTC
NSD 3.x can run multiple instances by specifying alternate config files via the -c command-line parameter.  The attached patch alters the RC script such that the config file chosen depends on the name of the RC script invoked.  This lets you add instances by creating symlinks to the RC script.  The same approach is used with ISC DHCPD to run the separate v4 and v6 instances.  The pattern is ${LOCAL_BASE}/etc/rc.d/foo tells NSD to use /usr/local/etc/nsd/foo.conf.  This does not change the default behaviour.

Fix: Patch attached with submission follows:
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-15 05:38:31 UTC
Maintainer of dns/nsd,

Please note that PR ports/176156 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/176156

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-15 05:38:32 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Darren Pilgrim 2013-02-15 06:04:14 UTC
I forgot to add that the script adds extra commands for the notify, 
patch, rebuild, and update nsdc commands.  This lets you do:

/usr/local/etc/rc.d/nsdfoo rebuild

instead of:

nsdc -c /i/forgot/which/config/nsdfoo/uses.conf rebuild

Homogeneity of interface, etc.
Comment 4 Jaap Akkerhuis 2013-02-18 19:31:59 UTC
I'm luke warm about this enhancement. It create more complexity and
is probaby only needed by just a small minority of the users. But
yes, go ahead, apply the patch.

	jaap
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2013-02-18 20:38:45 UTC
State Changed
From-To: feedback->open

Maintainer approved.
Comment 6 Beech Rintoul freebsd_committer freebsd_triage 2013-02-25 21:30:35 UTC
Responsible Changed
From-To: freebsd-ports-bugs->beech

I'll take it
Comment 7 dfilter service freebsd_committer freebsd_triage 2013-02-25 21:59:25 UTC
Author: beech
Date: Mon Feb 25 21:59:11 2013
New Revision: 312942
URL: http://svnweb.freebsd.org/changeset/ports/312942

Log:
  - Add multi-instance support
  
  PR:		ports/176156
  Submitted by:	Darren Pilgrim <darren.pilgrim@gmail.com>
  Approved by:	Jaap Akkerhuis <jaap@NLnetLabs.nl> (maintainer)

Modified:
  head/dns/nsd/files/nsd.in   (contents, props changed)

Modified: head/dns/nsd/files/nsd.in
==============================================================================
--- head/dns/nsd/files/nsd.in	Mon Feb 25 21:21:37 2013	(r312941)
+++ head/dns/nsd/files/nsd.in	Mon Feb 25 21:59:11 2013	(r312942)
@@ -14,45 +14,71 @@
 
 . /etc/rc.subr
 
-name=nsd
-rcvar=nsd_enable
+case $0 in
+/etc/rc*)
+	# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
+	# so get the name of the script from $_file
+	name=$_file
+	;;
+*)
+	name=$0
+	;;
+esac
 
-required_files=%%PREFIX%%/etc/nsd/nsd.conf
+name=${name##*/}
 
-command=%%PREFIX%%/sbin/nsdc
-command_args="start"
-pidfile=`%%PREFIX%%/sbin/nsd-checkconf -o pidfile %%PREFIX%%/etc/nsd/nsd.conf`
-procname=%%PREFIX%%/sbin/${name}
+rcvar=${name}_enable
 
 load_rc_config ${name}
 
-nsd_enable=${nsd_enable-"NO"}
+eval ": \${${name}_conf:=\"%%PREFIX%%/etc/nsd/${name}.conf\"}"
+eval "_conf=\${${name}_conf}"
+
+command=%%PREFIX%%/sbin/nsdc
+procname=%%PREFIX%%/sbin/nsd
+
+required_files=${_conf}
+pidfile=`%%PREFIX%%/sbin/nsd-checkconf -o pidfile ${_conf}`
+
+extra_commands="notify patch rebuild reload update"
 
-extra_commands="reload"
-start_precmd="nsd_precmd"
-reload_cmd="nsd_reload"
-stop_cmd="nsd_stop"
+notify_cmd="nsd_nsdc_cmd notify"
+patch_cmd="nsd_nsdc_cmd patch"
+rebuild_cmd="nsd_nsdc_cmd rebuild"
+reload_cmd="nsd_reload_cmd"
+start_cmd="nsd_start_cmd"
+stop_cmd="nsd_stop_cmd"
+update_cmd="nsd_nsdc_cmd update"
 
-nsd_precmd()
+nsd_nsdc_cmd()
 {
-	db=`%%PREFIX%%/sbin/nsd-checkconf -o database %%PREFIX%%/etc/nsd/nsd.conf`
-	if [ ! -f "$db" ]; then
-		${command} rebuild
-	fi
+	${command} -c ${_conf} "$1"
 }
 
-nsd_reload()
+nsd_reload_cmd()
 {
-	${command} rebuild && ${command} reload
+	nsd_nsdc_cmd rebuild && nsd_nsdc_cmd reload
+}
+
+nsd_start_cmd()
+{
+	local _db
+	_db=`%%PREFIX%%/sbin/nsd-checkconf -o database ${_conf}`
+	if [ ! -f "${_db}" ]; then
+		nsd_nsdc_cmd rebuild
+	fi
+
+	echo "Starting ${name}."
+	nsd_nsdc_cmd start
 }
 
-nsd_stop()
+nsd_stop_cmd()
 {
 	echo "Merging nsd zone transfer changes to zone files."
-	${command} patch
+	nsd_nsdc_cmd patch
 
 	echo "Stopping ${name}."
-	${command} stop
+	nsd_nsdc_cmd stop	
 }
 
 run_rc_command "$1"
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 8 Beech Rintoul freebsd_committer freebsd_triage 2013-02-25 21:59:54 UTC
State Changed
From-To: open->closed

Committed, Thanks!