PortSystem        1.0

name              nsca
version           2.7.2
categories        net
maintainers       nomaintainer
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      sourceforge:nagios
platforms         darwin
checksums         md5 33a98e7975f633a9489d7a8938ed6131

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