# $Id: Portfile 82553 2011-08-15 19:22:39Z jmr@macports.org $
PortSystem      1.0

name                    xserve-raid-tools
version                 1.2
revision                1
categories              sysutils net
maintainers             markd

description             The xserve-raid-tools package provides command line tools and \
			a daemon for monitoring Apple Xserve RAIDs.  It also contains a \
			Nagios plugin to monitor Apple Xserve RAIDs.

long_description        ${description}

homepage                http://noc.hep.wisc.edu/xserve-raid-tools.txt
platforms               darwin
master_sites            ftp://noc.hep.wisc.edu/pub/src/xserve-raid-tools/
checksums               md5 fe7d8400a6c85e73cfc5af1f6869a92d

depends_lib		port:p5.12-xml-parser \
			port:netcat

variant nagios_plugin {
        depends_build-append    port:nagios-plugins
}                                         

variant server {
        startupitem.create      yes
        startupitem.name        xserve-raid-checkd
        startupitem.start       "${prefix}/bin/xserve-raid-checkd"
        startupitem.stop        "exec ${prefix}/bin/xserve-raid-checkd -k kill"
}

set nagios_plugin_dir ${prefix}/libexec/nagios

post-patch {
	reinplace "s|\$(PREFIX)|\$(DESTDIR)\$(PREFIX)|g" \
		${worksrcpath}/Makefile.in
}

build {}

post-destroot {
if { [variant_isset nagios_plugin] } {   
        xinstall -m 755 -d ${destroot}${nagios_plugin_dir}
	xinstall -m 755 ${worksrcpath}/check_xserve_raid ${destroot}${nagios_plugin_dir}
}
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/xserve-raid-tools
	foreach docfile {CHANGES LICENSE NOTES README TODO} {
		xinstall ${worksrcpath}/${docfile} ${destroot}${prefix}/share/doc/xserve-raid-tools/
	}
}

post-activate {
ui_msg "\n Make sure to edit the ${prefix}/etc/xserve-raid-tools.conf file. \n"
}
