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

name                denyhosts
categories          security sysutils
version             3.1.2
license             GPL-2
maintainers         nomaintainer
description         DenyHosts is a utility to help sys admins thwart ssh hackers
long_description    DenyHosts is a python program that automatically blocks ssh\
                    attacks by adding entries to /etc/hosts.deny. DenyHosts\
                    will also inform Linux administrators about offending\
                    hosts, attacked users and suspicious logins.

platforms           {darwin any} freebsd
supported_archs     noarch
distname            DenyHosts-${version}
homepage            https://denyhosts.sourceforge.net/
master_sites        sourceforge:project/denyhosts/denyhosts/${version}-beta

checksums           md5 0a5c219e5edb146b1130c32b2c4e58a4 \
                    sha1 98d81f3a9f8084949c530b9bb75fd7fac3ba2982 \
                    rmd160 37b5d0f150fa480dd138fb268329155cd9ad5184 \
                    sha256 cfae79a11ce27e0e8a7a9915139d4c6b68df1022e447432d589e8fbb8e1aa9e7

python.default_version  312

patchfiles          patch-denyhosts.cfg-dist.diff \
                    patch-daemon-control-dist.diff \
                    pyfiles.patch

post-patch {
    reinplace s|@PREFIX@|${prefix}| ${worksrcpath}/setup.py \
                                    ${worksrcpath}/denyhosts.conf \
                                    ${worksrcpath}/daemon-control-dist \
                                    ${worksrcpath}/denyhosts.py \
                                    ${worksrcpath}/DenyHosts/constants.py
    reinplace s|@PYTHON@|${python.bin}| ${worksrcpath}/daemon-control-dist
    reinplace s|@PYTHONPREFIX@|${python.prefix}| ${worksrcpath}/daemon-control-dist
}

pre-destroot {
    xinstall -d ${destroot}${prefix}/var/run/
    xinstall -d ${destroot}${prefix}/var/log/
}

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

post-destroot {
    move ${destroot}${python.pkgd}/etc/denyhosts.conf ${destroot}${prefix}/etc/denyhosts.conf-dist
    xinstall -d ${destroot}${prefix}/share/denyhosts
    move ${destroot}${python.prefix}/bin/daemon-control-dist ${destroot}${prefix}/share/denyhosts/
    delete ${destroot}${prefix}/bin/daemon-control-dist
}

startupitem.create  yes
startupitem.type    launchd
startupitem.pidfile clean ${prefix}/var/run/${name}.pid
startupitem.start   "${prefix}/share/denyhosts/daemon-control start"
startupitem.stop    "${prefix}/share/denyhosts/daemon-control stop"

notes "
Please read <https://github.com/denyhosts/denyhosts/blob/master/README.md>.\
You need to make config files in ${prefix}/etc/denyhosts and ${prefix}/share/denyhosts\;\
the files ending with '-dist' are examples for you to copy.
"