From f21db8eaa8a2104a0c8e0c41c1d97390168533e0 Mon Sep 17 00:00:00 2001 From: Geno Date: Wed, 15 Sep 2021 13:28:16 +0200 Subject: [PATCH] distributor: generate example config file if not exists --- distributor/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/distributor/main.go b/distributor/main.go index 7acaeee..39383c1 100644 --- a/distributor/main.go +++ b/distributor/main.go @@ -41,7 +41,15 @@ func main() { flag.Parse() config := &configData{} - if err := file.ReadTOML(defaultPath(configPath, "config.toml"), config); err != nil { + configPath = defaultPath(configPath, "config.toml") + if err := file.ReadTOML(configPath, config); err != nil { + if os.IsNotExist(err) { + config.XMPP.Gateway = "up.chat.sum7.eu" + if err := file.SaveTOML(configPath, config); err != nil { + log.Panicf("save example config file: %s", err) + } + log.Panicf("open config file, we generate one here %s", configPath) + } log.Panicf("open config file: %s", err) }