Portfile

# $Id: Portfile 20414 2006-11-03 02:15:12Z jberry@macports.org $
PortSystem 1.0

name pflogsumm
version 1.1.0
categories mail
maintainers nomaintainer@macports.org
description Produce Postfix MTA logfile summary
long_description Pflogsumm is a log analyzer/summarizer for the \
Postfix MTA. It is designed to provide an over-view \
of Postfix activity, with just enough detail to give \
the administrator a "heads up" for potential trouble \
spots. \
Pflogsumm generates summaries and, in some cases, \
detailed reports of mail server traffic volumes, \
rejected and bounced email, and server warnings, \
errors and panics. \
Also installs Chris Cappuccio's CGI script for \
browser access to the Pflogsumm output.
homepage http://jimsun.linxnet.com/postfix_contrib.html
master_sites http://jimsun.linxnet.com/downloads/ \
http://www.nmedia.net/~chris/mail/:cgi
distfiles-append mail-cgi.txt:cgi
checksums ${distname}.tar.gz md5 1f78fcaf2a36ec3520ecff286a45251a \
mail-cgi.txt md5 352451388eed3d1f7255dc07fc411d97
extract.only ${distname}.tar.gz
platforms darwin freebsd

set perl5.bin ${prefix}/bin/perl

depends_run bin:${perl5.bin}:perl5.8 \
port:p5-date-calc

set cgi_path ""
set maillog_path ""

variant darwin {
global cgi_path maillog_path
set cgi_path "/Library/WebServer/CGI-Executables"
set maillog_path "/var/log/mail.log"

# DarwinPorts Apache interoperability
if {[file exists ${prefix}/sbin/httpd]} {
set cgi_path "${prefix}/www/cgi-bin"
}
}

variant freebsd {
global cgi_path maillog_path
set cgi_path "/usr/local/www/cgi-bin"
set maillog_path "/var/log/maillog"

# DarwinPorts Apache interoperability
if {[file exists ${prefix}/sbin/httpd]} {
set cgi_path "${prefix}/www/cgi-bin"
}
}

post-extract {
file copy -force ${distpath}/mail-cgi.txt ${worksrcpath}/${name}.cgi
}

use_configure no

build {
cd ${worksrcpath}
reinplace "s|^#!.*perl|#!${perl5.bin}|" ${name}.pl
reinplace "s|mail.empnet.com|[exec hostname]|" ${name}.cgi
reinplace "s|/var/log/maillog|${maillog_path}|" ${name}.cgi
reinplace "s|${maillog_path}\[.\]\[0-3\]|&.gz|" ${name}.cgi
reinplace "s|/usr/ucb/ps|[binaryInPath ps]|" ${name}.cgi
reinplace "s|zcat=\"/bin/cat|zcat=\"[binaryInPath zcat]|" ${name}.cgi
reinplace "s|/bin/cat|[binaryInPath cat]|" ${name}.cgi
reinplace "s|/usr/local/bin/${name}.pl|${prefix}/bin/${name}|" ${name}.cgi
reinplace "s|^opts=|# &|" ${name}.cgi
reinplace "s|^#opts=|opts=|" ${name}.cgi
reinplace "s|mail.cgi|${name}.cgi|" ${name}.cgi
reinplace "s|\$pflog \$opts.*$|& 2>\\&1|" ${name}.cgi
}

destroot {
xinstall -m 0755 ${worksrcpath}/${name}.pl \
${destroot}${prefix}/bin/${name}
xinstall -m 0644 ${worksrcpath}/${name}.1 \
${destroot}${prefix}/share/man/man1
xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
xinstall -m 0644 ${worksrcpath}/${name}-faq.txt \
${destroot}${prefix}/share/doc/${name}
xinstall -d -m 0755 ${destroot}${cgi_path}
set maillog_group [file attributes ${maillog_path} -group]
xinstall -m 02755 -g ${maillog_group} ${worksrcpath}/${name}.cgi \
${destroot}${cgi_path}
}