From c0d5ef7e22c36c523f3d11da3a50085091a32fd6 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 8 Jan 2021 19:12:58 +0100 Subject: [PATCH] change workdir to config dir --- coolDns.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coolDns.go b/coolDns.go index 9538e66..5196641 100644 --- a/coolDns.go +++ b/coolDns.go @@ -7,6 +7,7 @@ import ( "net" "os" "os/signal" + "path/filepath" "strings" "syscall" @@ -383,6 +384,11 @@ func main() { configPath := flag.String("c", "/etc/cool-dns/config.yaml", "path to the config file") flag.Parse() + err := os.Chdir(filepath.Dir(*configPath)) + if err != nil { + log.Fatalf("Failed to goto config dir: %s", err.Error()) + } + config, err := loadConfig(*configPath) if err != nil { log.Fatalf("Failed to load config: %s\n", err.Error())