diff --git a/cmd/stop.go b/cmd/stop.go index a4f4f4f..be45ce1 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -360,8 +360,19 @@ func StopJail(args []string) { fmt.Printf("Error deleting parameter file %s\n", pfile) } - cj.InternalName = "" - cj.Running = false - cj.JID = 0 + // We need this to get a reference to cj.Running (bc cj.Running is just a copy of value in the scope of StopJail()) + for i, j := range gJails { + if strings.EqualFold(j.Name, cj.Name) && strings.EqualFold(j.Datastore, cj.Datastore) { + if err = setStructFieldValue(&gJails[i], "Running", "false"); err != nil { + fmt.Printf("ERROR: setting Running property to false: %s\n", err.Error()) + } + if err = setStructFieldValue(&gJails[i], "JID", "0"); err != nil { + fmt.Printf("ERROR: setting JID property to 0: %s\n", err.Error()) + } + if err = setStructFieldValue(&gJails[i], "InternalName", ""); err != nil { + fmt.Printf("ERROR: clearing InternalName property: %s\n", err.Error()) + } + } + } } }