Ticket #31805: patch-Portfile-sshguard-ipfw.diff

File patch-Portfile-sshguard-ipfw.diff, 4.6 KB (added by pixilla (Bradley Giesbrecht), 13 years ago)
  • opt/local/var/macports/sources/svn.macports.org/trunk/dports/net/sshguard-ipfw/Portfile

     
     1# -*- 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
    12# $Id$
    23
    34PortSystem 1.0
     
    23name                sshguard-ipfw
    3 version             1.4
     4version             1.5
    45categories          net security
     
    2728                    resources to the system.
    2829
    2930distname            sshguard-${version}
    30 homepage            http://sshguard.sourceforge.net
     31homepage            http://www.sshguard.net/
    3132master_sites        sourceforge:sshguard
    32 checksums           md5     76ec42919089c51a64df1cd5caa27e08 \
    33                     sha1    afd1134199ba41721b3d4032239529040e5dd367 \
    34                     rmd160  1a34d29d8849ea279049a8eb24ddef839dafdbf7
     33checksums           sha1    f8f713bfb3f5c9877b34f6821426a22a7eec8df3 \
     34                    rmd160  7b4625b3b2e0cf974bc935d868b89bd0d8c189e8
    3535use_bzip2           yes
    3636configure.args      --with-ipfw=/sbin/ipfw --with-firewall=ipfw
    37 startupitem.create  yes
    38 startupitem.start "tail -n0 -F /var/log/secure.log | ${prefix}/sbin/sshguard 2>&1 > /dev/null &"
    39 startupitem.stop "ps wuax | grep '\[s\]shguard$' | kill `awk '{ print \$2}'`"
     37
     38destroot.keepdirs   ${destroot}${prefix}/etc/${name}
     39post-destroot {
     40    xinstall -d ${destroot}${prefix}/share/${name}
     41    xinstall -d ${destroot}${prefix}/etc/${name}
     42    set fp [open ${destroot}${prefix}/share/${name}/options.example w]
     43    puts $fp \
     44"-l /var/log/system.log -l /var/log/secure.log
     45"
     46    close $fp
     47
     48    set fp [open ${destroot}${prefix}/share/${name}/org.macports.${name}.plist.example w]
     49    puts $fp \
     50"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
     51<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
     52<plist version=\"1.0\">
     53<dict>
     54        <key>Disabled</key>
     55        <true/>
     56        <key>Label</key>
     57        <string>org.macports.${name}</string>
     58        <key>OnDemand</key>
     59        <false/>
     60        <key>ProgramArguments</key>
     61        <array>
     62                <string>${prefix}/sbin/sshguard-start</string>
     63        </array>
     64</dict>
     65</plist>"
     66    close $fp
     67    set fp [open ${destroot}${prefix}/sbin/sshguard-start w]
     68    puts $fp \
     69"#! /bin/sh
     70
     71# sshguard-launchd.sh
     72#
     73# Wrapper script that starts sshguard and waits for the sshguard process
     74# to exit. This is needed for proper interaction with launchd.
     75
     76#---------------------------------------------------------
     77# Helper functions
     78#---------------------------------------------------------
     79
     80function shutdown() {
     81   
     82    # Bye sshguard!
     83    echo \"Shutting down sshguard... \"
     84    kill -s TERM \$(ps auxww | grep -v wrapper | awk '/sshguard/ && !/awk/ {print \$2}')
     85    echo \"done.\"
     86   
     87}
     88
     89
     90function startup() {
     91   
     92    # Get startup
     93    OPTIONS=\$(cat ${prefix}/etc/${name}/options | tr -d '\\n')
     94    # Let's go!
     95    echo \"Starting up sshguard... \"
     96    ${prefix}/sbin/sshguard \${OPTIONS}
     97   
     98    # Register the shutdown function as callback to execute when a signal
     99    # is sent to this process.
     100    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
     101    echo \"done.\"
     102   
     103}
     104
     105
     106#---------------------------------------------------------
     107# Let's go
     108#---------------------------------------------------------
     109
     110startup
     111# wait_for_sshguard_to_exit"
     112    close $fp
     113    file attributes ${destroot}${prefix}/sbin/sshguard-start -permissions "+x"
     114    if {[variant_isset startupitem]} {
     115        xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}
     116        xinstall -d ${destroot}/Library/LaunchDaemons
     117        xinstall -m 644 ${destroot}${prefix}/share/${name}/org.macports.${name}.plist.example \
     118            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}/org.macports.${name}.plist
     119        ln -sf "${prefix}/etc/LaunchDaemons/org.macports.${name}/org.macports.${name}.plist" "${destroot}/Library/LaunchDaemons/org.macports.${name}.plist"
     120    }
     121}
     122
     123post-activate {
     124    if {![file exists ${prefix}/etc/${name}/options]} {
     125        xinstall -m 644 ${destroot}${prefix}/share/${name}/options.example \
     126            ${prefix}/etc/${name}/options
     127    }
     128}
     129
     130variant startupitem description {Install launchd plist} {
     131}
     132
     133livecheck.type      regex
     134livecheck.url       http://sourceforge.net/projects/sshguard/files/sshguard/
     135livecheck.regex     "/sshguard-(\\d+(?:\\.\\d+)*)/"