82 lines
2.9 KiB
Ruby
82 lines
2.9 KiB
Ruby
class Sftpgo < Formula
|
|
desc "Fully featured SFTP server with optional HTTP/S, FTP/S and WebDAV support"
|
|
homepage "https://github.com/drakkan/sftpgo"
|
|
url "https://github.com/drakkan/sftpgo/releases/download/v2.3.2/sftpgo_v2.3.2_src_with_deps.tar.xz"
|
|
sha256 "5711129bc1a74384032b27424391ece8bff2fb20e03eb6998869c4dc7a0196ce"
|
|
license "AGPL-3.0-only"
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "c7a53a2ec8f5ff0489a5802ac7912b41c8c3dfbdd4be0f920146d3bb04b78994"
|
|
sha256 arm64_big_sur: "9990a67f9271d90eb9509aed752014ac4f9e1bad96403c4d86334ed7ea28cd4b"
|
|
sha256 monterey: "8ee580632f72f07ecd1ec6acb1fe976162f270e1fcffc259f2648d8fe7445f0c"
|
|
sha256 big_sur: "1e593fc58f2255060d5854c7b1b355924763843fb743ae086c57ee89b10e1310"
|
|
sha256 catalina: "371bdd06c187620d14d34ff1c020ae34ec6c032214fa9068c1250ed8494171bb"
|
|
sha256 x86_64_linux: "dc10606e40cf36f9217fea235ca6ab68b23899b7f0f120a8b988ab64e33cc128"
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ldflags = %W[
|
|
-s -w
|
|
-X github.com/drakkan/sftpgo/v2/util.additionalSharedDataSearchPath=#{opt_pkgshare}
|
|
].join(" ")
|
|
system "go", "build", *std_go_args(ldflags: ldflags)
|
|
system bin/"sftpgo", "gen", "man", "-d", man1
|
|
|
|
(zsh_completion/"_sftpgo").write Utils.safe_popen_read(bin/"sftpgo", "gen", "completion", "zsh")
|
|
(bash_completion/"sftpgo").write Utils.safe_popen_read(bin/"sftpgo", "gen", "completion", "bash")
|
|
(fish_completion/"sftpgo.fish").write Utils.safe_popen_read(bin/"sftpgo", "gen", "completion", "fish")
|
|
|
|
inreplace "sftpgo.json" do |s|
|
|
s.gsub! "\"users_base_dir\": \"\"", "\"users_base_dir\": \"#{var}/sftpgo/data\""
|
|
end
|
|
|
|
pkgetc.install "sftpgo.json"
|
|
pkgshare.install "static", "templates", "openapi"
|
|
(var/"sftpgo").mkpath
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Default data location:
|
|
|
|
#{var}/sftpgo
|
|
|
|
Configuration file location:
|
|
|
|
#{pkgetc}/sftpgo.json
|
|
EOS
|
|
end
|
|
|
|
plist_options startup: true
|
|
service do
|
|
run [bin/"sftpgo", "serve", "--config-file", etc/"sftpgo/sftpgo.json", "--log-file-path",
|
|
var/"sftpgo/log/sftpgo.log"]
|
|
keep_alive true
|
|
working_dir var/"sftpgo"
|
|
end
|
|
|
|
test do
|
|
expected_output = "ok"
|
|
http_port = free_port
|
|
sftp_port = free_port
|
|
ENV["SFTPGO_HTTPD__BINDINGS__0__PORT"] = http_port.to_s
|
|
ENV["SFTPGO_HTTPD__BINDINGS__0__ADDRESS"] = "127.0.0.1"
|
|
ENV["SFTPGO_SFTPD__BINDINGS__0__PORT"] = sftp_port.to_s
|
|
ENV["SFTPGO_SFTPD__BINDINGS__0__ADDRESS"] = "127.0.0.1"
|
|
ENV["SFTPGO_SFTPD__HOST_KEYS"] = "#{testpath}/id_ecdsa,#{testpath}/id_ed25519"
|
|
ENV["SFTPGO_LOG_FILE_PATH"] = ""
|
|
pid = fork do
|
|
exec bin/"sftpgo", "serve", "--config-file", "#{pkgetc}/sftpgo.json"
|
|
end
|
|
|
|
sleep 5
|
|
assert_match expected_output, shell_output("curl -s 127.0.0.1:#{http_port}/healthz")
|
|
system "ssh-keyscan", "-p", sftp_port.to_s, "127.0.0.1"
|
|
ensure
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|