From e2c65318328d435d34d73a8a974de70762b40ae7 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sun, 15 Feb 2026 19:09:20 -0800 Subject: fix: split sudo commands to fix ownership for rsync upload --- cmd/ship/deploy_impl_v2.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/ship/deploy_impl_v2.go b/cmd/ship/deploy_impl_v2.go index 5d9629d..417ee8f 100644 --- a/cmd/ship/deploy_impl_v2.go +++ b/cmd/ship/deploy_impl_v2.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "strconv" + "strings" "time" "github.com/bdw/ship/internal/output" @@ -25,17 +26,22 @@ func deployStaticV2(ctx *deployContext) *output.ErrorResponse { name := ctx.Name remotePath := fmt.Sprintf("/var/www/%s", name) - // Create directory + // Create directory and set ownership for upload + user, _ := client.Run("whoami") + user = strings.TrimSpace(user) if _, err := client.RunSudo(fmt.Sprintf("mkdir -p %s", remotePath)); err != nil { return output.Err(output.ErrUploadFailed, "failed to create directory: "+err.Error()) } + if _, err := client.RunSudo(fmt.Sprintf("chown -R %s:%s %s", user, user, remotePath)); err != nil { + return output.Err(output.ErrUploadFailed, "failed to set directory ownership: "+err.Error()) + } // Upload files using rsync if err := client.UploadDir(ctx.Path, remotePath); err != nil { return output.Err(output.ErrUploadFailed, err.Error()) } - // Set ownership + // Set ownership back to www-data if _, err := client.RunSudo(fmt.Sprintf("chown -R www-data:www-data %s", remotePath)); err != nil { // Non-fatal, continue } -- cgit v1.2.3