Procházet zdrojové kódy

Support base configuration file outside the zone config directory

(And allow the filename to be specified)
Ask Bjørn Hansen před 9 roky
rodič
revize
4980e99cde
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  1. 8 1
      geodns.go

+ 8 - 1
geodns.go

@@ -53,6 +53,7 @@ var timeStarted = time.Now()
 
 
 var (
 var (
 	flagconfig       = flag.String("config", "./dns/", "directory of zone files")
 	flagconfig       = flag.String("config", "./dns/", "directory of zone files")
+	flagconfigfile   = flag.String("configfile", "geodns.conf", "filename of config file (in 'config' directory)")
 	flagcheckconfig  = flag.Bool("checkconfig", false, "check configuration and exit")
 	flagcheckconfig  = flag.Bool("checkconfig", false, "check configuration and exit")
 	flagidentifier   = flag.String("identifier", "", "identifier (hostname, pop name or similar)")
 	flagidentifier   = flag.String("identifier", "", "identifier (hostname, pop name or similar)")
 	flaginter        = flag.String("interface", "*", "set the listener address")
 	flaginter        = flag.String("interface", "*", "set the listener address")
@@ -109,7 +110,13 @@ func main() {
 		}
 		}
 	}
 	}
 
 
-	configFileName := filepath.Clean(*flagconfig + "/geodns.conf")
+	var configFileName string
+
+	if filepath.IsAbs(*flagconfigfile) {
+		configFileName = *flagconfigfile
+	} else {
+		configFileName = filepath.Clean(filepath.Join(*flagconfig, *flagconfigfile))
+	}
 
 
 	if *flagcheckconfig {
 	if *flagcheckconfig {
 		dirName := *flagconfig
 		dirName := *flagconfig