Date: Thu, 7 Jun 2012 20:46:13 -0400 From: Sahil Tandon <sahil@tandon.net> To: freebsd-rc@FreeBSD.org Subject: Request for review: mail/postfix-postfwd rc script Message-ID: <20120608004612.GA15600@magic.hamla.org>
next in thread | raw e-mail | index | archive | help
--ZoaI/ZTpAVc4A5k6 Content-Type: multipart/mixed; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. --=20 Sahil Tandon --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="postfwd-rc_script.txt" Content-Transfer-Encoding: quoted-printable Index: files/postfwd.in =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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): =20 # 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. # =20 . /etc/rc.subr @@ -19,27 +20,45 @@ name=3Dpostfwd rcvar=3Dpostfwd_enable =20 -command=3D%%PREFIX%%/bin/${name} -required_files=3D%%PREFIX%%/etc/${name}.conf -pidfile=3D"/var/run/${name}.pid" +load_rc_config $name =20 -stop_postcmd=3Dstop_postcmd +: ${postfwd_enable=3D"NO"} +: ${postfwd_config=3D"%%PREFIX%%/etc/${name}.conf"} +: ${postfwd_flags=3D"--shortlog --summary=3D600 --cache=3D600 --cache-rbl-= timeout=3D3600 --cleanup-requests=3D1200 --cleanup-rbls=3D1800 --cleanup-ra= tes=3D1200"} +: ${postfwd_pidfile=3D"/var/run/${name}.pid"} =20 -stop_postcmd() -{ - rm -f $pidfile -} +required_files=3D%%PREFIX%%/etc/${name}.conf +command=3D%%PREFIX%%/bin/${name} +command_args=3D"-d -f ${required_files} --pidfile=3D${postfwd_pidfile} -i = 127.0.0.1 -p 10040 -u nobody -g nobody" =20 -load_rc_config "$name" +start_precmd=3D"${name}_check" +status_cmd=3D"${name}_status" +stop_cmd=3D"${name}_stop" +stop_postcmd=3D"${name}_postcmd" +extra_commands=3D"reload" + +postfwd_check() { + if [ -f "${postfwd_pidfile}" ]; then + err 1 "${name} is already running." + fi +} =20 -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=3D\"YES\" in /= etc/rc.conf" ;; -esac +postfwd_status() { + postfwd_pid=3D`cat ${postfwd_pidfile} 2>/dev/null` + postfwd_run=3D`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 +} =20 -: ${postfwd_enable=3D"NO"} -: ${postfwd_config=3D"%%PREFIX%%/etc/${name}.conf"} +postfwd_stop() { + ${command} -k --pidfile=3D${postfwd_pidfile}=20 +} =20 -command_args=3D"--shortlog --summary=3D600 --cache=3D600 --cache-rbl-timeo= ut=3D3600 --cleanup-requests=3D1200 --cleanup-rbls=3D1800 --cleanup-rates= =3D1200 -d -f ${required_files} -i 127.0.0.1 -p 10040 -u nobody -g nobody" +postfwd_postcmd() { + rm -f ${postfwd_pidfile} +} =20 run_rc_command "$1" --jI8keyz6grp/JLjh-- --ZoaI/ZTpAVc4A5k6 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJP0UtUAAoJENvQYAHAFtl3ZikIAJTCAflwGJ1f/YM9jGHR8qje NniRM2uA94y0vZDCKuLl9Nyr0D+2ZwvOZi2ylLPpMiTYNr00O4AlMEhvTDkSdJwc t95+4O18OlO2Q8/OutuI/ctgytrDpOtnO1tDU4Fc+eW2MDhgjQBIMh3HsLFa7Gfz boVOrUPQG7/OH15cdP55DiGtNsUcqygNfqnxRgSxjFXk++UmfivfJ5s8sw4pLTmB U/dUJBBBCY9nGPIDh3UVulfTbHpgfB8TXxA2QAmLyxuiTgUN8xbTUaqK4WGpfYaG cB62P8ZsCcEL98H6TzzEYJp+lH7RQ51ujE+N8XxxigLHXEhY+NIhcstBuPft8U0= =p9+p -----END PGP SIGNATURE----- --ZoaI/ZTpAVc4A5k6--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120608004612.GA15600>