homebrew-core/Formula/teleport.rb
2017-04-12 05:09:47 -07:00

54 lines
2 KiB
Ruby

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.1.tar.gz"
sha256 "d154e1822b8671ac8035f0a91769e95ed85a338228d9e27c2291dec77df5b7fe"
bottle do
sha256 "dcfe9e35cf36b52c8dadf88ffe0baa7fe23956fa4948d9762b68b1ad3485660e" => :sierra
sha256 "a5e9e2e489f544bccd42d8c34ff2de8a247a6adafe347dcd3659a6f15029cea4" => :el_capitan
sha256 "fae6211b5b69f8b15709619dca2e0f9e1c1fb53228b77f0b9344d71cab8f1f38" => :yosemite
end
depends_on "go" => :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
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