PortSystem 1.0
PortGroup github 1.0

github.setup        raimue molly-guard 0.4.5 macports/
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          sysutils
platforms           any
supported_archs     noarch
license             Artistic-2
maintainers         {raimue @raimue}
description         Avoid accidental shutdowns or reboots
long_description \
    This ports overrides the existing shutdown, reboot, halt commands with \
    its own version that first executes some checks before invoking the real \
    system functionality. For example, one script shipped with this port \
    checks for existing SSH sessions. If any of the three commands are called \
    interactively over an SSH session, the shell script prompts you to enter \
    the name of the host you wish to shut down. This should adequately \
    prevent you from accidental shutdowns and reboots.

checksums           rmd160  082d2f4b02ceefa51a3303ec29715b41eb7acb53 \
                    sha256  4a5af40677cb3784023a3f2e4d307aa9821d775677943c1823a6fd167f64a0c6

depends_build       port:libxslt \
                    port:docbook-xsl-nons
depends_run         port:debianutils

use_configure       no
build.args          prefix=${prefix} \
                    DB2MAN=${prefix}/share/xsl/docbook-xsl-ns/manpages/docbook.xsl
destroot.args       prefix=${prefix}
destroot.destdir    DEST=${destroot}

post-destroot {
    move ${destroot}${prefix}/etc/molly-guard/rc ${destroot}${prefix}/etc/molly-guard/rc.default
}

post-activate {
    if {![file exists ${prefix}/etc/molly-guard/rc]} {
        file copy ${prefix}/etc/molly-guard/rc.default ${prefix}/etc/molly-guard/rc
    }
}