From f5ebe96649a30658bb8a8bee4cb2ac1b45823b28 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 6 Apr 2025 00:42:11 +0800 Subject: Hooks, git2d: Simplify deployment logic --- server.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'server.go') diff --git a/server.go b/server.go index feab082..3e02586 100644 --- a/server.go +++ b/server.go @@ -13,10 +13,12 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "syscall" "time" "go.lindenii.runxiyu.org/forge/internal/database" + "go.lindenii.runxiyu.org/forge/internal/misc" "go.lindenii.runxiyu.org/lindenii-common/cmap" goSSH "golang.org/x/crypto/ssh" ) @@ -64,18 +66,10 @@ func (s *Server) Setup() { } func (s *Server) Run() { - if err := s.deployHooks(); err != nil { - slog.Error("deploying hooks", "error", err) - os.Exit(1) - } - if err := s.loadTemplates(); err != nil { - slog.Error("loading templates", "error", err) - os.Exit(1) - } - if err := s.deployGit2D(); err != nil { - slog.Error("deploying git2d", "error", err) - os.Exit(1) - } + misc.NoneOrPanic(s.loadTemplates()) + misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("git2d/git2d")), s.config.Git.DaemonPath)) + misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("hookc/hookc")), filepath.Join(s.config.Hooks.Execs, "pre-receive"))) + misc.NoneOrPanic(os.Chmod(filepath.Join(s.config.Hooks.Execs, "pre-receive"), 0o755)) // Launch Git2D go func() { -- cgit v1.2.3