diff --git a/Formula/newrelic-infra-agent.rb b/Formula/newrelic-infra-agent.rb new file mode 100644 index 0000000000000..b3e840ed97b03 --- /dev/null +++ b/Formula/newrelic-infra-agent.rb @@ -0,0 +1,47 @@ +class NewrelicInfraAgent < Formula + desc "New Relic infrastructure agent" + homepage "https://github.com/newrelic/infrastructure-agent" + url "https://github.com/newrelic/infrastructure-agent/archive/refs/tags/1.20.0.tar.gz" + sha256 "0ea19d1e70b7c9204bfe5aeb7803b4c3c6b0942036f8680ae52ae76d85e2fa68" + license "Apache-2.0" + head "https://github.com/newrelic/infrastructure-agent.git" + + depends_on "go" => :build + # https://github.com/newrelic/infrastructure-agent/issues/695 + depends_on arch: :x86_64 + + def install + goarch = Hardware::CPU.arm? ? "arm64" : "amd64" + ENV["VERSION"] = version.to_s + os = "darwin" + ENV["CGO_ENABLED"] = "1" + on_linux do + os = "linux" + ENV["CGO_ENABLED"] = "0" + end + ENV["GOOS"] = os + system "make", "dist-for-os" + bin.install "dist/#{os}-newrelic-infra_#{os}_#{goarch}/newrelic-infra" + bin.install "dist/#{os}-newrelic-infra-ctl_#{os}_#{goarch}/newrelic-infra-ctl" + bin.install "dist/#{os}-newrelic-infra-service_#{os}_#{goarch}/newrelic-infra-service" + on_macos do + (var/"db/newrelic-infra").install "assets/licence/LICENSE.macos.txt" + end + end + + def post_install + (etc/"newrelic-infra").mkpath + (var/"log/newrelic-infra").mkpath + end + + service do + run [bin/"newrelic-infra-service", "-config", etc/"newrelic-infra/newrelic-infra.yml"] + log_path var/"log/newrelic-infra/newrelic-infra.log" + error_log_path var/"log/newrelic-infra/newrelic-infra.stderr.log" + end + + test do + output = shell_output("#{bin}/newrelic-infra -validate") + assert_match "config validation", output + end +end