From de864a845ead2049cc5756ef20240a2525eda6c2 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 10 Aug 2021 13:07:55 -0700 Subject: [PATCH] make all config and writeable files respect configDir/CWTCH_HOME --- app/main.go | 5 +++-- server.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/main.go b/app/main.go index 945672f..8656290 100644 --- a/app/main.go +++ b/app/main.go @@ -14,6 +14,7 @@ import ( mrand "math/rand" "os" "os/signal" + "path" "syscall" "time" ) @@ -24,7 +25,7 @@ const ( func main() { flagDebug := flag.Bool("debug", false, "Enable debug logging") - flagExportTofu := flag.Bool("exportTofuBundle", false, "Export the tofubundle to a file called `tofubundle`") + flagExportTofu := flag.Bool("exportTofuBundle", false, "Export the tofubundle to a file called tofubundle") flag.Parse() log.AddEverythingFromPattern("server/app/main") @@ -96,7 +97,7 @@ func main() { log.Infof("Server Config: server address:%s", base64.StdEncoding.EncodeToString(bundle)) if *flagExportTofu { - ioutil.WriteFile("tofubundle", []byte(tofubundle), 0600) + ioutil.WriteFile(path.Join(serverConfig.ConfigDir, "tofubundle"), []byte(tofubundle), 0600) } // Graceful Shutdown diff --git a/server.go b/server.go index 11e66d9..0c02b07 100644 --- a/server.go +++ b/server.go @@ -62,7 +62,7 @@ func (s *Server) Run(acn connectivity.ACN) error { log.Infof("cwtch server running on cwtch:%s\n", addressIdentity+".onion:") s.metricsPack.Start(service, s.config.ConfigDir, s.config.ServerReporting.LogMetricsToFile) - ms, err := storage.InitializeSqliteMessageStore("cwtch.messages") + ms, err := storage.InitializeSqliteMessageStore(path.Join(s.config.ConfigDir, "cwtch.messages")) if err != nil { return fmt.Errorf("could not open database: %v", err) }