mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2024-12-12 17:41:08 +01:00
fe14f63217
- Ability to run a command pre up and post down - Ability to be a client in one mesh and a peer in the other - Added dev card to specify different sync rate, keepalive rate per mesh.
34 lines
651 B
Go
34 lines
651 B
Go
// cmd is a package for running commands in the different operating systems implementations
|
|
package cmd
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
type CmdRunner interface {
|
|
RunCommands(commands ...string) error
|
|
}
|
|
|
|
type UnixCmdRunner struct{}
|
|
|
|
// RunCommand: runs the unix command. It splits the command into fields
|
|
// and then runs the command accordingly
|
|
func RunCommand(cmd string) error {
|
|
args := strings.Fields(cmd)
|
|
c := exec.Command(args[0], args[1:]...)
|
|
return c.Run()
|
|
}
|
|
|
|
func (l *UnixCmdRunner) RunCommands(commands ...string) error {
|
|
for _, cmd := range commands {
|
|
err := RunCommand(cmd)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|