aboutsummaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-03-08 23:56:21 +0700
committerShulhan <ms@kilabit.info>2021-03-08 23:56:21 +0700
commit1244e56cee5c3ee9f184ecb47f2c606a5bb4bf5c (patch)
treed1d2adef9d0a25ab6dd1e16827f8be3381bc7094 /command.go
parent58f8e27183415dbe758ff4fd098ed126758ad0ca (diff)
downloadawwan-1244e56cee5c3ee9f184ecb47f2c606a5bb4bf5c.tar.xz
all: set base dir based on the first .ssh directory that we found
Previously, the base directory is set on current working directory. This limit the way to execute awwan only from the directory that contains the .ssh directory. This changes set the environment BaseDir based on the first .ssh directory that we found from script path up to the "/". So, user can execute awwan script from any sub-directories.
Diffstat (limited to 'command.go')
-rw-r--r--command.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/command.go b/command.go
index 93fcc50..1b0f204 100644
--- a/command.go
+++ b/command.go
@@ -48,6 +48,11 @@ func NewCommand(mode, scriptPath string, startAt, endAt int) (cmd *Command, err
return nil, fmt.Errorf("%s: unknown command %s\n", logp, mode)
}
+ scriptPath, err = filepath.Abs(scriptPath)
+ if err != nil {
+ return nil, fmt.Errorf("%s: %w", logp, err)
+ }
+
if endAt < startAt {
endAt = startAt
}
@@ -468,7 +473,10 @@ func (cmd *Command) initSSHClient() (err error) {
cmd.env.hostname)
}
- log.Printf("sshSection:%+v\n", sshSection)
+ log.Printf("\nSSH Hostname: %s\n", sshSection.Hostname)
+ log.Printf("SSH Port: %d\n", sshSection.Port)
+ log.Printf("SSH User: %s\n", sshSection.User)
+ log.Printf("SSH IdentityFile %s\n\n", sshSection.IdentityFile)
cmd.sshClient, err = ssh.NewClient(sshSection)
if err != nil {