2 Commits

Author SHA1 Message Date
5afa2c0f9a 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
2019-09-26 00:24:15 -04:00
e766f580bb added generate.go, added todo
Added generate.go out of habit for idiots like me who delete config
files like it's no big deal. Also added a markdown file called todo,
name is self-explanatory as it helps me remember stuff that I need
to do and as well helps contributors figure what needs to happen
2019-09-25 23:17:38 -04:00
5 changed files with 61 additions and 3 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ config.yaml
vendor/
*.log
*.tar.gz
*.bak

View File

@ -11,6 +11,7 @@ type Configuration struct {
Password string
Port int
Hosts []string
Logs []string
}
func initializeConfig(filename string) Configuration {

View File

@ -1,5 +1,52 @@
package main
// this file is for generating the config if it doesn't exist
import (
"fmt"
"io/ioutil"
"os"
"gopkg.in/yaml.v2"
)
// this file is for generating the config if it doesn't exist, mainly for the idiots like me :)
// this is not really a priority right now so it sitting in the backburner as you read this
// signed Wyatt J. Miller, the awesome guy who doesn't generate configs *thumbs up*
var config string = "config.yaml"
func doesConfigExist() bool {
_, err := os.Stat(config)
if err != nil {
return false
} else {
return true
}
}
func createTemplateConfig(result bool) {
if result == false {
os.Create(config)
} else {
fmt.Println()
}
}
func writeTemplateConfig(filename string) {
file := []byte(filename)
_ = ioutil.WriteFile("config.yaml", file, 0600)
config := Configuration{}
_, err := yaml.Marshal(config)
if err != nil {
panic(err)
}
fmt.Println("Template for logman's configuration complete!")
fmt.Println("")
fmt.Println("Fill in the necessary credentials you need. If")
fmt.Println("you need assitance, check out the wiki for more.")
os.Exit(0)
}

4
ssh.go
View File

@ -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)

7
todo.md Normal file
View File

@ -0,0 +1,7 @@
## Things I got to do for the project
- Have config file dictate what log file you want
- 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
- Develop a log getting logs for sanity