Index: /opt/local/var/macports/sources/svn.macports.org/trunk/dports/net/sshguard-ipfw/Portfile
===================================================================
--- /opt/local/var/macports/sources/svn.macports.org/trunk/dports/net/sshguard-ipfw/Portfile	(revision 86188)
+++ /opt/local/var/macports/sources/svn.macports.org/trunk/dports/net/sshguard-ipfw/Portfile	(working copy)
@@ -1,3 +1,4 @@
+# -*- 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$
 
 PortSystem 1.0
@@ -2,3 +3,3 @@
 name                sshguard-ipfw
-version             1.4
+version             1.5
 categories          net security
@@ -27,13 +28,108 @@
                     resources to the system.
 
 distname            sshguard-${version}
-homepage            http://sshguard.sourceforge.net
+homepage            http://www.sshguard.net/
 master_sites        sourceforge:sshguard
-checksums           md5     76ec42919089c51a64df1cd5caa27e08 \
-                    sha1    afd1134199ba41721b3d4032239529040e5dd367 \
-                    rmd160  1a34d29d8849ea279049a8eb24ddef839dafdbf7
+checksums           sha1    f8f713bfb3f5c9877b34f6821426a22a7eec8df3 \
+                    rmd160  7b4625b3b2e0cf974bc935d868b89bd0d8c189e8
 use_bzip2           yes
 configure.args      --with-ipfw=/sbin/ipfw --with-firewall=ipfw
-startupitem.create  yes
-startupitem.start "tail -n0 -F /var/log/secure.log | ${prefix}/sbin/sshguard 2>&1 > /dev/null &"
-startupitem.stop "ps wuax | grep '\[s\]shguard$' | kill `awk '{ print \$2}'`"
+
+destroot.keepdirs   ${destroot}${prefix}/etc/${name}
+post-destroot {
+    xinstall -d ${destroot}${prefix}/share/${name}
+    xinstall -d ${destroot}${prefix}/etc/${name}
+    set fp [open ${destroot}${prefix}/share/${name}/options.example w]
+    puts $fp \
+"-l /var/log/system.log -l /var/log/secure.log
+"
+    close $fp
+
+    set fp [open ${destroot}${prefix}/share/${name}/org.macports.${name}.plist.example w]
+    puts $fp \
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+	<key>Disabled</key>
+	<true/>
+	<key>Label</key>
+	<string>org.macports.${name}</string>
+	<key>OnDemand</key>
+	<false/>
+	<key>ProgramArguments</key>
+	<array>
+		<string>${prefix}/sbin/sshguard-start</string>
+	</array>
+</dict>
+</plist>"
+    close $fp
+    set fp [open ${destroot}${prefix}/sbin/sshguard-start w]
+    puts $fp \
+"#! /bin/sh
+
+# sshguard-launchd.sh
+# 
+# Wrapper script that starts sshguard and waits for the sshguard process 
+# to exit. This is needed for proper interaction with launchd.
+
+#---------------------------------------------------------
+# Helper functions
+#---------------------------------------------------------
+
+function shutdown() {
+    
+    # Bye sshguard!
+    echo \"Shutting down sshguard... \"
+    kill -s TERM \$(ps auxww | grep -v wrapper | awk '/sshguard/ && !/awk/ {print \$2}')
+    echo \"done.\"
+    
+}
+
+
+function startup() {
+    
+    # Get startup 
+    OPTIONS=\$(cat ${prefix}/etc/${name}/options | tr -d '\\n')
+    # Let's go!
+    echo \"Starting up sshguard... \"
+    ${prefix}/sbin/sshguard \${OPTIONS}
+    
+    # Register the shutdown function as callback to execute when a signal 
+    # is sent to this process.
+    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
+    echo \"done.\"
+    
+}
+
+
+#---------------------------------------------------------
+# Let's go
+#---------------------------------------------------------
+
+startup
+# wait_for_sshguard_to_exit"
+    close $fp
+    file attributes ${destroot}${prefix}/sbin/sshguard-start -permissions "+x"
+    if {[variant_isset startupitem]} {
+        xinstall -d ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}
+        xinstall -d ${destroot}/Library/LaunchDaemons
+        xinstall -m 644 ${destroot}${prefix}/share/${name}/org.macports.${name}.plist.example \
+            ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${name}/org.macports.${name}.plist
+        ln -sf "${prefix}/etc/LaunchDaemons/org.macports.${name}/org.macports.${name}.plist" "${destroot}/Library/LaunchDaemons/org.macports.${name}.plist"
+    }
+}
+
+post-activate {
+    if {![file exists ${prefix}/etc/${name}/options]} {
+        xinstall -m 644 ${destroot}${prefix}/share/${name}/options.example \
+            ${prefix}/etc/${name}/options
+    }
+}
+
+variant startupitem description {Install launchd plist} {
+}
+
+livecheck.type      regex
+livecheck.url       http://sourceforge.net/projects/sshguard/files/sshguard/
+livecheck.regex     "/sshguard-(\\d+(?:\\.\\d+)*)/"
