WIP on start, go fmt on *

This commit is contained in:
yo
2022-04-24 16:49:54 +02:00
parent dbd9153513
commit 43f26d099f
12 changed files with 1498 additions and 1169 deletions

View File

@ -1,13 +1,13 @@
package cmd
import (
"os"
"fmt"
// "log"
"os"
// "log"
"errors"
"regexp"
"os/exec"
// "reflect"
"regexp"
// "reflect"
"strings"
)
@ -38,7 +38,6 @@ func removeRctlRules(jail string, rules []string) error {
return nil
}
// TODO: Validate with >1 dataset
func umountAndUnjailZFS(jail *Jail) error {
var ds []string
@ -75,11 +74,10 @@ func umountAndUnjailZFS(jail *Jail) error {
fmt.Printf("ERROR unjailing %s/%s: %s\n", jail.Zpool, ds[len(ds)-1], err.Error())
return err
}
return nil
}
func destroyVNetInterfaces(jail *Jail) error {
for _, i := range strings.Split(jail.Config.Ip4_addr, ",") {
iname := fmt.Sprintf("%s.%d", strings.Split(i, "|")[0], jail.JID)
@ -119,7 +117,6 @@ func deleteDevfsRuleset(jail *Jail) error {
return nil
}
func umountJailFsFromHost(jail *Jail, mountpoint string) error {
cmd := "mount -p"
out, err := executeCommand(cmd)
@ -145,7 +142,6 @@ func umountJailFsFromHost(jail *Jail, mountpoint string) error {
return nil
}
// Internal usage only
func stopJail(jail *Jail) error {
cmd := "jail -q"
@ -221,7 +217,7 @@ func StopJail(args []string) {
}
}
if len (cj.Config.Exec_prestop) > 0 {
if len(cj.Config.Exec_prestop) > 0 {
fmt.Printf(" > Execute prestop:\n")
_, err := executeCommand(cj.Config.Exec_prestop)
if err != nil {
@ -230,8 +226,8 @@ func StopJail(args []string) {
fmt.Printf(" > Execute prestop: OK\n")
}
}
if len (cj.Config.Exec_stop) > 0 {
if len(cj.Config.Exec_stop) > 0 {
fmt.Printf(" > Execute stop:\n")
_, err := executeCommandInJail(cj, cj.Config.Exec_stop)
if err != nil {
@ -260,7 +256,7 @@ func StopJail(args []string) {
fmt.Printf(" > Destroy VNet interfaces: OK\n")
}
}
/*fmt.Printf(" > Remove devfsruleset %s:\n", cj.Config.Devfs_ruleset)
err = deleteDevfsRuleset(cj)
if err != nil {
@ -268,7 +264,7 @@ func StopJail(args []string) {
} else {
fmt.Printf(" > Remove devfsruleset %s: OK\n", cj.Config.Devfs_ruleset)
}*/
fmt.Printf(" > Stop jail %s:\n", cj.Name)
err = stopJail(cj)
if err != nil {
@ -340,4 +336,3 @@ func StopJail(args []string) {
}
}
}