2015-07-12 17:17:18 +00:00
|
|
|
class Consul < Formula
|
|
|
|
desc "Tool for service discovery, monitoring and configuration"
|
|
|
|
homepage "https://www.consul.io"
|
|
|
|
url "https://github.com/hashicorp/consul.git",
|
2016-09-24 15:45:48 +00:00
|
|
|
:tag => "v0.7.0",
|
|
|
|
:revision => "a189091a3530051285c12c726ca28ea55e015336"
|
2015-07-12 17:17:18 +00:00
|
|
|
|
2016-09-15 07:30:49 +00:00
|
|
|
head "https://github.com/hashicorp/consul.git",
|
2016-09-24 15:45:48 +00:00
|
|
|
:shallow => false
|
2016-02-04 00:51:05 +00:00
|
|
|
|
2015-07-12 21:58:03 +00:00
|
|
|
bottle do
|
2015-12-13 23:53:24 +00:00
|
|
|
cellar :any_skip_relocation
|
2016-09-17 00:57:47 +00:00
|
|
|
sha256 "616562063629987d6e21911f9d17848921988d8ed4059c5adceece56fe92f152" => :sierra
|
2016-09-15 07:39:00 +00:00
|
|
|
sha256 "f9618ae18bf2bb836585f580969232bc75bce77e76225116e52bf296153a1d4e" => :el_capitan
|
|
|
|
sha256 "1b93587de3de41ba0e037cfd083c88e4fb3cb1e088392903ff411c525fc934f0" => :yosemite
|
|
|
|
sha256 "f40b5c11b628851e265cb20327e7be674c8fca56ce282ebced5d8ec58251e4a1" => :mavericks
|
2015-07-12 21:58:03 +00:00
|
|
|
end
|
|
|
|
|
2015-09-01 17:51:42 +00:00
|
|
|
option "with-web-ui", "Installs the consul web ui"
|
|
|
|
|
2015-07-12 17:17:18 +00:00
|
|
|
depends_on "go" => :build
|
|
|
|
|
2016-10-04 15:46:33 +00:00
|
|
|
resource "web-ui" do
|
|
|
|
url "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_web_ui.zip"
|
|
|
|
sha256 "42212089c228a73a0881a5835079c8df58a4f31b5060a3b4ffd4c2497abe3aa8"
|
|
|
|
end
|
|
|
|
|
2015-07-12 17:17:18 +00:00
|
|
|
def install
|
2015-12-12 16:04:11 +00:00
|
|
|
contents = Dir["{*,.git,.gitignore}"]
|
|
|
|
gopath = buildpath/"gopath"
|
|
|
|
(gopath/"src/github.com/hashicorp/consul").install contents
|
2015-07-12 17:17:18 +00:00
|
|
|
|
2015-12-12 16:04:11 +00:00
|
|
|
ENV["GOPATH"] = gopath
|
|
|
|
ENV.prepend_create_path "PATH", gopath/"bin"
|
2015-07-12 17:17:18 +00:00
|
|
|
|
2015-12-12 16:04:11 +00:00
|
|
|
cd gopath/"src/github.com/hashicorp/consul" do
|
2015-07-12 17:17:18 +00:00
|
|
|
system "make"
|
|
|
|
bin.install "bin/consul"
|
2016-04-04 18:58:37 +00:00
|
|
|
zsh_completion.install "contrib/zsh-completion/_consul"
|
2015-07-12 17:17:18 +00:00
|
|
|
end
|
2015-09-01 17:51:42 +00:00
|
|
|
|
|
|
|
# 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
|
2015-07-12 17:17:18 +00:00
|
|
|
end
|
|
|
|
|
2016-09-24 15:45:48 +00:00
|
|
|
plist_options :manual => "consul agent -dev -advertise 127.0.0.1"
|
2016-06-15 06:22:37 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-07-12 17:17:18 +00:00
|
|
|
test do
|
|
|
|
fork do
|
2015-07-21 06:14:42 +00:00
|
|
|
exec "#{bin}/consul", "agent", "-data-dir", "."
|
2015-07-12 17:17:18 +00:00
|
|
|
end
|
|
|
|
sleep 3
|
|
|
|
system "#{bin}/consul", "leave"
|
|
|
|
end
|
|
|
|
end
|