# $Id: Portfile,v 1.17 2005/08/11 21:33:24 rshaw Exp $
PortSystem		1.0

name			radmind
version			1.5.0
categories		net sysutils
maintainers		darwinports@opendarwin.org
description		Remotely administer the file systems of multiple unix machines
long_description	A suite of Unix command-line tools and a server \
					designed to remotely administer the file systems of \
					multiple Unix machines. At its core, radmind \
					operates as a tripwire. It is able to detect changes \
					to any managed filesystem object, e.g. files, \
					directories, links, etc.  However, radmind goes \
					further than just integrity checking: once a change \
					is detected, radmind can optionally reverse the \
					change.
platforms		darwin
homepage		http://rsug.itd.umich.edu/software/radmind
master_sites	${homepage}/files/
checksums		md5 c636f5c27cec2aeb4d0031a14d91aff5
extract.suffix	.tgz

depends_lib		lib:libssl.0.9:openssl

patchfiles		patch-Makefile.in

configure.args	--mandir='\${prefix}/share/man' \
				--with-radminddir='\${prefix}/var/radmind'

destroot.keepdirs	${destroot}${prefix}/var/radmind/cert \
					${destroot}${prefix}/var/radmind/client \
					${destroot}${prefix}/var/radmind/command \
					${destroot}${prefix}/var/radmind/file \
					${destroot}${prefix}/var/radmind/preapply \
					${destroot}${prefix}/var/radmind/postapply \
					${destroot}${prefix}/var/radmind/special \
					${destroot}${prefix}/var/radmind/tmp/file \
					${destroot}${prefix}/var/radmind/tmp/transcript \
					${destroot}${prefix}/var/radmind/transcript
post-destroot {
	cd ${worksrcpath}
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 COPYRIGHT README SPEC \
		${destroot}${prefix}/share/doc/${name}

	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/cert
	xinstall -d -m 0755 ${destroot}${prefix}/var/radmind/client
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/command
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/file
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/preapply
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/postapply
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/special
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/tmp
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/tmp/file
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/tmp/transcript
	xinstall -d -m 0750 ${destroot}${prefix}/var/radmind/transcript

	cd ${destroot}${prefix}/var/radmind/cert
	system "echo 'Place ca.pem & cert.pem files in this directory.' >README"
	cd ${destroot}${prefix}/var/radmind/client
	system "echo 'Place command files in this directory.' >README"

	# radmind start/stop rc script (if non-Darwin)
	if {![variant_isset darwin]} {
		xinstall -d -m 0755 ${destroot}${prefix}/etc/rc.d
		xinstall -m 0755 ${filespath}/radmind.sh.in \
			${destroot}${prefix}/etc/rc.d/radmind.sh
		reinplace "s%__PREFIX%${prefix}%" \
			${destroot}${prefix}/etc/rc.d/radmind.sh
	}
}

platform darwin {
	startupitem.create			yes
	startupitem.name			Radmind
	startupitem.requires		Resolver Disks
	startupitem.start			"if \[ -f ${prefix}/var/radmind/config \]; then"
	startupitem.start-append	"\tCheckForNetwork"
	startupitem.start-append	"\t\[ \"\${NETWORKUP}\" = \"-YES-\" \] && \\"
	startupitem.start-append	"\t\t${prefix}/sbin/radmind -R -u 077"
	startupitem.start-append	"fi"
	startupitem.stop			"/usr/bin/killall radmind"
}

