From 9b86d786fe0649ac2adbbf9440eccaa03dacd042 Mon Sep 17 00:00:00 2001 From: yo Date: Thu, 14 Jul 2022 12:32:14 +0200 Subject: [PATCH] Fix setting Running to false --- cmd/stop.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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()) + } + } + } } }