diff --git a/main.go b/main.go index dad4086..f568a49 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ func main() { flag.StringVar(&rsyncoptions.Hostname, "rsync-hostname", "", "Rsync host") flag.StringVar(&rsyncoptions.Username, "rsync-username", "", "Rsync username") flag.StringVar(&rsyncoptions.Destination, "rsync-destination", ".", "Rsync Destination directory") + flag.StringVar(&rsyncoptions.Rsh, "rsync-rsh", ".", "Rsync rsh command") flag.IntVar(&poolTime, "pool-time", 30, "Number of second to check new files to sync") flag.Parse() @@ -59,6 +60,7 @@ func main() { Username: rsyncoptions.Username, Hostname: rsyncoptions.Hostname, Destination: rsyncoptions.Destination, + Rsh: rsyncoptions.Rsh, Path: t.Path, OnProgress: func(p int) { err := qcli.SetProgress(t, p) diff --git a/rsync.go b/rsync.go index fc36843..74f24a1 100644 --- a/rsync.go +++ b/rsync.go @@ -15,6 +15,7 @@ type RsyncOptions struct { Hostname string Path string Destination string + Rsh string OnProgress func(p int) } @@ -29,6 +30,7 @@ func (r *RsyncOptions) Uri() string { type Rsync struct { Source string Destination string + Rsh string OnProgress func(p int) progress int @@ -38,6 +40,7 @@ func NewRsync(options *RsyncOptions) *Rsync { return &Rsync{ Source: options.Uri(), Destination: options.Destination, + Rsh: options.Rsh, OnProgress: options.OnProgress, progress: -1, } @@ -60,15 +63,20 @@ func ScanCR(data []byte, atEOF bool) (advance int, token []byte, err error) { } func (r *Rsync) Run() error { - cmd := exec.Command( - "rsync", + args := []string{ "--archive", "--partial", "--inplace", "--no-inc-recursive", "--info=progress2", - r.Source, - r.Destination, + } + if r.Rsh != "" { + args = append(args, "--rsh", r.Rsh) + } + args = append(args, r.Source, r.Destination) + cmd := exec.Command( + "rsync", + args..., ) out, err := cmd.StdoutPipe() if err != nil {