Date: Fri, 8 Jun 2012 21:04:06 -0400 From: Sahil Tandon <sahil@tandon.net> To: freebsd-rc@freebsd.org Subject: RESEND: [sahil@tandon.net: Request for review: mail/postfix-postfwd rc script] Message-ID: <20120609010405.GA295@magic.hamla.org>
next in thread | raw e-mail | index | archive | help
I suspect my last message was mangled in transit because of the way the attachment was included; trying again in-line. ----- Forwarded message from Sahil Tandon <sahil@tandon.net> ----- Greetings, I haven't hacked on rc scripts in a while, and have made some non-negligible changes to the mail/postfix-postfwd script. I would be much obliged to anyone who could catch egregious mistakes, and also welcome style or "best practices" suggestions. No need to be gentle, and thanks in advance! :) Please Cc: me on any replies as I am not subscribed to this list. -- Sahil Tandon Index: files/postfwd.in =================================================================== RCS file: /home/pcvs/ports/mail/postfix-postfwd/files/postfwd.in,v retrieving revision 1.4 diff -u -u -r1.4 postfwd.in --- files/postfwd.in 14 Jan 2012 08:56:01 -0000 1.4 +++ files/postfwd.in 8 Jun 2012 00:43:08 -0000 @@ -9,9 +9,10 @@ # # 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 @@ -19,27 +20,45 @@ name=postfwd rcvar=postfwd_enable -command=%%PREFIX%%/bin/${name} -required_files=%%PREFIX%%/etc/${name}.conf -pidfile="/var/run/${name}.pid" +load_rc_config $name -stop_postcmd=stop_postcmd +: ${postfwd_enable="NO"} +: ${postfwd_config="%%PREFIX%%/etc/${name}.conf"} +: ${postfwd_flags="--shortlog --summary=600 --cache=600 --cache-rbl-timeout=3600 --cleanup-requests=1200 --cleanup-rbls=1800 --cleanup-rates=1200"} +: ${postfwd_pidfile="/var/run/${name}.pid"} -stop_postcmd() -{ - rm -f $pidfile -} +required_files=%%PREFIX%%/etc/${name}.conf +command=%%PREFIX%%/bin/${name} +command_args="-d -f ${required_files} --pidfile=${postfwd_pidfile} -i 127.0.0.1 -p 10040 -u nobody -g nobody" -load_rc_config "$name" +start_precmd="${name}_check" +status_cmd="${name}_status" +stop_cmd="${name}_stop" +stop_postcmd="${name}_postcmd" +extra_commands="reload" + +postfwd_check() { + if [ -f "${postfwd_pidfile}" ]; then + err 1 "${name} is already running." + fi +} -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 +postfwd_status() { + postfwd_pid=`cat ${postfwd_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 +} -: ${postfwd_enable="NO"} -: ${postfwd_config="%%PREFIX%%/etc/${name}.conf"} +postfwd_stop() { + ${command} -k --pidfile=${postfwd_pidfile} +} -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" +postfwd_postcmd() { + rm -f ${postfwd_pidfile} +} run_rc_command "$1" ----- End forwarded message -----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120609010405.GA295>