Use getJailFromArray so we can handle same name jails
This commit is contained in:
parent
170dce31b3
commit
e7a6bdd376
18
cmd/stop.go
18
cmd/stop.go
@ -190,24 +190,22 @@ func stopJail(jail *Jail) error {
|
|||||||
func StopJail(args []string) {
|
func StopJail(args []string) {
|
||||||
// Current jail were stopping
|
// Current jail were stopping
|
||||||
var cj *Jail
|
var cj *Jail
|
||||||
|
var err error
|
||||||
|
|
||||||
for _, j := range args {
|
for _, a := range args {
|
||||||
for _, rj := range gJails {
|
// Check if jail exist and is distinctly named
|
||||||
if rj.Name == j {
|
cj, err = getJailFromArray(a, gJails)
|
||||||
cj = &rj
|
if err != nil {
|
||||||
break
|
fmt.Printf("Error getting jail: %s\n", err)
|
||||||
}
|
|
||||||
}
|
|
||||||
if cj == nil {
|
|
||||||
fmt.Printf("Jail not found: %s\n", j)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if cj.Running == false {
|
if cj.Running == false {
|
||||||
fmt.Printf("Jail %s is not running!\n", cj.Name)
|
fmt.Printf("Jail %s is not running!\n", cj.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("> Stopping jail %s\n", j)
|
fmt.Printf("> Stopping jail %s\n", a)
|
||||||
|
|
||||||
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
|
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
|
||||||
if err == nil && len(out) > 0 {
|
if err == nil && len(out) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user