# $Id: Portfile,v 1.3 2005/08/11 21:33:20 rshaw Exp $
PortSystem		1.0

name			assp
version			1.1.0
categories		mail
maintainers		darwinports@opendarwin.org
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		darwin

depends_run		bin:perl:perl5.8

pre-extract		{ file mkdir ${worksrcpath} }
extract.dir		${worksrcpath}

set assp_base	${prefix}/var/assp

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

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

build {}

pre-destroot {
	addgroup assp
	set gid [existsgroup assp]
	adduser assp gid=${gid} realname=ASSP\ Proxy home=${prefix}/var/assp
}
destroot {
	cd ${worksrcpath}

	xinstall -d -m 0755 ${destroot}${prefix}/etc/rc.d
	xinstall -m 0755 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 rc/start.dat ${destroot}${assp_base}/start
	xinstall -o assp -g assp -m 0755 rc/stop.dat ${destroot}${assp_base}/stop
	foreach file {freshclam.sh stats.sh} {
		xinstall -o assp -g assp -m 0755 $file ${destroot}${assp_base}
	}
	foreach file {assp.pl move2num.pl rebuildspamdb.pl repair.pl stat.pl} {
		xinstall -o assp -g assp -m 0755 $file ${destroot}${assp_base}
	}
	foreach file {notspamreport.txt spamreport.txt whitereport.txt} {
		xinstall -o assp -g assp -m 0644 $file ${destroot}${assp_base}
	}

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

pre-install {
	addgroup assp
	set gid [existsgroup assp]
	adduser assp gid=${gid} realname=ASSP\ Proxy home=${prefix}/var/assp
}

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.
========================================================================
"
	}
}

