From afc57e91cdad9bcc31fc79ff8f14a71d89a34e84 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Sat, 20 Apr 2019 14:04:01 -0500 Subject: [PATCH] Pass ssh flags to rsync Resolves #19 --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 3e69bbc..0b95379 100644 --- a/main.go +++ b/main.go @@ -84,7 +84,7 @@ chmod +x `+codeServerPath+` flog.Info("synced settings in %s", time.Since(start)) flog.Info("syncing extensions") - err = syncExtensions(host) + err = syncExtensions(host, *sshFlags) if err != nil { flog.Fatal("failed to sync extensions: %v", err) } @@ -208,24 +208,24 @@ func syncUserSettings(host string) error { return rsync(localConfDir+"/", remoteSettingsDir, host, "workspaceStorage", "logs", "CachedData") } -func syncExtensions(host string) error { +func syncExtensions(host string, sshFlags string) error { localExtensionsDir, err := extensionsDir() if err != nil { return err } const remoteExtensionsDir = ".local/share/code-server/extensions" - return rsync(localExtensionsDir+"/", remoteExtensionsDir, host) + return rsync(localExtensionsDir+"/", remoteExtensionsDir, sshFlags, host) } -func rsync(src string, dest string, host string, excludePaths ...string) error { +func rsync(src string, dest string, host string, sshFlags string, excludePaths ...string) error { remoteDest := fmt.Sprintf("%s:%s", host, dest) excludeFlags := make([]string, len(excludePaths)) for i, path := range excludePaths { excludeFlags[i] = "--exclude=" + path } - cmd := exec.Command("rsync", append(excludeFlags, "-azv", "--copy-unsafe-links", src, remoteDest)...) + cmd := exec.Command("rsync", append(excludeFlags, "-e", "ssh "+sshFlags, "-azv", "--copy-unsafe-links", src, remoteDest)...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err := cmd.Run()