diff --git a/dyndnsd-client.go b/dyndnsd-client.go index def18096e21f51f8b13f4a2ef0aaecc1e3403e17..3247e1d1d4811186b7d98921df1611388eaafd40 100644 --- a/dyndnsd-client.go +++ b/dyndnsd-client.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "github.com/joshbetz/config" "io/ioutil" @@ -27,7 +28,17 @@ func init() { logger.Println("PINGING dyndnsd ENDPOINT") // Configuration - cfg = config.New("config.json") + var configPath string + flag.StringVar(&configPath, "config", "", "Config file path") + flag.Parse() + + if _, err := os.Stat(configPath); os.IsNotExist(err) { + fmt.Println("Config path does not exist. Aborting!\n") + flag.Usage() + os.Exit(3) + } + + cfg = config.New(configPath) cfg.Get("ipv4_endpoint", &ipv4Endpoint) cfg.Get("ipv6_endpoint", &ipv6Endpoint) }