# $Id: Portfile,v 1.7 2006/07/23 01:14:46 markd Exp $

PortSystem 1.0
name			dhcp
version			3.0.4
categories		net
description		ISC dhcpd server
long_description	ISC's Dynamic Host Configuration Protocol Distribution \
			reference implementation of all aspects of the DHCP \
			protocol, through a suite of DHCP tools: A DHCP \
			server, client, and relay agent.  These tools all \
			use a modular API which is designed to be sufficently \
			general that can easily be made to work on POSIX- \
			compliant operating systems and also non-POSIX \
			systems like Windows NT and MacOS.\
			The DHCP server, client and relay agent are provided \
			both as reference implementations of the protocol \
			and as working, fully-features sample implementations.\
			Both the client and the server provide functionality \
			that, while not strictly required by the protocol, \
			is very useful in practice.  The DHCP server also \
			makes allowance for non-compliant clients which \
			one might still like to support.
homepage		http://www.isc.org/products/DHCP/
platforms		darwin
maintainers		darwinports@opendarwin.org
master_sites		isc ftp://ftp.isc.org/isc/dhcp/dhcp-3.0-history/
checksums		md5 004ef935fd54b8046b16bdde31a9e151

post-patch {
	file copy -force ${filespath}/site.conf ${worksrcpath}
	reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/site.conf
}

configure.pre_args

startupitem.create	yes
startupitem.name	dhcpd
startupitem.init	"PID=/var/run/dhcpd.pid"
startupitem.start	"\[ -x ${prefix}/sbin/dhcpd \] && ${prefix}/sbin/dhcpd -cf ${prefix}/etc/dhcp/dhcpd.conf -lf ${prefix}/var/db/dhcpd/dhcpd.leases"
startupitem.stop	"\[ -r \${PID} \] && kill \$(cat \${PID})"

destroot.keepdirs	${destroot}${prefix}/var/db/dhcpd
post-destroot {
	set etc ${destroot}${prefix}/etc/dhcp
	xinstall -m 755 -d ${etc}
	xinstall -m 644 ${worksrcpath}/server/dhcpd.conf ${etc}/dhcpd.conf.sample
	xinstall -m 644 ${worksrcpath}/client/dhclient.conf \
		${etc}/dhclient.conf.sample
}

platform darwin 8 { build.args	CC=/usr/bin/gcc-4.0 }

post-activate {
                ui_msg "\n

NOTE:

-The dhcpd .conf and .leases files must be named and located as shown for dhcpd to find them:
	${prefix}/etc/dhcp/dhcpd.conf (there is a sample file)
	${prefix}/var/db/dhcpd/dhcpd.leases (use the touch command to create a blank one)

\n"
}

