]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync.go
Move embedded remote helpers to cmd/safcm/
[safcm/safcm.git] / cmd / safcm / sync.go
index 4a82ca3b906464f8ce58f652f4abf9afbbf71cb8..bee0133e4fd4326ef1610325fc6ae8649147da29 100644 (file)
@@ -20,9 +20,11 @@ package main
 import (
        "flag"
        "fmt"
+       "io/fs"
        "log"
        "os"
        "os/signal"
+       "runtime"
        "sort"
        "strings"
        "sync"
@@ -105,6 +107,10 @@ func MainSync(args []string) error {
                os.Exit(1)
        }
 
+       if runtime.GOOS == "windows" {
+               log.Print("WARNING: Windows support is experimental!")
+       }
+
        cfg, allHosts, allGroups, err := LoadBaseFiles()
        if err != nil {
                return err
@@ -364,9 +370,25 @@ func (s *Sync) Host(wg *sync.WaitGroup) error {
                wg.Done()
        }()
 
+       helpers, err := fs.Sub(RemoteHelpers, "remote")
+       if err != nil {
+               conn.Kill()
+               return err
+       }
+
        // Connect to remote host
-       err := conn.DialSSH(s.host.SshUser, s.host.Name, s.config.SshConfig)
+       user := s.host.SshUser
+       if user == "" {
+               user = s.config.SshUser
+       }
+       err = conn.DialSSH(rpc.SSHConfig{
+               Host:          s.host.Name,
+               User:          user,
+               SshConfig:     s.config.SshConfig,
+               RemoteHelpers: helpers,
+       })
        if err != nil {
+               conn.Kill()
                return err
        }
        defer conn.Kill()