# -*- 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

PortSystem          1.0
PortGroup           perl5 1.0
PortGroup           github 1.0

github.setup        ddclient ddclient 3.11.2 v
github.tarball_from archive
revision            0

platforms           {darwin any}
supported_archs     noarch
categories          net
license             GPL-2+
maintainers         {snc @nerdling} 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            https://ddclient.net/

checksums           rmd160  e35d21c2def2024071324cd6c05eaadaf7b8dc18 \
                    sha256  243cd832abd3cdd2b49903e1b5ed7f450e2d9c4c0eaf8ce4fe692c244d3afd77 \
                    size    278314

perl5.major         5.34

depends_lib         port:p${perl5.major}-io-socket-ssl
depends_run         port:p${perl5.major}-data-validate-ip \
                    port:postfix \
                    path:share/curl/curl-ca-bundle.crt:curl-ca-bundle

set sendmail        ${prefix}/sbin/sendmail

variant system_sendmail \
    description {Use the system sendmail.} {
    depends_run-delete \
                    port:postfix
    set sendmail    sendmail
}

use_autoreconf      yes
test.run            yes
test.target         check

configure.args    --sysconfdir=${prefix}/etc/ddclient

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

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

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

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

post-activate {
        file mkdir ${prefix}/var/cache/${name}
}

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