aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/git-lfs-server/main.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/cmd/git-lfs-server/main.go b/cmd/git-lfs-server/main.go
index 3921646..aa2a0c6 100644
--- a/cmd/git-lfs-server/main.go
+++ b/cmd/git-lfs-server/main.go
@@ -98,9 +98,10 @@ type batchResponse struct {
98} 98}
99 99
100type handler struct { 100type handler struct {
101 mc *minio.Client 101 mc *minio.Client
102 bucket string 102 bucket string
103 anonUser string 103 anonUser string
104 gitolitePath string
104} 105}
105 106
106// Requires lowercase hash 107// Requires lowercase hash
@@ -257,7 +258,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
257 if body.Ref != nil && body.Ref.Name != "" { 258 if body.Ref != nil && body.Ref.Name != "" {
258 gitoliteArgs = append(gitoliteArgs, body.Ref.Name) 259 gitoliteArgs = append(gitoliteArgs, body.Ref.Name)
259 } 260 }
260 cmd := exec.Command("gitolite", gitoliteArgs...) 261 cmd := exec.Command(h.gitolitePath, gitoliteArgs...)
261 err := cmd.Run() 262 err := cmd.Run()
262 permGranted := err == nil 263 permGranted := err == nil
263 var exitErr *exec.ExitError 264 var exitErr *exec.ExitError
@@ -314,15 +315,20 @@ func die(msg string, args ...any) {
314} 315}
315 316
316func main() { 317func main() {
318 log("Environment variables:")
319 for _, s := range os.Environ() {
320 log(" %s", s)
321 }
322
317 anonUser := os.Getenv("ANON_USER") 323 anonUser := os.Getenv("ANON_USER")
318 endpoint := os.Getenv("S3_ENDPOINT") 324 endpoint := os.Getenv("S3_ENDPOINT")
319 bucket := os.Getenv("S3_BUCKET") 325 bucket := os.Getenv("S3_BUCKET")
320 accessKeyIDFile := os.Getenv("S3_ACCESS_KEY_ID_FILE") 326 accessKeyIDFile := os.Getenv("S3_ACCESS_KEY_ID_FILE")
321 secretAccessKeyFile := os.Getenv("S3_SECRET_ACCESS_KEY_FILE") 327 secretAccessKeyFile := os.Getenv("S3_SECRET_ACCESS_KEY_FILE")
328 gitolitePath := os.Getenv("GITOLITE_PATH")
322 329
323 log("Environment variables:") 330 if gitolitePath == "" {
324 for _, s := range os.Environ() { 331 gitolitePath = "gitolite"
325 log(" %s", s)
326 } 332 }
327 333
328 if anonUser == "" { 334 if anonUser == "" {
@@ -359,7 +365,7 @@ func main() {
359 die("Fatal: failed to create S3 client: %s", err) 365 die("Fatal: failed to create S3 client: %s", err)
360 } 366 }
361 367
362 if err = cgi.Serve(&handler{mc, bucket, anonUser}); err != nil { 368 if err = cgi.Serve(&handler{mc, bucket, anonUser, gitolitePath}); err != nil {
363 die("Fatal: failed to serve CGI: %s", err) 369 die("Fatal: failed to serve CGI: %s", err)
364 } 370 }
365} 371}