Compare commits
2 Commits
working-ve
...
dev-log
Author | SHA1 | Date | |
---|---|---|---|
5afa2c0f9a | |||
e766f580bb |
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ config.yaml
|
|||||||
.vscode/
|
.vscode/
|
||||||
vendor/
|
vendor/
|
||||||
*.log
|
*.log
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
|
*.bak
|
@ -11,6 +11,7 @@ type Configuration struct {
|
|||||||
Password string
|
Password string
|
||||||
Port int
|
Port int
|
||||||
Hosts []string
|
Hosts []string
|
||||||
|
Logs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeConfig(filename string) Configuration {
|
func initializeConfig(filename string) Configuration {
|
||||||
|
49
generate.go
49
generate.go
@ -1,5 +1,52 @@
|
|||||||
package main
|
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
|
// 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*
|
// 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
4
ssh.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
@ -91,12 +92,13 @@ func (s SSHConnection) openSession(client SSHClients) SSHSessions {
|
|||||||
func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP {
|
func (s SSHConnection) executeSFTP(execute SSHClients) SSHSFTP {
|
||||||
// execute order 66 lol
|
// execute order 66 lol
|
||||||
sftp := SSHSFTP{}
|
sftp := SSHSFTP{}
|
||||||
|
homedir := os.Getenv("HOME")
|
||||||
|
|
||||||
for _, j := range execute {
|
for _, j := range execute {
|
||||||
// TODO: this is just a placeholder, change to the actual tarring executable
|
// TODO: this is just a placeholder, change to the actual tarring executable
|
||||||
getFile(j)
|
getFile(j)
|
||||||
|
|
||||||
err := gzipit("/home/wyatt/"+filename, ".")
|
err := gzipit(homedir+filename, ".")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Cannot gzip file(s)", err)
|
fmt.Errorf("Cannot gzip file(s)", err)
|
||||||
|
7
todo.md
Normal file
7
todo.md
Normal 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
|
Reference in New Issue
Block a user