Unmount local FS before stopping jail
This commit is contained in:
33
cmd/stop.go
33
cmd/stop.go
@ -95,7 +95,12 @@ func destroyVNetInterfaces(jail *Jail) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Jails copy the ruleset referenced as "devfs_ruleset" when starting, getting a new devsf_ruleset ID.
|
||||
// This new ID can be obtained with 'jls -j $JID devfs_ruleset'
|
||||
// This is the ID which needs to be removed. Original ID referenced is json should not be deleted
|
||||
// or else it will require a restart of "devfs" service.
|
||||
// But, stoppign the jail already removes this >1000 ID.
|
||||
// So no need to call this function.
|
||||
func deleteDevfsRuleset(jail *Jail) error {
|
||||
cmd := "devfs rule showsets"
|
||||
out, err := executeCommand(cmd)
|
||||
@ -256,13 +261,13 @@ func StopJail(args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf(" > Remove devfsruleset %s:\n", cj.Config.Devfs_ruleset)
|
||||
/*fmt.Printf(" > Remove devfsruleset %s:\n", cj.Config.Devfs_ruleset)
|
||||
err = deleteDevfsRuleset(cj)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s\n", err.Error())
|
||||
} else {
|
||||
fmt.Printf(" > Remove devfsruleset %s: OK\n", cj.Config.Devfs_ruleset)
|
||||
}
|
||||
}*/
|
||||
|
||||
fmt.Printf(" > Stop jail %s:\n", cj.Name)
|
||||
err = stopJail(cj)
|
||||
@ -311,6 +316,28 @@ func StopJail(args []string) {
|
||||
fmt.Printf(" > Umount devfs: OK\n")
|
||||
}
|
||||
}
|
||||
|
||||
// Remove local mounts from $JAIL/fstab
|
||||
// The way we get fstab is presumptuous
|
||||
fstab := strings.Replace(cj.ConfigPath, "config.json", "fstab", 1)
|
||||
mounts, err := getFstab(fstab)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s\n", err.Error())
|
||||
}
|
||||
if len(mounts) > 0 {
|
||||
fmt.Printf(" > Umount mountpoints from %s\n", fstab)
|
||||
errs := 0
|
||||
for _, m := range mounts {
|
||||
err = umountJailFsFromHost(cj, m.Mountpoint)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s\n", err.Error())
|
||||
errs += 1
|
||||
}
|
||||
}
|
||||
if errs == 0 {
|
||||
fmt.Printf(" > Umount mountpoints from %s: OK\n", fstab)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user