use managed attribute

This commit is contained in:
shoopea
2023-07-31 10:13:36 +02:00
parent 24a5e6676f
commit b4d27e0867
7 changed files with 130 additions and 10 deletions

View File

@@ -202,6 +202,44 @@ func (c *Config) Run(e *Email) {
return
}
func (c *Config) Cleanup(e *Email) {
log.WithFields(log.Fields{}).Debugf("starting")
defer log.WithFields(log.Fields{}).Debugf("done")
for _, a := range cfg.apps {
for _, src := range a.sources {
if b, ok := c.box[src.Box()]; ok {
if fs, ok := b.zfs.filesystems[src.Path()]; ok {
fs.srcApps = append(fs.srcApps, a)
}
}
for _, dest := range a.destinations {
if b, ok := c.box[src.Box()]; ok {
if fs, ok := b.zfs.filesystems[dest.Append("/"+src.Box()+"/"+src.Path()).Path()]; ok {
fs.destApps = append(fs.destApps, a)
}
}
}
}
}
for _, b := range cfg.box {
if b.online {
for _, fs := range b.zfs.filesystems {
if len(fs.srcApps) > 0 && !fs.backedUp {
log.WithFields(log.Fields{"box": b.name, "fs": fs.path}).Warnf("not backed up")
e.AddItem(fmt.Sprintf(" - Src : Folder not backed up (%s)", b.name+":"+fs.path))
}
if len(fs.destApps) == 0 && !fs.backedUp && fs.managed {
log.WithFields(log.Fields{"box": b.name, "fs": fs.path}).Warnf("managed")
e.AddItem(fmt.Sprintf(" - Dest : Folder managed (%s)", b.name+":"+fs.path))
}
}
}
}
}
func (c *Config) Stop(e *Email) {
log.WithFields(log.Fields{}).Debugf("starting")
defer log.WithFields(log.Fields{}).Debugf("done")