# $Id: Portfile 62810 2010-01-18 09:04:12Z markd@macports.org $

PortSystem 1.0

name			ntop
version			3.3.10
revision		1
categories		net
maintainers		markd openmaintainer
description		network traffic probe
platforms		darwin
long_description	ntop is a network traffic probe that shows the network \
				usage, similar to what the popular top Unix command does.

homepage		http://www.ntop.org/
master_sites		sourceforge
checksums		md5 6e2ffa90d5f935c8f03d88a5dd19a866

patchfiles		patch-external-geoip.diff \
			patch-Makefile.am.diff

depends_build		port:gawk \
			port:wget \
			port:rrdtool \
			port:libevent
depends_lib		port:libpcap \
			port:gd2 \
			port:libpng \
			port:gdbm \
			port:libgeoip

configure.cflags-append	-I${prefix}/include
configure.args		--mandir=${prefix}/share/man \
			--with-localedir=${prefix}/share/locale \
			--with-rrd-home=${prefix}

use_autoconf		yes
build.type		gnu

# Create a startupitem to start/stop the server
	startupitem.create    yes
	startupitem.start    "${prefix}/share/${name}/ntop.sh"
	startupitem.stop     "${prefix}/share/${name}/ntop.sh"

pre-configure {
	system "cd ${worksrcpath} && ./autogen.sh --noconfig"
}

post-destroot	{
	xinstall -m 755 -o nobody -d ${destroot}/${prefix}/var/ntop \
		${destroot}/${prefix}/var/ntop/rrd
	system "cd ${destroot}${prefix}/var/ntop && \
		touch addressQueue.db dnsCache.db macPrefix.db \
		ntop_pw.db prefsCache.db rrd/.turd"
	system "chown -R nobody ${destroot}${prefix}/var/ntop"

	xinstall -m 755 -d ${destroot}${prefix}/etc/ntop
	xinstall -m 755 \
		${worksrcpath}/packages/FreeBSD-ports/net/ntop/files/ntop.conf.sample \
		${destroot}${prefix}/etc/ntop/ntop.conf
	reinplace "s|%%DBDIR%%/ntop|${prefix}/var/ntop|g" \
		${destroot}${prefix}/etc/ntop/ntop.conf            
	reinplace "s|#--interface sis0|--interface en0|g" \
		${destroot}${prefix}/etc/ntop/ntop.conf

	if { [variant_isset server] } {
		xinstall -m 755 ${portpath}/${filesdir}/ntop.sh \
			${destroot}${prefix}/share/ntop/ntop.sh
		reinplace "s|__PREFIX__|${prefix}|g" \
			${destroot}${prefix}/share/ntop/ntop.sh
	}
}

