1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-29 10:18:30 +00:00

- Add OPTION to install postfwd v2 rather than v1 and

convert to new options framework.

- Revise the rc.d script[1] with style and functionality
  improvements, one of which works around an upstream
  issue that obstructed operation of 'status' and other
  functions.  Because this affects the default package,
  bump PORTREVISION.

Reviewed by:	dougb [1]
This commit is contained in:
Sahil Tandon 2012-06-10 18:58:16 +00:00
parent 63d09c9c9b
commit 8c1d11010c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=298971
2 changed files with 55 additions and 31 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= postfwd
PORTVERSION= 1.32
PORTREVISION= 1
CATEGORIES= mail
MASTER_SITES= http://www.${PORTNAME}.org/old/
PKGNAMEPREFIX= postfix-
@ -21,37 +22,42 @@ RUN_DEPENDS= ${SITE_PERL}/${PERL_ARCH}/Net/DNS.pm:${PORTSDIR}/dns/p5-Net-DNS \
${SITE_PERL}/${PERL_ARCH}/Storable.pm:${PORTSDIR}/devel/p5-Storable \
${SITE_PERL}/${PERL_ARCH}/Time/HiRes.pm:${PORTSDIR}/devel/p5-Time-HiRes
PORTDOCS= arch.html ${PORTNAME}.CHANGELOG ${PORTNAME}.html \
${PORTNAME}.txt quick.html versions.html
PORTDOCS= *
PORTEXAMPLES= request.sample postfwd.plugins.sample
PLIST_FILES= bin/${PORTNAME} etc/${PORTNAME}.conf.sample
PLIST_FILES= bin/${PORTNAME} etc/${PORTNAME}.conf.sample
SUB_FILES= pkg-message
USE_RC_SUBR= ${PORTNAME}
USE_PERL5_RUN= yes
NO_BUILD= yes
MAN8= ${PORTNAME}.8
MAN8= ${PORTNAME}.8 ${PORTNAME}2.8
.include <bsd.port.pre.mk>
OPTIONS_DEFINE= EXAMPLES DOCS POSTFWD2
POSTFWD2_DESC= Install postfwd v2 rather than v1
.include <bsd.port.options.mk>
do-install:
.if ${PORT_OPTIONS:MPOSTFWD2}
@${INSTALL_SCRIPT} ${WRKSRC}/sbin/${PORTNAME}2 ${PREFIX}/bin/${PORTNAME}
.else
@${INSTALL_SCRIPT} ${WRKSRC}/sbin/${PORTNAME} ${PREFIX}/bin/
.endif
@${INSTALL_DATA} ${WRKSRC}/etc/${PORTNAME}.cf.sample ${PREFIX}/etc/${PORTNAME}.conf.sample
@${INSTALL_MAN} ${WRKSRC}/man/man8/${MAN8} ${MANPREFIX}/man/man8/
@${INSTALL_MAN} ${WRKSRC}/man/man8/* ${MANPREFIX}/man/man8/
post-install:
.if !defined(NOPORTDOCS)
.if !empty(PORT_OPTIONS:MDOCS)
@${INSTALL} -o ${DOCOWN} -g ${DOCGRP} -m 555 -d ${DOCSDIR}
@cd ${WRKSRC}/doc/ && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}
.endif
.if !defined(NOPORTEXAMPLES)
.if !empty(PORT_OPTIONS:MEXAMPLES)
@${INSTALL} -o ${SHAREOWN} -g ${SHAREGRP} -m 555 -d ${EXAMPLESDIR}
@${INSTALL_DATA} ${WRKSRC}/tools/request.sample ${EXAMPLESDIR}
@${INSTALL_DATA} ${WRKSRC}/plugins/postfwd.plugins.sample ${EXAMPLESDIR}
.endif
@${CAT} ${PKGMESSAGE}
.include <bsd.port.post.mk>
.include <bsd.port.mk>

View File

@ -1,45 +1,63 @@
#!/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
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"}
pidfile=${postfwd_pidfile:="/var/run/${name}.pid"}
required_files=${postfwd_config:="%%PREFIX%%/etc/${name}.conf"}
command=%%PREFIX%%/bin/${name}
required_files=%%PREFIX%%/etc/${name}.conf
pidfile="/var/run/${name}.pid"
command_args="--daemon --file=${required_files} --pidfile=${pidfile} --interface=127.0.0.1 --port=10040 --user=nobody --group=nobody"
stop_postcmd=stop_postcmd
start_precmd="${name}_check"
status_cmd="${name}_status"
stop_cmd="${command} -k --pidfile=${pidfile}"
stop_postcmd="rm -f ${pidfile}"
extra_commands="reload"
reload_cmd="${name}_reload"
stop_postcmd()
{
rm -f $pidfile
postfwd_check() {
if [ -f "${postfwd_pidfile}" ]; then
err 1 "${name} is already running."
fi
}
load_rc_config "$name"
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
}
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_reload() {
: ${postfwd_enable="NO"}
: ${postfwd_config="%%PREFIX%%/etc/${name}.conf"}
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"
kill -HUP `cat $pidfile`
}
run_rc_command "$1"