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 | |
| 38 | destroot.keepdirs ${destroot}${prefix}/etc/${name} |
| 39 | post-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 | |
| 80 | function 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 | |
| 90 | function 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 | |
| 110 | startup |
| 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 | |
| 123 | post-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 | |
| 130 | variant startupitem description {Install launchd plist} { |
| 131 | } |
| 132 | |
| 133 | livecheck.type regex |
| 134 | livecheck.url http://sourceforge.net/projects/sshguard/files/sshguard/ |
| 135 | livecheck.regex "/sshguard-(\\d+(?:\\.\\d+)*)/" |