diff --git a/Dockerfile b/Dockerfile index c90f9385..086897bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ RUN adduser -u 1000 -H -D -G $username $username USER $username EXPOSE 5680 -CMD ["/usr/sbin/icinga-notifications", "--config", "/etc/icinga-notifications/config.yml"] +CMD ["/usr/sbin/icinga-notifications"] diff --git a/Makefile b/Makefile index 3e7201c6..e41bbe51 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ all: mkdir -p build go build \ -o build/ \ - -ldflags "-X '$(pkg).LibExecDir=$(libexecdir)'" \ + -ldflags "-X '$(pkg).LibExecDir=$(libexecdir)' -X '$(pkg).SysConfDir=$(sysconfdir)'" \ ./cmd/icinga-notifications go build -o build/channel/ ./cmd/channel/... diff --git a/cmd/icinga-notifications/main.go b/cmd/icinga-notifications/main.go index 23d0bfa7..3dea365f 100644 --- a/cmd/icinga-notifications/main.go +++ b/cmd/icinga-notifications/main.go @@ -26,7 +26,7 @@ func main() { var configPath string var showVersion bool - flag.StringVar(&configPath, "config", "", "path to config file") + flag.StringVar(&configPath, "config", internal.SysConfDir+"/icinga-notifications/config.yml", "path to config file") flag.BoolVar(&showVersion, "version", false, "print version") flag.Parse() @@ -43,11 +43,6 @@ func main() { return } - if configPath == "" { - _, _ = fmt.Fprintln(os.Stderr, "missing -config flag") - os.Exit(1) - } - err := daemon.LoadConfig(configPath) if err != nil { _, _ = fmt.Fprintln(os.Stderr, "cannot load config:", err) diff --git a/internal/paths.go b/internal/paths.go index d7076f71..01f2681c 100644 --- a/internal/paths.go +++ b/internal/paths.go @@ -1,6 +1,7 @@ package internal -// This variable exists to allow overwriting the path using `go build -ldflags "-X ...", see Makefile. +// These variables exist to allow overwriting the paths using `go build -ldflags "-X ...", see Makefile. var ( LibExecDir = "/usr/libexec" + SysConfDir = "/etc" )