# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 91705 2012-04-08 12:18:35Z cal@macports.org $

PortSystem          1.0

name                dhcp
version             4.1-ESV-R4
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 Mac OS.\ 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         nomaintainer
master_sites        http://ftp.isc.org/isc/dhcp/${version}/

checksums           sha256  13b3c08695f0a663fe1e1b6af5ce8a4e052b3f4a291e404b463f5d2762e6000d \
                    rmd160  792eab5695ae0803dfaa57d74072dd990e361c31

patchfiles          RFC3542.include.patch

depends_lib         port:openssl

startupitem.create  yes
startupitem.name    dhcpd
startupitem.executable \
                    ${prefix}/sbin/dhcpd -f -cf ${prefix}/etc/dhcp/dhcpd.conf -lf ${prefix}/var/db/dhcpd/dhcpd.leases
startupitem.netchange \
                    yes

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
    file delete ${destroot}${prefix}/etc/dhcpd.conf
    file delete ${destroot}${prefix}/etc/dhclient.conf
}

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