blob: eb35942c88183d88728728972347aa807e658229 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package zabbix
import (
"fmt"
"os"
"path/filepath"
)
const (
bareosWorkDir = "/var/lib/bareos"
baculaWorkDir = "/var/lib/bacula"
)
var root = "/"
// checkWorkDir checks if a work directory is valid
func checkWorkDir() error {
// Determine the work directory to use.
if workDir != "" {
workDir = filepath.Join(root, workDir)
info, err := os.Stat(workDir)
if os.IsNotExist(err) || !info.IsDir() {
return fmt.Errorf("Invalid work directory %s : it does not exist or is not a directory", workDir)
}
} else {
workDir = filepath.Join(root, bareosWorkDir)
info, err := os.Stat(workDir)
if os.IsNotExist(err) || !info.IsDir() {
workDir = filepath.Join(root, baculaWorkDir)
info, err := os.Stat(workDir)
if os.IsNotExist(err) || !info.IsDir() {
return fmt.Errorf("Could not autodetect a suitable work directory. Is bareos or bacula installed?")
}
}
}
workDir = filepath.Clean(workDir)
return nil
}
|