From 5afa2c0f9a021bc5c474c26bf8103e17fc06b389 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Thu, 26 Sep 2019 00:24:15 -0400 Subject: [PATCH] added an env variable Added an environment variable for the home directory so we don't have to hardcode it or enter it inside a config file --- ssh.go | 4 +++- todo.md | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ssh.go b/ssh.go index ed7f553..d5ce94f 100644 --- a/ssh.go +++ b/ssh.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os" "golang.org/x/crypto/ssh" ) @@ -91,12 +92,13 @@ func (s SSHConnection) openSession(client SSHClients) SSHSessions { func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP { // execute order 66 lol sftp := SSHSFTP{} + homedir := os.Getenv("HOME") for _, j := range execute { // TODO: this is just a placeholder, change to the actual tarring executable getFile(j) - err := gzipit("/home/wyatt/"+filename, ".") + err := gzipit(homedir+filename, ".") if err != nil { fmt.Errorf("Cannot gzip file(s)", err) diff --git a/todo.md b/todo.md index 4fa229e..4471f18 100644 --- a/todo.md +++ b/todo.md @@ -3,4 +3,5 @@ - Allow having SSH keys and passwordless SSH sessions, along with having bypassing keys altogether - Allow fetching of multiple log files (fields under the defined host? Seperate key/field? Dynamic?) - Allow different machines to collect different log files -- Allow to gather directories of log files \ No newline at end of file +- Allow to gather directories of log files +- Develop a log getting logs for sanity \ No newline at end of file