# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem		1.0

name			assp
version			1.1.0
categories		mail
license			GPL-2
maintainers		nomaintainer
description		Anti-Spam SMTP Proxy (ASSP) Server
long_description	The Anti-Spam SMTP Proxy (ASSP) Server is an open \
					source, platform-independent SMTP Proxy server which \
					implements whitelists and Bayesian filtering to rid \
					the planet of the blight of unsolicited email (UCE). \
					UCE must be stopped at the SMTP server.  Anti-spam \
					tools must be adaptive to new spam and customized \
					for each site?s mail patterns. This free, \
					easy-to-use tool works with any mail transport and \
					achieves these goals requiring no operator \
					intervention after the initial setup phase.
homepage		http://assp.sourceforge.net/
master_sites	sourceforge
use_zip			yes
checksums		md5 55be31bab3efacc6bd964adf8cd25c83
platforms		any
supported_archs	noarch

depends_run		port:perl5

extract.mkdir	yes

set assp_base	${prefix}/var/assp

pre-patch {
	file rename "${worksrcpath}/ASSP Documentation.htm" ${worksrcpath}/ASSPDocumentation.htm
	file rename "${worksrcpath}/Regular Expression Tutorial.htm" ${worksrcpath}/RegularExpressionTutorial.htm
	foreach file [glob -directory ${worksrcpath} *.pl *.sh *.htm *.txt rc/*.dat] {
		reinplace -locale C "s%\r%%" $file
	}
}
patchfiles		patch-assp.pl.diff

configure {
	reinplace "s%^#!.*perl%#!${prefix}/bin/perl%" \
		${worksrcpath}/assp.pl \
		${worksrcpath}/move2num.pl \
		${worksrcpath}/rebuildspamdb.pl \
		${worksrcpath}/repair.pl \
		${worksrcpath}/stat.pl
	reinplace -locale C "s%/usr/local/assp%${assp_base}%" \
		${worksrcpath}/ASSPDocumentation.htm \
		${worksrcpath}/stats.sh \
		${worksrcpath}/assp.pl \
		${worksrcpath}/rc/assp.dat \
		${worksrcpath}/rc/start.dat \
		${worksrcpath}/rc/stop.dat
	reinplace -locale C "s%/usr/local%${prefix}%" \
		${worksrcpath}/ASSPDocumentation.htm
}

build {}

add_users assp group=assp realname=ASSP\ Proxy home=${prefix}/var/assp

destroot {
	xinstall -d -m 0755 ${destroot}${prefix}/etc/rc.d
	xinstall -m 0755 -W ${worksrcpath} rc/assp.dat ${destroot}${prefix}/etc/rc.d/assp.sh

	xinstall -o assp -g assp -d -m 0755 ${destroot}${assp_base}
	xinstall -o assp -g assp -m 0640 ${filespath}/assp.cfg.in \
		${destroot}${assp_base}/assp.cfg-dist
	reinplace "s%__BASE%${assp_base}%" ${destroot}${assp_base}/assp.cfg-dist
	xinstall -o assp -g assp -m 0755 -W ${worksrcpath} rc/start.dat ${destroot}${assp_base}/start
	xinstall -o assp -g assp -m 0755 -W ${worksrcpath} rc/stop.dat ${destroot}${assp_base}/stop
	xinstall -o assp -g assp -m 0755 -W ${worksrcpath} freshclam.sh stats.sh ${destroot}${assp_base}
	xinstall -o assp -g assp -m 0755 -W ${worksrcpath} assp.pl move2num.pl rebuildspamdb.pl repair.pl stat.pl ${destroot}${assp_base}
	xinstall -o assp -g assp -m 0644 -W ${worksrcpath} notspamreport.txt spamreport.txt whitereport.txt ${destroot}${assp_base}

	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 -W ${worksrcpath} changelog.txt ${destroot}${prefix}/share/doc/${name}
	foreach file [glob -directory ${worksrcpath} *.htm] {
		xinstall -m 0644 $file ${destroot}${prefix}/share/doc/${name}
	}
}

post-activate {
	if {![file exists ${assp_base}/assp.cfg]} {
		xinstall -o assp -g assp -m 0640 ${assp_base}/assp.cfg-dist \
			${assp_base}/assp.cfg
		ui_msg "
========================================================================
After restarting your computer or manually starting ASSP:

  sudo ${prefix}/etc/rc.d/assp.sh start

Point your browser to http://127.0.0.1:55555/ -- put anything you like
in the username and use the password nospam4me to connect. If everything
is working correctly you will see a beautifully formatted configuration
screen with all of ASSP's fabulous features spelled out for you in
painful detail. Simply click the options you want, type a few
customizations if you like and you're on your way.

At a minimum you'll want to change values for 'Web Admin Password,'
'Accept All Mail,' 'Local Domains,' 'Spam Error,' and 'Spam Addresses.'
The password for your server is posted in bold on the internet for
EVERYONE to see, so if you don't change it, you deserve what you get.
Also remember to press Enter or click the button at the bottom to
register your changes - simply clearing a checkbox doesn't send the
change to ASSP.

See ${homepage} for more information.
========================================================================
"
	}
}
