Use getJailFromArray so we can handle same name jails + check pertinence before jailing non existing DS
This commit is contained in:
parent
e7a6bdd376
commit
484e05e8d1
21
cmd/start.go
21
cmd/start.go
@ -212,6 +212,7 @@ func prepareJailedZfsDatasets(jail *Jail) error {
|
||||
}
|
||||
|
||||
func jailZfsDatasets(jail *Jail) error {
|
||||
if jail.Config.Jail_zfs > 0 {
|
||||
for _, d := range strings.Split(jail.Config.Jail_zfs_dataset, " ") {
|
||||
// Jail dataset
|
||||
cmd := fmt.Sprintf("zfs jail %d %s/%s", jail.JID, jail.Zpool, d)
|
||||
@ -234,6 +235,7 @@ func jailZfsDatasets(jail *Jail) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1028,18 +1030,11 @@ func StartJail(args []string) {
|
||||
var cj *Jail
|
||||
var err error
|
||||
|
||||
for _, j := range args {
|
||||
fmt.Printf("> Starting jail %s\n", j)
|
||||
|
||||
for i, rj := range gJails {
|
||||
if rj.Name == j {
|
||||
// Get jail reference, not a copy of it; So we can modify attributes
|
||||
cj = &gJails[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if cj == nil {
|
||||
fmt.Printf("Jail not found: %s\n", j)
|
||||
for _, a := range args {
|
||||
// Check if jail exist and is distinctly named
|
||||
cj, err = getJailFromArray(a, gJails)
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting jail: %s\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -1048,6 +1043,8 @@ func StartJail(args []string) {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("> Starting jail %s\n", a)
|
||||
|
||||
// Set InternalName as it is used by some of these
|
||||
cj.InternalName = fmt.Sprintf("ioc-%s", cj.Name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user