Date: Sat, 09 Jun 2012 10:58:40 -0700 From: Doug Barton <dougb@FreeBSD.org> To: Sahil Tandon <sahil@tandon.net> Cc: freebsd-rc@freebsd.org Subject: Re: RESEND: [sahil@tandon.net: Request for review: mail/postfix-postfwd rc script] Message-ID: <4FD38ED0.7070803@FreeBSD.org> In-Reply-To: <20120609010405.GA295@magic.hamla.org> References: <20120609010405.GA295@magic.hamla.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4FD38ED0.7070803>