diff --git a/config/config.go b/config/config.go index 102e14654e87f6ede9001725bd9850044a8316ed..90f853d551e4ffa617416a5b632af529b26e08df 100644 --- a/config/config.go +++ b/config/config.go @@ -3,6 +3,7 @@ import ( "log" "os" + "path/filepath" "git.sr.ht/~sircmpwn/getopt" "github.com/vaughan0/go-ini" @@ -37,13 +38,28 @@ Debug = true } } + // Only loads from one of these locations for _, path := range []string{ "config.ini", "../config.ini", "/etc/sr.ht/config.ini", + "/etc/sr.ht/*.ini", } { - config, err = ini.LoadFile(path) - if err == nil { + matches, err_ := filepath.Glob(path) + if err_ != nil { + panic(err) // only happens on bad input + } + for _, f := range matches { + if config == nil { + config, err = ini.LoadFile(f) + } else { + err = config.LoadFile(f) + } + if err != nil { + break + } + } + if len(matches) > 0 { break } }