# $Id: Portfile 49118 2009-04-04 05:36:45Z mcalhoun@macports.org $

PortSystem        1.0

name              snmptt
version           1.2
categories        net
maintainers       nomaintainer
description       An SNMP trap handler written in Perl for use with the Net-SNMP / UCD-SNMP snmptrapd program
long_description  ${description}

platforms         darwin
homepage          http://www.snmptt.org/
master_sites      sourceforge:snmptt
checksums         md5 5200502b7058c9e2cbe3816bf0fe27d0
distfiles	  ${name}_${version}.tgz
worksrcdir	  ${name}_${version}

depends_lib       path:bin/perl:perl5 \
		  port:p5-config-inifiles

use_configure     no
build             {}

set bindir	${prefix}/sbin
set docsdir	${prefix}/share/doc/${name}
set etcdir	${prefix}/etc/${name}
set scriptdir	${prefix}/share/${name}

post-patch {
	reinplace "s|/usr/bin/perl|${prefix}/bin/perl|g" \
		${worksrcpath}/snmptt \
		${worksrcpath}/snmptt-net-snmp-test \
		${worksrcpath}/snmpttconvert \
		${worksrcpath}/snmpttconvertmib \
		${worksrcpath}/snmptthandler

reinplace "s|/etc/snmp/snmptt.ini|${prefix}/etc/${name}/snmptt.ini|g" \
                ${worksrcpath}/snmptt \
                ${worksrcpath}/snmptthandler

reinplace "s|/etc/snmp/snmptt.conf|${prefix}/etc/snmptt.conf|g" \
		${worksrcpath}/snmptt.ini
}

destroot {
	xinstall -m 755 -d ${destroot}${bindir}
	xinstall -m 755 -d ${destroot}${docsdir}/docs
	xinstall -m 755 -d ${destroot}${scriptdir}
	xinstall -m 755 -d ${destroot}${etcdir}

	xinstall -m 755 -W ${worksrcpath} snmptt snmptt-net-snmp-test snmpttconvert \
			snmpttconvertmib snmptthandler \
				${destroot}${bindir}

	xinstall -m 755 -W ${worksrcpath}/docs faqs.html index.html layout1.css \
			snmptt.html snmpttconvert.html snmpttconvertmib.html \
				${destroot}${docsdir}/docs

	xinstall -m 755 -W ${worksrcpath} ChangeLog INSTALL README \
				${destroot}${docsdir}

	eval xinstall -m 644 [glob ${worksrcpath}/sample-*] \
				${destroot}${docsdir}
	eval xinstall -m 644 [glob ${worksrcpath}/examples/*-trap.*] \
				${destroot}${docsdir}

	xinstall -m 644 ${worksrcpath}/snmptt.ini ${destroot}${etcdir}/snmptt.ini.sample
	xinstall -m 644 ${worksrcpath}/examples/snmptt.conf.generic ${destroot}${etcdir}
	xinstall -m 755 ${worksrcpath}/snmptt-init.d ${destroot}${docsdir}
}

post-activate {
ui_msg "\n

snmptt setup:

-Rename the ${prefix}/etc/${name}/snmptt.ini.sample file to remove the trailing
\"sample\" so snmptt will be able to find its configuration, and customize the
 file as necessary.

-Use snmpttconvertmib to build an ${prefix}/etc/snmptt.conf file with translations from
 MIB files for your devices as described in the documentation.


snmptrapd setup:

-Edit your snmptrapd.conf (you may use the snmpconf utility) and make sure that
 these items are present.

	traphandle  default ${prefix}/bin/perl ${prefix}/sbin/snmptt

\n"
}

