started working on "gocage console"
This commit is contained in:
parent
0053fd6c8b
commit
7dbbf8a757
39
cmd/console.go
Normal file
39
cmd/console.go
Normal file
@ -0,0 +1,39 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ShellJail(args []string) error {
|
||||
var jailnames []string
|
||||
if len(args) > 0 {
|
||||
for _, a := range args {
|
||||
jailnames = append(jailnames, a)
|
||||
}
|
||||
}
|
||||
|
||||
for _, cj := range gJails {
|
||||
for _, jn := range jailnames {
|
||||
if strings.EqualFold(cj.Name, jn) {
|
||||
err := shellJail(cj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func shellJail(jail Jail) error {
|
||||
cmd := fmt.Sprintf("jexec %s /bin/csh", jail.JID)
|
||||
_, err := executeCommand(cmd)
|
||||
if err != nil {
|
||||
fmt.Errorf("Error executing %s: %s", cmd, err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user