Change default file locations (#35)

* Change default files location as described in #27

* config: Change default config file name
This commit is contained in:
fox.cpp 2019-04-08 19:57:21 +03:00 committed by Simon Ser
parent 3c40e21817
commit 6e17ecab31
6 changed files with 82 additions and 25 deletions

39
directories.go Normal file
View file

@ -0,0 +1,39 @@
package maddy
import (
"os"
)
var (
defaultConfigDirectory = "/etc/maddy"
defaultStateDirectory = "/var/lib/maddy"
defaultLibexecDirectory = "/usr/libexec/maddy"
)
func ConfigDirectory() string {
return defaultConfigDirectory
}
func StateDirectory(globals map[string]interface{}) string {
if dir := os.Getenv("MADDYSTATE"); dir != "" {
return dir
}
if val, ok := globals["statedir"]; ok {
return val.(string)
}
return defaultStateDirectory
}
func LibexecDirectory(globals map[string]interface{}) string {
if dir := os.Getenv("MADDYLIBEXEC"); dir != "" {
return dir
}
if val, ok := globals["libexecdir"]; ok {
return val.(string)
}
return defaultLibexecDirectory
}