make all config and writeable files respect configDir/CWTCH_HOME

This commit is contained in:
Dan Ballard 2021-08-10 13:07:55 -07:00
parent 99a4a663e1
commit de864a845e
2 changed files with 4 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import (
mrand "math/rand" mrand "math/rand"
"os" "os"
"os/signal" "os/signal"
"path"
"syscall" "syscall"
"time" "time"
) )
@ -24,7 +25,7 @@ const (
func main() { func main() {
flagDebug := flag.Bool("debug", false, "Enable debug logging") 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() flag.Parse()
log.AddEverythingFromPattern("server/app/main") log.AddEverythingFromPattern("server/app/main")
@ -96,7 +97,7 @@ func main() {
log.Infof("Server Config: server address:%s", base64.StdEncoding.EncodeToString(bundle)) log.Infof("Server Config: server address:%s", base64.StdEncoding.EncodeToString(bundle))
if *flagExportTofu { if *flagExportTofu {
ioutil.WriteFile("tofubundle", []byte(tofubundle), 0600) ioutil.WriteFile(path.Join(serverConfig.ConfigDir, "tofubundle"), []byte(tofubundle), 0600)
} }
// Graceful Shutdown // Graceful Shutdown

View File

@ -62,7 +62,7 @@ func (s *Server) Run(acn connectivity.ACN) error {
log.Infof("cwtch server running on cwtch:%s\n", addressIdentity+".onion:") log.Infof("cwtch server running on cwtch:%s\n", addressIdentity+".onion:")
s.metricsPack.Start(service, s.config.ConfigDir, s.config.ServerReporting.LogMetricsToFile) 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 { if err != nil {
return fmt.Errorf("could not open database: %v", err) return fmt.Errorf("could not open database: %v", err)
} }