<commit_before>require 'formula'

class Fail2ban < Formula
  homepage 'http://www.fail2ban.org/'
  url 'http://cloud.github.com/downloads/fail2ban/fail2ban/fail2ban_0.8.7.1.orig.tar.gz'
  sha1 'ec1a7ea1360056d5095bb9de733c1e388bd22373'

  def install
    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-server', '/etc', etc
    inreplace 'fail2ban-regex', '/etc', etc

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

    system "python", "setup.py", "install",
                     "--prefix=#{prefix}",
                     "--install-lib=#{libexec}",
                     "--install-data=#{libexec}",
                     "--install-scripts=#{bin}"
  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_prefix}/bin/fail2ban-client</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<commit_msg>fail2ban: force stale socket cleanup for successful launch<commit_after>require 'formula'

class Fail2ban < Formula
  homepage 'http://www.fail2ban.org/'
  url 'http://cloud.github.com/downloads/fail2ban/fail2ban/fail2ban_0.8.7.1.orig.tar.gz'
  sha1 'ec1a7ea1360056d5095bb9de733c1e388bd22373'

  def install
    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-server', '/etc', etc
    inreplace 'fail2ban-regex', '/etc', etc

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

    system "python", "setup.py", "install",
                     "--prefix=#{prefix}",
                     "--install-lib=#{libexec}",
                     "--install-data=#{libexec}",
                     "--install-scripts=#{bin}"
  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_prefix}/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
{'fraction_non_alphanumeric': 0.14996232102486812, 'fraction_numerical': 0.0293896006028636, 'mean_word_length': 2.4239036973344796, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 2, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4091763', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1309, 'n_words': 305}