aboutsummaryrefslogtreecommitdiff
path: root/config/workdir.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-02-24 23:05:45 +0100
committerJulien Dessaux2020-02-25 09:46:38 +0100
commitcadb15f7afb5e7c88667eb4006209efca17744af (patch)
tree7e8e9e55c22bd4d195caf2b1dc1123500443ce75 /config/workdir.go
parentAdded tests to the spool package, and reworked the code around that. (diff)
downloadbareos-zabbix-check-cadb15f7afb5e7c88667eb4006209efca17744af.tar.gz
bareos-zabbix-check-cadb15f7afb5e7c88667eb4006209efca17744af.tar.bz2
bareos-zabbix-check-cadb15f7afb5e7c88667eb4006209efca17744af.zip
Added tests to the main package and completely reworked the code around that1.0
Diffstat (limited to '')
-rw-r--r--config/workdir.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/config/workdir.go b/config/workdir.go
deleted file mode 100644
index 208df1a..0000000
--- a/config/workdir.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package config
-
-import (
- "fmt"
- "log"
- "os"
- "path/filepath"
-)
-
-const (
- bareosWorkDir = "/var/lib/bareos"
- baculaWorkDir = "/var/lib/bacula"
-)
-
-// checkWorkDir checks if a work directory is valid
-func (c *Config) checkWorkDir() {
- // Determine the work directory to use.
- if c.workDir != "" {
- info, err := os.Stat(c.workDir)
- if os.IsNotExist(err) || !info.IsDir() {
- fmt.Printf("INFO Invalid work directory %s : it does not exist or is not a directory.\n", c.workDir)
- os.Exit(0)
- }
- } else {
- c.workDir = bareosWorkDir
- info, err := os.Stat(c.workDir)
- if os.IsNotExist(err) || !info.IsDir() {
- c.workDir = baculaWorkDir
- info, err := os.Stat(c.workDir)
- if os.IsNotExist(err) || !info.IsDir() {
- fmt.Println("INFO Could not find a suitable work directory. Is bareos or bacula installed?")
- os.Exit(0)
- }
- }
- }
- c.workDir = filepath.Clean(c.workDir)
- if c.verbose {
- log.Println("Setting work directory to ", c.workDir)
- }
-}