From owner-svn-ports-head@freebsd.org Wed Aug 17 13:22:28 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65CD0BBDCA1; Wed, 17 Aug 2016 13:22:28 +0000 (UTC) (envelope-from lev@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 29FA31D7C; Wed, 17 Aug 2016 13:22:28 +0000 (UTC) (envelope-from lev@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7HDMRVl044308; Wed, 17 Aug 2016 13:22:27 GMT (envelope-from lev@FreeBSD.org) Received: (from lev@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7HDMRUi044307; Wed, 17 Aug 2016 13:22:27 GMT (envelope-from lev@FreeBSD.org) Message-Id: <201608171322.u7HDMRUi044307@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lev set sender to lev@FreeBSD.org using -f From: "Lev A. Serebryakov" Date: Wed, 17 Aug 2016 13:22:27 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r420347 - head/dns/nsd/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2016 13:22:28 -0000 Author: lev Date: Wed Aug 17 13:22:27 2016 New Revision: 420347 URL: https://svnweb.freebsd.org/changeset/ports/420347 Log: Add profiles to nsd init script. PR: 211883 Submitted by: lev Approved by: jaap@NLnetLabs.nl Modified: head/dns/nsd/files/nsd.in Modified: head/dns/nsd/files/nsd.in ============================================================================== --- head/dns/nsd/files/nsd.in Wed Aug 17 13:21:46 2016 (r420346) +++ head/dns/nsd/files/nsd.in Wed Aug 17 13:22:27 2016 (r420347) @@ -11,6 +11,18 @@ # # nsd_enable="YES" # +# You could set alternative config with +# +# nsd_config="/path/to/config" +# +# Multiple profiles are supported with +# +# nsd_profiles="name1 name2" +# nsd_name1_enable="YES" +# nsd_name1_config="/path/to/config1" +# nsd_name2_enable="YES" +# nsd_name2_config="/path/to/config2" +# . /etc/rc.subr @@ -19,16 +31,77 @@ rcvar=nsd_enable # read settings, set default values load_rc_config "${name}" -: ${nsd_enable="NO"} +: ${nsd_enable:="NO"} +: ${nsd_config:=%%ETCDIR%%/nsd.conf} -config=${nsd_config:=%%ETCDIR%%/nsd.conf} -required_files=${config} -pidfile=`%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${config}` +# Set PID file +_pidprefix=/var/run/${name} +_cfgpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${nsd_config}) +pidfile=${_cfgpidfile:-${_pidprefix}.pid} + +required_files=${nsd_config} command="%%PREFIX%%/sbin/${name}" -command_args="-c ${required_files}" +command_args="-c ${nsd_config} -P ${pidfile}" extra_commands="reload" -load_rc_config $name +load_rc_config "${name}" + +if [ -n "$2" ]; then + profile="$2" + if [ "x${nsd_profiles}" != "x" ]; then + eval nsd_config="\${nsd_${profile}_config:-%%ETCDIR%%/nsd-${profile}.conf}" + if [ "x${nsd_config}" = "x" ]; then + echo "You must define a configuration file (nsd_${profile}_config)" + exit 1 + fi + _cfgpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${nsd_config}) + _defaultpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile /dev/null) + # Replace empty or default value with profile-based + if [ "x${_cfgpidfile}" = "x" -o "x${_cfgpidfile}" = "x${_defaultpidfile}" ] ; then + pidfile=${_pidprefix}-${profile}.pid + else + pidfile=${_cfgpidfile} + fi + required_files="${nsd_config}" + eval nsd_enable="\${nsd_${profile}_enable:-${nsd_enable}}" + command_args="-c ${nsd_config} -P ${pidfile}" + else + echo "$0: extra argument ignored" + fi +else + if [ "x${nsd_profiles}" != "x" -a "x$1" != "x" ]; then + for profile in ${nsd_profiles}; do + eval _enable="\${nsd_${profile}_enable}" + case "x${_enable:-${nsd_enable}}" in + x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee]) + continue + ;; + x[Yy][Ee][Ss]) + ;; + *) + if test -z "$_enable"; then + _var=nsd_enable + else + _var=nsd_"${profile}"_enable + fi + echo "Bad value" \ + "'${_enable:-${nsd_enable}}'" \ + "for ${_var}. " \ + "Profile ${profile} skipped." + continue + ;; + esac + echo "===> nsd profile: ${profile}" + %%PREFIX%%/etc/rc.d/nsd $1 ${profile} + retcode="$?" + if [ "0${retcode}" -ne 0 ]; then + failed="${profile} (${retcode}) ${failed:-}" + else + success="${profile} ${success:-}" + fi + done + exit 0 + fi +fi run_rc_command "$1" -