2013-09-26 03:58:25 -04:00
|
|
|
package chroot
|
|
|
|
|
|
|
|
import (
|
2013-09-26 04:32:53 -04:00
|
|
|
"fmt"
|
2013-09-26 21:28:06 -04:00
|
|
|
"log"
|
2013-09-27 06:54:53 -04:00
|
|
|
"os/exec"
|
2013-09-26 03:58:25 -04:00
|
|
|
)
|
|
|
|
|
2013-09-27 06:54:53 -04:00
|
|
|
func ChrootCommand(chroot string, command string) *exec.Cmd {
|
2013-09-27 21:10:33 -04:00
|
|
|
cmd := fmt.Sprintf("sudo chroot %s", chroot)
|
|
|
|
return ShellCommand(cmd, command)
|
2013-09-27 06:54:53 -04:00
|
|
|
}
|
|
|
|
|
2013-09-27 21:10:33 -04:00
|
|
|
func ShellCommand(commands ...string) *exec.Cmd {
|
|
|
|
cmds := append([]string{"-c"}, commands...)
|
|
|
|
cmd := exec.Command("/bin/sh", cmds...)
|
|
|
|
log.Printf("ShellCommand: %s %v", cmd.Path, cmd.Args[1:])
|
2013-09-27 06:54:53 -04:00
|
|
|
return cmd
|
2013-09-26 03:58:25 -04:00
|
|
|
}
|