From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Feb 15 05:20:00 2013 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A092F5EA for ; Fri, 15 Feb 2013 05:20:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 87C3F281 for ; Fri, 15 Feb 2013 05:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r1F5K0TI015141 for ; Fri, 15 Feb 2013 05:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r1F5K0vs015140; Fri, 15 Feb 2013 05:20:00 GMT (envelope-from gnats) Resent-Date: Fri, 15 Feb 2013 05:20:00 GMT Resent-Message-Id: <201302150520.r1F5K0vs015140@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Darren Pilgrim Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 97A375BB for ; Fri, 15 Feb 2013 05:12:51 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 744CE26A for ; Fri, 15 Feb 2013 05:12:51 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r1F5CoFR051470 for ; Fri, 15 Feb 2013 05:12:50 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r1F5Cogt051469; Fri, 15 Feb 2013 05:12:50 GMT (envelope-from nobody) Message-Id: <201302150512.r1F5Cogt051469@red.freebsd.org> Date: Fri, 15 Feb 2013 05:12:50 GMT From: Darren Pilgrim To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/176156: Add multi-instance support to NSD rc script X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Feb 2013 05:20:00 -0000 >Number: 176156 >Category: ports >Synopsis: Add multi-instance support to NSD rc script >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Feb 15 05:20:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Darren Pilgrim >Release: >Organization: >Environment: >Description: 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. >How-To-Repeat: >Fix: Patch attached with submission follows: --- files/nsd.in.orig 2012-02-21 15:26:18.452254011 -0800 +++ files/nsd.in 2012-09-09 06:11:14.075501163 -0700 @@ -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" >Release-Note: >Audit-Trail: >Unformatted: