From owner-cvs-all@FreeBSD.ORG Fri Nov 26 20:37:00 2010 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28EAB106564A; Fri, 26 Nov 2010 20:37:00 +0000 (UTC) (envelope-from tom@tomjudge.com) Received: from tomjudge.vm.bytemark.co.uk (tomjudge.vm.bytemark.co.uk [80.68.91.100]) by mx1.freebsd.org (Postfix) with ESMTP id C9C178FC08; Fri, 26 Nov 2010 20:36:59 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by tomjudge.vm.bytemark.co.uk (Postfix) with ESMTP id 0F4ABDCB3C; Fri, 26 Nov 2010 20:36:59 +0000 (GMT) X-Virus-Scanned: Debian amavisd-new at tomjudge.vm.bytemark.co.uk Received: from tomjudge.vm.bytemark.co.uk ([127.0.0.1]) by localhost (tomjudge.vm.bytemark.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L9WeKi176aO6; Fri, 26 Nov 2010 20:36:56 +0000 (GMT) Received: from 192-168-200-57.lan.tj.home.tomjudge.com (unknown [192.168.200.57]) by tomjudge.vm.bytemark.co.uk (Postfix) with ESMTP id 89705DCB3B; Fri, 26 Nov 2010 20:36:55 +0000 (GMT) Message-ID: <4CF01A66.30603@tomjudge.com> Date: Fri, 26 Nov 2010 14:36:54 -0600 From: Tom Judge User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: Doug Barton References: <201011251458.oAPEwX25045477@repoman.freebsd.org> <4CEEB376.9030701@FreeBSD.org> In-Reply-To: <4CEEB376.9030701@FreeBSD.org> Content-Type: multipart/mixed; boundary="------------010407080301040107090300" Cc: Josh Paetzel , cvs-ports@FreeBSD.org, cvs-all@FreeBSD.org, ports-committers@FreeBSD.org Subject: Re: cvs commit: ports/net-mgmt/softflowd/files softflowd.in ports/net-mgmt/softflowd Makefile X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2010 20:37:00 -0000 This is a multi-part message in MIME format. --------------010407080301040107090300 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Here is a further update that makes (status|poll|rcvar) work also. Tom On 25/11/2010 13:05, Doug Barton wrote: > With all due respect to Tom, this script is not in good shape, and > should not have been committed in its current form. I've attached a > patch that corrects the most glaring errors. It would be great if Tom, > or someone else familiar with this software, could test it ASAP and > report back. > > 1. Lots of extraneous whitespace, including newlines at the beginning > and end of the script, eols; and inconsistent indentation. > 2. No $FreeBSD$ > 3. Unless there is a good reason to do otherwise local scripts should > use REQUIRE: LOGIN. > 4. There should be no quotes around /etc/rc.subr > 5. The default values should be set after calling load_rc_config() > 6. We do not like any code to be run in rc.d scripts unconditionally. > 7. The script is not PREFIX clean. > > Once again, I appreciate the effort put in here, but given that a lot > of rc.d scripts are copied from other scripts (which seems like what > was done here) we need to be doubly careful with QA so that bad > examples don't propagate further. > > > Doug > > > On 11/25/2010 06:58, Josh Paetzel wrote: >> jpaetzel 2010-11-25 14:58:33 UTC >> >> FreeBSD ports repository >> >> Modified files: >> net-mgmt/softflowd Makefile >> Added files: >> net-mgmt/softflowd/files softflowd.in >> Log: >> Add rc.d script to port >> >> PR: ports/151398 >> http://www.FreeBSD.org/cgi/query-pr.cgi?pr=151398 >> Submitted by: Tom Judge >> Approved by: Maintainer timeout >> >> Revision Changes Path >> 1.5 +2 -0 ports/net-mgmt/softflowd/Makefile >> 1.1 +75 -0 ports/net-mgmt/softflowd/files/softflowd.in >> (new) >> >> http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/net-mgmt/softflowd/Makefile.diff?&r1=1.4&r2=1.5&f=h >> >> http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/net-mgmt/softflowd/files/softflowd.in >> >> > > > --------------010407080301040107090300 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="softflowd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="softflowd.patch" --- softflowd.in.orig 2010-11-26 14:32:42.874001002 -0600 +++ softflowd.in 2010-11-26 14:33:23.834001003 -0600 @@ -1,11 +1,11 @@ - #!/bin/sh -# (c) 2010 Tom Judge +# $FreeBSD$ + +# (c) 2010 Tom Judge # PROVIDE: softflowd -# REQUIRE: NETWORKING -# BEFORE: LOGIN +# REQUIRE: LOGIN # KEYWORD: shutdown # softflowd_enable="YES" @@ -19,57 +19,64 @@ # softflowd_em0_extra_args="" # softflowd_em1_extra_args="" -. "/etc/rc.subr" - -softflowd_enable=${softflowd_enable:-"NO"} -softflowd_timeouts="-t maxlife=300" -softflowd_max_states="16000" -softflowd_extra_args="" +. /etc/rc.subr name=softflowd rcvar=`set_rcvar` -load_rc_config $name + +start_precmd="softflowd_precommand $@" +stop_precmd="softflowd_precommand $@" +status_precmd="softflowd_precommand $@" +poll_precmd="softflowd_precommand $@" +rcvar_precmd="softflowd_precommand $@" stop_cmd="softflowd_stop" -command="/usr/local/sbin/softflowd" +command="%%PREFIX%%/sbin/softflowd" _pidprefix="/var/run/softflowd" - -if [ -n "$2" ]; then - profile="$2" - pidfile="${_pidprefix}.${profile}.pid" - ctlfile="${_pidprefix}.${profile}.ctl" - eval apache22_flags="\${apache22_${profile}_flags:-${apache22_flags}}" - eval softflowd_collector="\${softflowd_${profile}_collector}" - if [ "x${softflowd_collector}" = "x" ]; then - echo "ERROR: You must specify a collector to send data to." - exit 1 - fi - eval softflowd_timeouts="\${softflowd_${profile}_timeouts:-${softflowd_timeouts}}" - eval softflowd_max_states="\${softflowd_${profile}_max_states:-${softflowd_max_states}}" - eval softflowd_extra_args="\${softflowd_${profile}_extra_args:-${softflowd_extra_args}}" - command_args="-i ${profile} -n ${softflowd_collector} -m ${softflowd_max_states} -p ${pidfile} -c ${ctlfile} ${softflowd_timeouts} ${softflowd_extra_args}" - -else - if [ "x${softflowd_interfaces}" != "x" -a "x$1" != "x" ]; then - for profile in ${softflowd_interfaces}; do - echo "===> softflowd profile: ${profile}" - /usr/local/etc/rc.d/softflowd $1 ${profile} - retcode="$?" - if [ "0${retcode}" -ne 0 ]; then - failed="${profile} (${retcode}) ${failed:-}" - else - success="${profile} ${success:-}" - fi - done - exit 0 - fi +if [ -n $2 ]; then + pidfile="${_pidprefix}.${2}.pid" fi -softflowd_stop() { - /usr/local/sbin/softflowctl -c ${ctlfile} shutdown -} - +load_rc_config $name -run_rc_command "$1" +softflowd_enable=${softflowd_enable:-"NO"} +softflowd_timeouts="-t maxlife=300" +softflowd_max_states="16000" +softflowd_precommand () +{ + if [ -n "$2" ]; then + profile="$2" + ctlfile="${_pidprefix}.${profile}.ctl" + eval apache22_flags="\${apache22_${profile}_flags:-${apache22_flags}}" + eval softflowd_collector="\${softflowd_${profile}_collector}" + if [ "x${softflowd_collector}" = "x" ]; then + echo "ERROR: You must specify a collector to send data to." + exit 1 + fi + eval softflowd_timeouts="\${softflowd_${profile}_timeouts:-${softflowd_timeouts}}" + eval softflowd_max_states="\${softflowd_${profile}_max_states:-${softflowd_max_states}}" + eval softflowd_extra_args="\${softflowd_${profile}_extra_args:-${softflowd_extra_args}}" + command_args="-i ${profile} -n ${softflowd_collector} -m ${softflowd_max_states} -p ${pidfile} -c ${ctlfile} ${softflowd_timeouts} ${softflowd_extra_args}" + else + if [ "x${softflowd_interfaces}" != "x" ]; then + for profile in ${softflowd_interfaces}; do + echo "===> softflowd profile: ${profile}" + %%PREFIX%%/etc/rc.d/softflowd $1 ${profile} + retcode="$?" + if [ "0${retcode}" -ne 0 ]; then + failed="${profile} (${retcode}) ${failed:-}" + else + success="${profile} ${success:-}" + fi + done + fi + exit 0 + fi +} +softflowd_stop() +{ + %%PREFIX%%/sbin/softflowctl -c ${ctlfile} shutdown +} +run_rc_command "$1" --------------010407080301040107090300--