homebrew-core/Formula/packetbeat.rb
2017-12-14 22:39:48 +01:00

83 lines
2.6 KiB
Ruby

class Packetbeat < Formula
desc "Lightweight Shipper for Network Data"
homepage "https://www.elastic.co/products/beats/packetbeat"
url "https://github.com/elastic/beats/archive/v6.1.0.tar.gz"
sha256 "1dc37aa296a96d3ced69d0b31815e08a1985aaf2f02113889465502bb02478ac"
head "https://github.com/elastic/beats.git"
bottle do
cellar :any_skip_relocation
sha256 "4820141ee9c806054fc0ec05cc075f9ac737883a74c12d338111d2f2bdb8b382" => :high_sierra
sha256 "16f4580bf2e48ef38442200a1757df673a9086cbbc6db56457cb02993b8a47a3" => :sierra
sha256 "6108dcf3cd82d3bbc8360426ce87a7ad2615e2d6347d072bb3edc64ec94d20e4" => :el_capitan
end
depends_on "go" => :build
resource "virtualenv" do
url "https://files.pythonhosted.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz"
sha256 "02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a"
end
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/elastic/beats").install buildpath.children
ENV.prepend_create_path "PYTHONPATH", buildpath/"vendor/lib/python2.7/site-packages"
resource("virtualenv").stage do
system "python", *Language::Python.setup_install_args(buildpath/"vendor")
end
ENV.prepend_path "PATH", buildpath/"vendor/bin"
cd "src/github.com/elastic/beats/packetbeat" do
# prevent downloading binary wheels
inreplace "../libbeat/scripts/Makefile", "pip install", "pip install --no-binary :all"
system "make"
system "make", "update"
(libexec/"bin").install "packetbeat"
libexec.install "_meta/kibana"
inreplace "packetbeat.yml", "packetbeat.interfaces.device: any", "packetbeat.interfaces.device: en0"
(etc/"packetbeat").install Dir["packetbeat*.yml"]
(etc/"packetbeat").install "fields.yml"
prefix.install_metafiles
end
(bin/"packetbeat").write <<~EOS
#!/bin/sh
exec #{libexec}/bin/packetbeat \
-path.config #{etc}/packetbeat \
-path.home #{prefix} \
-path.logs #{var}/logs/packetbeat \
-path.data #{var}/lib/packetbeat \
"$@"
EOS
end
plist_options :manual => "packetbeat"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>Program</key>
<string>#{opt_bin}/packetbeat</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
system "#{bin}/packetbeat", "devices"
end
end