diff --git a/internal/httpservers/webuiServer.go b/internal/httpservers/webuiServer.go index 227aa81..12faf97 100644 --- a/internal/httpservers/webuiServer.go +++ b/internal/httpservers/webuiServer.go @@ -8,8 +8,10 @@ import ( "net/http" "os" "path" + "path/filepath" config "github.com/OliveTin/OliveTin/internal/config" + sv "github.com/OliveTin/OliveTin/internal/stringvariables" updatecheck "github.com/OliveTin/OliveTin/internal/updatecheck" ) @@ -43,12 +45,15 @@ func findWebuiDir() string { // search order must be deterministic - the order that the slice was defined in. for i := 0; i < len(directoriesToSearch); i++ { dir := directoriesToSearch[i] + absdir, _ := filepath.Abs(dir) - if _, err := os.Stat(dir); !os.IsNotExist(err) { + if _, err := os.Stat(absdir); !os.IsNotExist(err) { log.WithFields(log.Fields{ - "dir": dir, + "dir": absdir, }).Infof("Found the webui directory") + sv.Set("internal.webuidir", absdir+" ("+dir+")") + return dir } } @@ -71,6 +76,9 @@ func setupCustomWebuiDir() { if err != nil { log.Warnf("Could not create themes directory: %v", err) + sv.Set("internal.themesdir", err.Error()) + } else { + sv.Set("internal.themesdir", dir) } } diff --git a/internal/installationinfo/runtimeinfo.go b/internal/installationinfo/runtimeinfo.go index 96d066f..29f9782 100644 --- a/internal/installationinfo/runtimeinfo.go +++ b/internal/installationinfo/runtimeinfo.go @@ -4,6 +4,8 @@ import ( "bufio" "errors" "os" + "path" + "path/filepath" "runtime" "strings" ) @@ -14,6 +16,32 @@ type runtimeInfo struct { Arch string InContainer bool LastBrowserUserAgent string + User string + Uid string + FoundSshKey string +} + +var Runtime = &runtimeInfo{ + OS: runtime.GOOS, + Arch: runtime.GOARCH, + InContainer: isInContainer(), + OSReleasePrettyName: getOsReleasePrettyName(), + User: os.Getenv("USER"), + Uid: os.Getenv("UID"), +} + +func refreshRuntimeInfo() { + Runtime.FoundSshKey = searchForSshKey() +} + +func searchForSshKey() string { + path, _ := filepath.Abs(path.Join(os.Getenv("HOME"), ".ssh/id_rsa")) + + if _, err := os.Stat(path); err == nil { + return path + } + + return "none-found at " + path } func isInContainer() bool { @@ -46,10 +74,3 @@ func getOsReleasePrettyName() string { return "notfound" } - -var Runtime = &runtimeInfo{ - OS: runtime.GOOS, - Arch: runtime.GOARCH, - InContainer: isInContainer(), - OSReleasePrettyName: getOsReleasePrettyName(), -} diff --git a/internal/installationinfo/sosreport.go b/internal/installationinfo/sosreport.go index b70566a..b0ce756 100644 --- a/internal/installationinfo/sosreport.go +++ b/internal/installationinfo/sosreport.go @@ -3,6 +3,7 @@ package installationinfo import ( "fmt" config "github.com/OliveTin/OliveTin/internal/config" + sv "github.com/OliveTin/OliveTin/internal/stringvariables" "gopkg.in/yaml.v3" "time" ) @@ -18,6 +19,10 @@ type sosReportConfig struct { ListenAddressRestActions string ListenAddressGrpcActions string Timezone string + TimeNow string + ConfigDirectory string + WebuiDirectory string + ThemesDirectory string } func configToSosreport(cfg *config.Config) *sosReportConfig { @@ -30,10 +35,16 @@ func configToSosreport(cfg *config.Config) *sosReportConfig { ListenAddressRestActions: cfg.ListenAddressRestActions, ListenAddressGrpcActions: cfg.ListenAddressGrpcActions, Timezone: time.Now().Location().String(), + TimeNow: time.Now().String(), + ConfigDirectory: cfg.GetDir(), + WebuiDirectory: sv.Get("internal.webuidir"), + ThemesDirectory: sv.Get("internal.themesdir"), } } func GetSosReport() string { + refreshRuntimeInfo() + ret := "" ret += "### SOSREPORT START (copy all text to SOSREPORT END)\n"