distributor: generate example config file if not exists

This commit is contained in:
Geno 2021-09-15 13:28:16 +02:00
parent 86241538cf
commit f21db8eaa8
1 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,15 @@ func main() {
flag.Parse() flag.Parse()
config := &configData{} 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) log.Panicf("open config file: %s", err)
} }