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 KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/consul agent -dev -advertise 127.0.0.1 RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/consul.log StandardOutPath #{var}/log/consul.log EOS end test do fork do exec "#{bin}/consul", "agent", "-data-dir", "." end sleep 3 system "#{bin}/consul", "leave" end end