1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 22:32:14 +00:00

Support string values for runcmd

This commit is contained in:
Josh Curl
2016-11-07 11:36:37 -08:00
parent ee16cd4311
commit c1abc67fa8
6 changed files with 65 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ import (
"strings"
yaml "github.com/cloudfoundry-incubator/candiedyaml"
osYaml "github.com/rancher/os/config/yaml"
log "github.com/Sirupsen/logrus"
)
@@ -269,13 +270,16 @@ func RunScript(path string) error {
return cmd.Run()
}
func RunCommandSequence(commandSequence [][]string) {
func RunCommandSequence(commandSequence []osYaml.StringandSlice) {
for _, command := range commandSequence {
if len(command) == 0 {
var cmd *exec.Cmd
if command.StringValue != "" {
cmd = exec.Command("sh", "-c", command.StringValue)
} else if len(command.SliceValue) > 0 {
cmd = exec.Command(command.SliceValue[0], command.SliceValue[1:]...)
} else {
continue
}
cmd := exec.Command(command[0], command[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {