getJailFromArray filtering by type

This commit is contained in:
yo
2023-08-05 19:49:50 +02:00
parent bce37e6541
commit 45e1c57ce4
7 changed files with 12 additions and 10 deletions

View File

@ -3,13 +3,14 @@ package cmd
import (
"fmt"
//"log"
"time"
//"errors"
"strings"
)
func DestroyJails(args []string) {
for _, a := range args {
cj, err := getJailFromArray(a, gJails)
cj, err := getJailFromArray(a, []string{""}, gJails)
if err != nil {
fmt.Printf("Error getting jail: %s\n", err)
return
@ -27,6 +28,8 @@ func DestroyJails(args []string) {
}
fmt.Printf("Stopping jail %s\n", cj.Name)
StopJail([]string{fmt.Sprintf("%s/%s", cj.Datastore, cj.Name)})
// Give some time to the host OS to free all mounts accessing processes
time.Sleep(1 * time.Second)
}
// Get root and config datasets, then destroy
@ -51,7 +54,6 @@ func DestroyJails(args []string) {
fmt.Printf("Error deleting config dataset: %s\n", err)
return
}
//TODO: Delete jail named directory
fmt.Printf("Jail %s is no more!\n", cj.Name)
}
}