93 lines
2.7 KiB
Ruby
93 lines
2.7 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 => "v0.7.4",
|
|
:revision => "1c442cb5704841704c1ba88daf1156245d0b311e"
|
|
|
|
head "https://github.com/hashicorp/consul.git",
|
|
:shallow => false
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "fdc85bfa116f1cd50fae6acbd5791600eb6cd7482ff555cd4d9ca9d21a37760c" => :sierra
|
|
sha256 "d184621b553335440eef5c5b3b1fdb42b326c0e06c8c4f782a6fadcdc0fc0936" => :el_capitan
|
|
sha256 "f361cdb14e178c431e93cdbd073cdafe586559e338c56e1ba0b6993f71cf4942" => :yosemite
|
|
end
|
|
|
|
option "with-web-ui", "Installs the consul web ui"
|
|
|
|
depends_on "go" => :build
|
|
|
|
resource "web-ui" do
|
|
url "https://releases.hashicorp.com/consul/0.7.4/consul_0.7.4_web_ui.zip"
|
|
sha256 "3d2ef4035b53dc448c8b2db7835e96d3d0365a2577f5a0b316c8dfc726f34a64"
|
|
end
|
|
|
|
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"
|
|
zsh_completion.install "contrib/zsh-completion/_consul"
|
|
end
|
|
|
|
# install web-ui to package share folder.
|
|
(pkgshare/"web-ui").install resource("web-ui") if build.with? "web-ui"
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
If consul was built with --with-web-ui, you can activate the UI by running
|
|
consul with `-ui-dir #{pkgshare}/web-ui`.
|
|
EOS
|
|
end
|
|
|
|
plist_options :manual => "consul agent -dev -advertise 127.0.0.1"
|
|
|
|
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>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
|