# $Id: Portfile,v 1.1 2005/11/04 06:14:09 mww Exp $

PortSystem 1.0

name			icmpmonitor
version			1.2
categories		net
platforms		darwin
maintainers		mww@opendarwin.org
description		simple network monitor using icmp to check for hosts
long_description	Using the InterNet Control Message Protocol (ICMP) "ECHO" \
			facility, monitors several hosts, and notify admin if some of them \
			are down.

homepage		http://icmpmonitor.sourceforge.net/
master_sites	sourceforge
checksums		md5 c6c9bfc14f914604232945185be387b3
patchfiles		patch-icmpmonitor.c

post-patch {
	reinplace "s|__ETCDIR__|${prefix}/etc|g" ${worksrcpath}/icmpmonitor.c
}

configure.args	--mandir=\\\${prefix}/share/man

destroot.destdir	prefix=${destroot}${prefix}
post-destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name} \
		${destroot}${prefix}/var/run/
	xinstall -m 644 ${worksrcpath}/sample.cfg \
		${destroot}${prefix}/etc/icmpmonitor.cfg.sample
	xinstall -m 644 -W ${worksrcpath} ChangeLog NEWS README TODO \
		${destroot}${prefix}/share/doc/${name}
	system "touch ${destroot}${prefix}/var/run/icmpmonitor.pid"
}

startupitem.create	yes
startupitem.init	\
	"PID=${prefix}/var/run/${name}.pid\nBIN=${prefix}/sbin/icmpmonitor"
startupitem.start	"\[ -x \${BIN} \] && \${BIN} &; echo \$! > \${PID}"
startupitem.stop	"\[ -r \${PID} \] && /bin/kill \$(cat \${PID})"
