From owner-freebsd-rc@FreeBSD.ORG Sat Jun 9 17:58:56 2012 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by hub.freebsd.org (Postfix) with ESMTP id 9F2801065670 for ; Sat, 9 Jun 2012 17:58:56 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from opti.dougb.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 41618153D30; Sat, 9 Jun 2012 17:58:41 +0000 (UTC) Message-ID: <4FD38ED0.7070803@FreeBSD.org> Date: Sat, 09 Jun 2012 10:58:40 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120608 Thunderbird/12.0.1 MIME-Version: 1.0 To: Sahil Tandon References: <20120609010405.GA295@magic.hamla.org> In-Reply-To: <20120609010405.GA295@magic.hamla.org> X-Enigmail-Version: 1.4.2 OpenPGP: id=D5B2F0FB Content-Type: multipart/mixed; boundary="------------060102080006000809080004" Cc: freebsd-rc@freebsd.org Subject: Re: RESEND: [sahil@tandon.net: Request for review: mail/postfix-postfwd rc script] X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jun 2012 17:58:56 -0000 This is a multi-part message in MIME format. --------------060102080006000809080004 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sorry for the delay, here's a different patch that incorporates most of your changes, with a few other improvements: 1. Add a $FreeBSD$ 2. Remove some trailing whitespace 3. pidfile= is magic, and needs to be included. It's also not usually necessary to allow the user to change the pidfile location, but if you really want to allow that, the way to do it is in the new patch. 4. It's not clear to me why there are so many items in the default _flags option. Are any of those truly required? If so, they should be in command_args. OTOH, if what this represents is a rational default configuration that the user might want to twiddle, it's fine. 5. I used the same trick for the conf file as I did for pidfile (utilizing required_files). It was already properly utilized in command_args in your patch. 6. Rather than having stop_cmd and stop_postcmd be separate functions I just put them in line. 7. With pidfile= the check command you added should not be necessary, 'service postfwd status' is what you want instead. Of course, none of this is tested, so you'll want to do that. :) hth, Doug -- This .signature sanitized for your protection --------------060102080006000809080004 Content-Type: text/plain; charset=UTF-8; name="postfwd.in.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="postfwd.in.patch" --- /usr/ports/mail/postfix-postfwd/files/postfwd.in 2012-01-15 14:25:28.000000000 -0800 +++ postfwd.in 2012-06-09 10:35:44.000000000 -0700 @@ -1,45 +1,50 @@ #!/bin/sh -# PROVIDE: postfwd +# $FreeBSD$ +# +# PROVIDE: postfwd # REQUIRE: LOGIN cleanvar # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # -# postfwd_enable (bool): +# postfwd_enable (bool): # Set to "NO" by default. -# Set it to "YES" to enable postfwd. -# postfwd_config (path): Set to %%PREFIX%%/etc/postfwd.conf -# by default. -# +# Set it to "YES" to enable postfwd. +# postfwd_config (path): +# Set to %%PREFIX%%/etc/postfwd.conf +# by default. . /etc/rc.subr name=postfwd rcvar=postfwd_enable -command=%%PREFIX%%/bin/${name} -required_files=%%PREFIX%%/etc/${name}.conf -pidfile="/var/run/${name}.pid" - -stop_postcmd=stop_postcmd +load_rc_config $name -stop_postcmd() -{ - rm -f $pidfile -} - -load_rc_config "$name" +: ${postfwd_enable:="NO"} +: ${postfwd_flags="--shortlog --summary=600 --cache=600 --cache-rbl-timeout=3600 --cleanup-requests=1200 --cleanup-rbls=1800 --cleanup-rates=1200"} -case "$postfwd_enable" in - [Yy][Ee][Ss] | 1 | [Oo][Nn] | [Tt][Rr][Uu][Ee]) ;; - *) echo "To make use of $name you must first set $rcvar=\"YES\" in /etc/rc.conf" ;; -esac +pidfile=${postfwd_pidfile:="/var/run/${name}.pid"} +required_files=${postfwd_config:="%%PREFIX%%/etc/${name}.conf"} -: ${postfwd_enable="NO"} -: ${postfwd_config="%%PREFIX%%/etc/${name}.conf"} +command=%%PREFIX%%/bin/${name} +command_args="-d -f ${required_files} --pidfile=${pidfile} -i 127.0.0.1 -p 10040 -u nobody -g nobody" -command_args="--shortlog --summary=600 --cache=600 --cache-rbl-timeout=3600 --cleanup-requests=1200 --cleanup-rbls=1800 --cleanup-rates=1200 -d -f ${required_files} -i 127.0.0.1 -p 10040 -u nobody -g nobody" +status_cmd="${name}_status" +stop_cmd="${command} -k --pidfile=${pidfile}" +stop_postcmd="rm -f ${pidfile}" +extra_commands="reload" + +postfwd_status() { + postfwd_pid=`cat ${pidfile} 2>/dev/null` + postfwd_run=`ps -U nobody | grep -m 1 ${postfwd_pid} 2>/dev/null` + if [ -n "${postfwd_pid}" -a -n "${postfwd_run}" ]; then + echo "$name is running as ${postfwd_pid}" + else + echo "$name is not running" + fi +} run_rc_command "$1" --------------060102080006000809080004--