aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/fail2ban.rb
blob: 826619583e0d5d0a3bfa4dc0ee4da7c638e23e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require "formula"

class Fail2ban < Formula
  homepage "http://www.fail2ban.org/"
  url "https://github.com/fail2ban/fail2ban/archive/0.8.14.tar.gz"
  sha1 "fb104335acf9d71552a4a1cec06fac1187846867"

  bottle do
    sha1 "ab90e39f9669b929dd4ec43b9f736a1ab1cac652" => :mavericks
    sha1 "3b2c563f7316ed9c485744e24ec6abc3bb242040" => :mountain_lion
    sha1 "0c91986b55c0d35497ef0d4c42d992c9958c577e" => :lion
  end

  def install
    rm "setup.cfg"
    inreplace "setup.py" do |s|
      s.gsub! /\/etc/, etc
      s.gsub! /\/var/, var
    end

    # Replace hardcoded paths
    inreplace "fail2ban-client", "/usr/share/fail2ban", libexec
    inreplace "fail2ban-server", "/usr/share/fail2ban", libexec
    inreplace "fail2ban-regex", "/usr/share/fail2ban", libexec

    inreplace "fail2ban-client", "/etc", etc
    inreplace "fail2ban-regex", "/etc", etc

    inreplace "fail2ban-server", "/var", var
    inreplace "config/fail2ban.conf", "/var/run", (var/"run")

    inreplace "setup.py", "/usr/share/doc/fail2ban", (libexec/"doc")

    system "python", "setup.py", "install", "--prefix=#{prefix}", "--install-lib=#{libexec}"
  end

  plist_options :startup => true

  def plist; <<-EOS.undent
      <?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>Label</key>
        <string>#{plist_name}</string>
        <key>ProgramArguments</key>
        <array>
          <string>#{opt_bin}/fail2ban-client</string>
          <string>-x</string>
          <string>start</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
      </dict>
      </plist>
    EOS
  end

  def caveats
    <<-EOS.undent
      Before using Fail2Ban for the first time you should edit jail
      configuration and enable the jails that you want to use, for instance
      ssh-ipfw. Also make sure that they point to the correct configuration
      path. I.e. on Mountain Lion the sshd logfile should point to
      /var/log/system.log.

        * #{etc}/fail2ban/jail.conf

      The Fail2Ban wiki has two pages with instructions for MacOS X Server that
      describes how to set up the Jails for the standard MacOS X Server
      services for the respective releases.

        10.4: http://www.fail2ban.org/wiki/index.php/HOWTO_Mac_OS_X_Server_(10.4)
        10.5: http://www.fail2ban.org/wiki/index.php/HOWTO_Mac_OS_X_Server_(10.5)
    EOS
  end
end