Skip to content

Commit

Permalink
Add support for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
brimstone committed Oct 8, 2016
1 parent a476726 commit 7a37a7d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "strings"

func init() {
inits = append(inits, runCommands)
}

func runCommands() {
for _, cmd := range config.Commands {
cmds := strings.Split(cmd, " ")
MyExec(cmds[0], cmds[1:]...)
}
}
14 changes: 14 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import "testing"

func Test_RunCommands(t *testing.T) {
config.Commands = []string{
"uptime",
}
MyExec = func(cmd string, arg ...string) ([]byte, error) {
t.Log("Preventing", cmd)
return []byte{}, nil
}
runCommands()
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ConfigType struct {
Path string `json:"path"`
Content string `json:"content"`
} `json:"files"`
Commands []string `json:"commands"`
}

var (
Expand Down

0 comments on commit 7a37a7d

Please sign in to comment.