# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 55458 2009-08-11 05:27:11Z snc@macports.org $

PortSystem 1.0

name        ddclient
version     3.8.0
platforms   darwin
categories  net
#license         GPL
maintainers snc openmaintainer
description Update dynamic DNS entries
long_description    ddclient is a Perl client used to update dynamic \
            DNS entries for accounts on many dynamic DNS services.
homepage    http://ddclient.sourceforge.net/
master_sites    sourceforge:ddclient
checksums   md5     be5c08fee4a45468b8e41c3dcb79e360 \
            sha1    ff889adacf916bebb25522d9cc1eda0e9593a7f4 \
            rmd160  771ed13aa248c13af11e0466888513418bae98fb
depends_run path:bin/perl:perl5

configure   {
        reinplace "s|\[\r\]$||" ${worksrcpath}/${name}
        reinplace "s|^#!.*/perl.*$|#!${prefix}/bin/perl|" ${worksrcpath}/${name}
        reinplace "s|/etc/|${prefix}/etc/|" ${worksrcpath}/${name}
}

build   {}

pre-destroot {
        file mkdir ${destroot}${prefix}/etc/ddclient
}

destroot    {
        xinstall -m 555 ${worksrcpath}/sample-etc_ddclient.conf \
            ${destroot}${prefix}/etc/ddclient/ddclient.conf.sample

        reinplace "s|/var/run|${prefix}/var/run|" \
            ${destroot}${prefix}/etc/ddclient/ddclient.conf.sample

        xinstall -m 555 ${worksrcpath}/${name} ${destroot}${prefix}/sbin
        xinstall -d ${destroot}${prefix}/share/doc/${name}

        eval file copy [glob ${worksrcpath}/sample-*] \
            ${destroot}${prefix}/share/doc/${name}
        eval file copy [glob ${worksrcpath}/COPY*] \
            ${destroot}${prefix}/share/doc/${name}
        eval file copy [glob ${worksrcpath}/README*] \
            ${destroot}${prefix}/share/doc/${name}

        destroot.keepdirs ${destroot}${prefix}/var/run
}

startupitem.create      yes
startupitem.start       ${prefix}/sbin/ddclient
startupitem.stop        "/bin/kill \$(cat ${prefix}/var/run/ddclient.pid)"

livecheck.regex         "${name}-(\\d+\\.\\d+\\.\\d+)"
