homebrew-core/Formula/collector-sidecar.rb
2018-03-19 03:12:04 -07:00

62 lines
1.9 KiB
Ruby

class CollectorSidecar < Formula
desc "Manage log collectors through Graylog"
homepage "https://github.com/Graylog2/collector-sidecar"
url "https://github.com/Graylog2/collector-sidecar/archive/0.1.5.tar.gz"
sha256 "823794c6365f7552b4d941df54c2fc828b836c20f65237a9f463a1794f27627f"
bottle do
sha256 "7eb3e32b82e2def6b0d97307e698e4eb3cb15d75c7b3391597b9f48d98b46763" => :high_sierra
sha256 "531790ce4d0f1530cd62a8111fd84b8af6b117d869cc2c8b9f57dedb351bc17b" => :sierra
sha256 "49e5ce60007e1b18da746c22c81c9bd13120851b19fca1965a4d4167bca270fd" => :el_capitan
end
depends_on "glide" => :build
depends_on "go" => :build
depends_on "mercurial" => :build
depends_on "filebeat"
def install
ENV["GOPATH"] = buildpath
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
(buildpath/"src/github.com/Graylog2/collector-sidecar").install buildpath.children
cd "src/github.com/Graylog2/collector-sidecar" do
inreplace "main.go", "/etc", etc
inreplace "collector_sidecar.yml" do |s|
s.gsub! "/usr", HOMEBREW_PREFIX
s.gsub! "/etc", etc
s.gsub! "/var", var
end
system "glide", "install"
system "make", "build"
(etc/"graylog/collector-sidecar").install "collector_sidecar.yml"
bin.install "graylog-collector-sidecar"
prefix.install_metafiles
end
end
plist_options :manual => "graylog-collector-sidecar"
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}/graylog-collector-sidecar</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
assert_match version.to_s, shell_output("#{bin}/graylog-collector-sidecar -version")
end
end