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.1",
|
|
:revision => "a9455cd4fc2809570ff1855c37d6ffc2449bd42f"
|
|
|
|
head "https://github.com/hashicorp/consul.git",
|
|
:shallow => false
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "79f10c6083b5bcadf6a989ae4e870bd4e73f66a89af8b1e4f35d0c646f53fe50" => :sierra
|
|
sha256 "102dadb359f912705a619cb4f02c488d8df1ec9d7fc8d9188c9b0cce1daa5bc1" => :el_capitan
|
|
sha256 "f2d3a6a1c0a9585c4f71aabe225b1c8f0b1795eef7b6cee54e6e49b175499471" => :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.1/consul_0.7.1_web_ui.zip"
|
|
sha256 "1b793c60e1af24cc470421d0411e13748f451b51d8a6ed5fcabc8d00bfb84264"
|
|
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
|