78 lines
2.3 KiB
Ruby
78 lines
2.3 KiB
Ruby
class Consul < Formula
|
|
desc "Tool for service discovery, monitoring and configuration"
|
|
homepage "https://www.consul.io"
|
|
url "https://github.com/hashicorp/consul.git",
|
|
:tag => "v1.0.2",
|
|
:revision => "b55059fc3d0327c92c41431e57dfd2df3f956b03"
|
|
|
|
head "https://github.com/hashicorp/consul.git",
|
|
:shallow => false
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "23804c075d9eb365599d6450a4bb59bcfb03a703fae8c03cbb2c2196156474e2" => :high_sierra
|
|
sha256 "056833510109f7fc3e358140af35f38daf0ee44f56c85bfe11e0eaa76939e9e4" => :sierra
|
|
sha256 "e9c460ab90b7e523978af4bc14b059a24b8406116538ed60c10a616c4c18dee2" => :el_capitan
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
contents = Dir["{*,.git,.gitignore}"]
|
|
gopath = buildpath/"gopath"
|
|
(gopath/"src/github.com/hashicorp/consul").install contents
|
|
|
|
ENV["GOPATH"] = gopath
|
|
ENV.prepend_create_path "PATH", gopath/"bin"
|
|
|
|
cd gopath/"src/github.com/hashicorp/consul" do
|
|
system "make"
|
|
bin.install "bin/consul"
|
|
prefix.install_metafiles
|
|
zsh_completion.install "contrib/zsh-completion/_consul"
|
|
end
|
|
end
|
|
|
|
plist_options :manual => "consul agent -dev -advertise 127.0.0.1"
|
|
|
|
def plist; <<~EOS
|
|
<?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>KeepAlive</key>
|
|
<dict>
|
|
<key>SuccessfulExit</key>
|
|
<false/>
|
|
</dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/consul</string>
|
|
<string>agent</string>
|
|
<string>-dev</string>
|
|
<string>-advertise</string>
|
|
<string>127.0.0.1</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/consul.log</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/consul.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
fork do
|
|
exec "#{bin}/consul", "agent", "-data-dir", "."
|
|
end
|
|
sleep 3
|
|
system "#{bin}/consul", "leave"
|
|
end
|
|
end
|