Do not support 2 jails with same name, only keep the first seen

This commit is contained in:
yo 2022-06-05 14:09:04 +02:00
parent 249ab19173
commit 57c8bba09b

View File

@ -220,6 +220,15 @@ func listJailsFromDirectory(dir string) []Jail {
j.Zpool = strings.Split(strings.TrimSuffix(out, "\n"), "/")[0] j.Zpool = strings.Split(strings.TrimSuffix(out, "\n"), "/")[0]
} }
// Check if jail with the same name already exist on another DS
for _, jj := range gJails {
if strings.EqualFold(jj.Name, j.Name) {
fmt.Printf("ERROR: A jail with name %s already exist on datastore %s!\n", j.Name, jj.Zpool)
fmt.Printf("Jail %s on datastore %s wont be handled\n", j.Name, j.Zpool)
return gJails
}
}
gJails = append(gJails, j) gJails = append(gJails, j)
} }
} }