class Teleport < Formula desc "Modern SSH server for teams managing distributed infrastructure" homepage "https://gravitational.com/teleport" url "https://github.com/gravitational/teleport/archive/v2.0.0.tar.gz" sha256 "640a66de9dd366558cb4f9725c47df46e1f109fb326a4902e739c6117f1e4700" bottle do sha256 "1dcebda84196c8df3d97375b56e101e1d98b5861e05aec52684ff68f0683f08b" => :sierra sha256 "b6d0c38a793be8afa9dd384c7523d0ef531147d71865a2927af75e95f4cdd588" => :el_capitan sha256 "f15fc0a2bddfedcdb235debc2486100639ce1070d48dc05943bf96580fe334b2" => :yosemite end depends_on "go" => :build depends_on "godep" => :build def install ENV["GOOS"] = "darwin" ENV["GOARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386" ENV["GOPATH"] = buildpath ENV["GOROOT"] = Formula["go"].opt_libexec (buildpath / "src/github.com/gravitational/teleport").install buildpath.children ln_s buildpath/"src", buildpath / "src/github.com/gravitational/teleport" cd "src/github.com/gravitational/teleport" do system "godep", "restore" ENV.deparallelize { system "make", "release" } system "/usr/bin/tar", "-xvf", "teleport-v#{version}-#{ENV["GOOS"]}-#{ENV["GOARCH"]}-bin.tar.gz" cd "teleport" do bin.install %w[teleport tctl tsh] prefix.install_metafiles end end end test do assert_match version.to_s, shell_output("#{bin}/teleport version") assert_match version.to_s, shell_output("#{bin}/tctl version") assert_match version.to_s, shell_output("#{bin}/tsh version") (testpath/"config.yml").write shell_output("#{bin}/teleport configure") .gsub("0.0.0.0", "127.0.0.1") .gsub("/var/lib/teleport", testpath) .gsub("/var/run", testpath) .gsub(/https_(.*)/, "") begin pid = spawn("#{bin}/teleport start -c #{testpath}/config.yml") sleep 5 system "/usr/bin/curl", "--insecure", "https://localhost:3080" system "/usr/bin/nc", "-z", "localhost", "3022" system "/usr/bin/nc", "-z", "localhost", "3023" system "/usr/bin/nc", "-z", "localhost", "3025" ensure Process.kill(9, pid) end end end