mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-17 14:38:41 +08:00
update RunCmd
This commit is contained in:
parent
e88d34ac96
commit
747baf1bba
2 changed files with 12 additions and 2 deletions
|
|
@ -103,7 +103,7 @@ netclient_args="daemon"`
|
|||
}
|
||||
|
||||
func FreebsdDaemon(command string) {
|
||||
out, err := ncutils.RunCmd("service netclient "+command, true)
|
||||
out, err := ncutils.RunCmdFormatted("service netclient "+command, true)
|
||||
ncutils.Log("output from RunCmd " + out)
|
||||
ncutils.Log("error from RunCmd " + err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ncutils
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
|
@ -11,7 +12,16 @@ import (
|
|||
|
||||
// RunCmdFormatted - run a command formatted for freebsd
|
||||
func RunCmdFormatted(command string, printerr bool) (string, error) {
|
||||
return "", nil
|
||||
|
||||
args := strings.Fields(command)
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
cmd.Wait()
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil && printerr {
|
||||
Log(fmt.Sprintf("error running command: %s", command))
|
||||
Log(strings.TrimSuffix(string(out), "\n"))
|
||||
}
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
// GetEmbedded - if files required for freebsd, put here
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue