v0.36b: fix writeConfigToDisk

This commit is contained in:
yo
2023-07-23 15:41:37 +02:00
parent 310564b4af
commit 24439a8181
4 changed files with 46 additions and 68 deletions

View File

@ -290,16 +290,8 @@ func StopJail(args []string) {
return
}
cvers = strings.TrimRight(cvers, "\n")
//fmt.Sprintf(cj.Config.Release, cvers)
//cj.Config.Release = cvers
//cj.ConfigUpdated = true
// This is working in this context, but value is not available in WriteConfigToDisk context :/
setStructFieldValue(cj, "Config.Release", cvers)
//fmt.Printf("DEBUG: release was set, now is : %s\n", cj.Config.Release)
// We need to get the real Config object, not a copy of it
cj.Config.Release = cvers
WriteConfigToDisk(cj, false)
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
if err == nil && len(out) > 0 {
@ -429,7 +421,7 @@ func StopJail(args []string) {
fmt.Printf(" > Umount mountpoints from %s: OK\n", fstab)
}
}
// TODO: Execute poststop
if len(cj.Config.Exec_poststop) > 0 {
fmt.Printf(" > Execute post-stop:\n")
@ -440,13 +432,13 @@ func StopJail(args []string) {
fmt.Printf(" > Execute post-stop: OK\n")
}
}
// Remove parameter file
pfile := fmt.Sprintf("/var/run/jail.%s.conf", cj.InternalName)
if err = os.Remove(pfile); err != nil {
fmt.Printf("Error deleting parameter file %s\n", pfile)
}
// 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) {
@ -464,9 +456,7 @@ func StopJail(args []string) {
}
}
}
//fmt.Printf("DEBUG: release = %s\n", cj.Config.Release)
WriteConfigToDisk(cj.Name, false, true)
WriteConfigToDisk(cj, false)
}
}