Add start and stop all jails for boot/shutdown, add debug mode
This commit is contained in:
29
cmd/stop.go
29
cmd/stop.go
@ -10,6 +10,8 @@ import (
|
||||
//"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// TODO : Use SYS_RCTL_GET_RACCT syscall
|
||||
@ -166,6 +168,33 @@ func stopJail(jail *Jail) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop all running jails by reverse priority
|
||||
func StopAllRunningJails() {
|
||||
var stopList []Jail
|
||||
|
||||
// Get boot enabled jails
|
||||
for _, j := range gJails {
|
||||
if j.Running == true {
|
||||
stopList = append(stopList, j)
|
||||
}
|
||||
}
|
||||
|
||||
// Order by priority
|
||||
js := initJailSortStruct()
|
||||
fct, _, err := getStructFieldValue(js, "Config.PriorityDec")
|
||||
if err != nil {
|
||||
log.Errorf("ERROR getting JailSort struct field \"Config.PriorityDec\"\n")
|
||||
return
|
||||
}
|
||||
JailsOrderedBy(fct.Interface().(jailLessFunc)).Sort(stopList)
|
||||
|
||||
for _, j := range stopList {
|
||||
jFullName := fmt.Sprintf("%s/%s", j.Datastore, j.Name)
|
||||
log.Debugf("Stopping %s with priority %s\n", jFullName, j.Config.Priority)
|
||||
StopJail([]string{jFullName})
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Stop jail:
|
||||
Remove rctl rules
|
||||
|
Reference in New Issue
Block a user