# $Id: Portfile,v 1.7 2006/07/01 22:11:48 markd Exp $
PortSystem        1.0
name              nrpe
version           2.5.2
categories        net
maintainers       markd@opendarwin.org
description       Nagios Remote Plugin Executor
long_description  Allows "local" Nagios plugins to run on remote hosts and \
		  report back to a Nagios server.

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

patchfiles	  patch-init-script.in

configure.args    --mandir=${prefix}/share/man \
		  --with-nrpe-user=nagios \
                  --with-nrpe-group=nagios \
		  --libexecdir=${prefix}/libexec/nagios \
		  --bindir=${prefix}/sbin \
		  --sysconfdir=${prefix}/etc/${name} \
                  --with-kerberos-inc=/usr/include/kerberosIV \
                  --enable-ssl \
		  --with-ssl-lib=${prefix} \
                  --with-ssl-inc=${prefix} \
		  --enable-command-args

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

post-patch {
        adduser nagios
        addgroup nagios

        reinplace "s|__PREFIX__|${prefix}|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}/libexec/nagios
        xinstall -m 755 ${worksrcpath}/src/nrpe ${destroot}${prefix}/sbin/nrpe
        xinstall -m 755 ${worksrcpath}/src/check_nrpe ${destroot}${prefix}/libexec/nagios
	xinstall -m 755 ${worksrcpath}/sample-config/nrpe.cfg ${destroot}${prefix}/etc/${name}/nrpe.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}
        xinstall -m 755 ${worksrcpath}/README.SSL ${destroot}${prefix}/share/doc/${name}

}

post-destroot {
	system "chown nagios:nagios ${destroot}${prefix}/sbin/nrpe"
	system "chown nagios:nagios ${destroot}${prefix}/libexec/nagios/check_nrpe"
	system "chown nagios:nagios ${destroot}${prefix}/etc/${name}/nrpe.cfg.sample"
}

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

