# $Id: Portfile,v 1.4 2006/06/09 18:35:01 markd Exp $
PortSystem        1.0
name              nsca
version           2.6
categories        net
maintainers       markd@opendarwin.org
description       Nagios Service Check Acceptor
long_description  The NSCA addon is designed to accept passive host and service \
		  check results from clients that use the send_nsca utility \
		  (also included in this package) and pass them along to the \
		  Nagios process by using the external command interface.

homepage          http://nagios.org
master_sites      http://easynews.dl.sourceforge.net/sourceforge/nagios/
platforms         darwin
checksums         md5 d526a3ac3c29648c729c5fb4fb332488

depends_build	port:libmcrypt

patchfiles        patch-init-script.in

configure.args    --mandir=${prefix}/share/man \
                  --with-nsca-user=nagios \
                  --with-nsca-grp=nagios \
                  --libexecdir=${prefix}/libexec/nagios \
		  --bindir=${prefix}/sbin \
                  --sysconfdir=${prefix}/etc/${name}

                startupitem.create    yes
                startupitem.start    "${prefix}/share/${name}/init-script start"
                startupitem.stop    "${prefix}/share/${name}/init-script stop"

pre-destroot {
        adduser nagios
        addgroup nagios

        reinplace "s|/var/lock/subsys/nsca|${prefix}/var/run/nsca.lock|g" "${worksrcpath}/init-script.in"
}

destroot {
        xinstall -d -m 755 ${destroot}${prefix}/etc/${name}
        xinstall -d -m 755 ${destroot}${prefix}/share/${name}
        xinstall -d -m 755 ${destroot}${prefix}/sbin
        xinstall -m 755 ${worksrcpath}/src/nsca ${destroot}${prefix}/sbin/nsca
        xinstall -m 755 ${worksrcpath}/src/send_nsca ${destroot}${prefix}/sbin/send_nsca
        xinstall -m 755 ${worksrcpath}/sample-config/nsca.cfg ${destroot}${prefix}/etc/${name}/nsca.cfg.sample
        xinstall -m 755 ${worksrcpath}/sample-config/send_nsca.cfg ${destroot}${prefix}/etc/${name}/send_nsca.cfg.sample

        xinstall -m 755 ${worksrcpath}/init-script ${destroot}${prefix}/share/${name}
        xinstall -d -m 755 ${destroot}${prefix}/var/run

        xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
        xinstall -m 755 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}

}

post-destroot {
        system "chown nagios:nagios ${destroot}${prefix}/sbin/nsca"
        system "chown nagios:nagios ${destroot}${prefix}/sbin/send_nsca"
        system "chown nagios:nagios ${destroot}${prefix}/etc/${name}/*"
}

post-install {
                ui_msg "\n
README files      -->       ${prefix}/share/doc/${name}
Config file names -->       ${prefix}/etc/${name}/nsca.cfg (rename sample file to nsca.cfg)
			    ${prefix}/etc/${name}/send_nsca.cfg (rename sample file to send_nsca.cfg)
Start script      -->       ${prefix}/share/${name}/init-script start|stop|status
\n"
}

