# $Id: Portfile,v 1.32 2006/06/27 07:00:50 markd Exp $

PortSystem 1.0
name             snort
version          2.4.5
revision	 1
categories       net
maintainers      toby@opendarwin.org
description      Open Source Network Intrusion Detection System
long_description \
    Snort is an open source network intrusion detection system, capable \
    of performing real-time traffic analysis and packet logging on IP \
    networks. It can perform protocol analysis, content \
    searching/matching and can be used to detect a variety of attacks \
    and probes, such as buffer overflows, stealth port scans, CGI \
    attacks, SMB probes, OS fingerprinting attempts, and much more.
homepage         http://www.snort.org/
platforms        darwin freebsd
master_sites     ${homepage}dl/current/ \
		 ${homepage}dl/old/
checksums        sha1 3ba7dae8058aecf4e4eb1c7a816a7c8a4fb7c550
depends_lib      lib:libpcre:pcre
configure.args   --mandir=${prefix}/share/man

variant mysql5 {
	depends_lib-append    port:mysql5
	configure.args-append --with-mysql=${prefix}
	patchfiles-append	patch-configure
}

variant mysql4 {
	depends_lib-append    port:mysql4
	configure.args-append --with-mysql=${prefix}
}

variant server {
    startupitem.create    yes
    startupitem.start "${prefix}/share/${name}/snort.sh"
    startupitem.stop  "/bin/kill \$(cat /var/run/snort_*.pid)"
}

post-destroot {
# Copy the Snort database schemas and sample snort.conf
	xinstall -d -m 755 ${destroot}${prefix}/share/${name}/schemas
	eval xinstall -m 755 [glob ${worksrcpath}/schemas/create*] ${destroot}${prefix}/share/${name}/schemas
	xinstall -d -m 755 ${destroot}${prefix}/etc/${name}
	xinstall -m 755 ${worksrcpath}/etc/snort.conf ${destroot}${prefix}/etc/${name}/snort.conf.sample

# Copy other useful files
	xinstall -d -m 755 ${destroot}${prefix}/etc/${name}
	eval xinstall [glob ${worksrcpath}/etc/*.map] ${destroot}${prefix}/etc/${name}
	eval xinstall [glob ${worksrcpath}/etc/*.conf*] ${destroot}${prefix}/etc/${name}

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

post-activate {
	ui_msg "\n

                ***** File locations *****

	The Snort database schemas -> ${prefix}/share/${name}/schemas
	The snort.conf sample file -> ${prefix}/etc/${name}/snort.conf.sample (rename to snort.conf)

NOTE:	If you installed Snort using the +server variant, make sure you do not
	change the location of the snort.conf file or the startup scripts
	will not be able to find it.
\n"

}

