diff --git a/jobs/jobs.go b/jobs/jobs.go new file mode 100644 index 0000000..976b05a --- /dev/null +++ b/jobs/jobs.go @@ -0,0 +1,39 @@ +package jobs + +import ( + "os" + "path" +) + +type Config struct { + ScriptsDir string `json:"scriptsDir"` +} + +type Service struct { + Config Config + + scriptPaths []string +} + +func New(config Config) *Service { + return &Service{ + Config: config, + } +} + +func (s *Service) LoadScripts() error { + entries, err := os.ReadDir(s.Config.ScriptsDir) + if err != nil { + return err + } + + s.scriptPaths = []string{} + + for _, entry := range entries { + s.scriptPaths = append(s.scriptPaths, + path.Join(s.Config.ScriptsDir, entry.Name()), + ) + } + + return nil +} diff --git a/scripts/raid-status b/scripts/raid-status new file mode 100755 index 0000000..08845fc --- /dev/null +++ b/scripts/raid-status @@ -0,0 +1,18 @@ +#!/bin/bash + +DEVICE="/dev/md0" + +TOTAL_DEVICES=$(mdadm -D "$DEVICE" | grep 'Total Devices' | cut -d':' -f 2 | tr -d ' ') + +mdadm -D "$DEVICE" | tail -n "$TOTAL_DEVICES" | tr -s ' ' | cut -d' ' -f 6 + +# Example Output: +# +# active +# active +# active +# active +# active +# + +# TODO: Non ho realmente trovato nella documentazione le altre parole, penso siano "missing" e "failing" perĂ² boh \ No newline at end of file