Skip to content

Commit

Permalink
Executing ssh (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Apr 8, 2016
1 parent 495ff33 commit 225cf85
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/commands/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package commands

import (
"fmt"
"os"
"syscall"

"github.com/codegangsta/cli"

Expand All @@ -14,6 +16,7 @@ func cmdWrapper(c *cli.Context) {
Logger.Fatalf("Missing <target> argument. See usage with 'assh wrapper -h'.")
}

// prepare variables
target := c.Args()[0]
command := c.Args()[1:]
options := []string{}
Expand All @@ -28,18 +31,25 @@ func cmdWrapper(c *cli.Context) {
options = append(options, val)
}
}

args := append(options, target)
args = append(args, command...)
bin := "/usr/bin/ssh"
Logger.Debugf("Wrapper called with target=%v command=%v ssh-options=%v", target, command, options)

// check if config is up-to-date
conf, err := config.Open()
if err != nil {
Logger.Fatalf("Cannot open configuration file: %v", err)
}

fmt.Println(conf.NeedsARebuildForTarget(target))
//host := conf.GetHostSafe(target)
//fmt.Println(host)
//fmt.Println(host.name)
if conf.NeedsARebuildForTarget(target) {
Logger.Debugf("The configuration file is outdated, rebuilding it before calling ssh")
//host := conf.GetHostSafe(target)
//fmt.Println(host)
//fmt.Println(host.name)
//conf.WriteSshConfigTo(os.Stdout)
}

//conf.WriteSshConfigTo(os.Stdout)
// Execute SSH
syscall.Exec(bin, args, os.Environ())
}

0 comments on commit 225cf85

Please sign in to comment.