ensureEnv: set OLLIE_* defaults at startup

Ensure all OLLIE_* path env vars (OLLIE, OLLIE_TOOLS_PATH,
OLLIE_SKILLS_PATH, OLLIE_PLAN_PATH, OLLIE_MEMORY_PATH) are set
to their default values via os.Setenv before the server or any
session is created. This guarantees they are visible to tool
subprocesses without requiring explicit external configuration.
This commit is contained in:
Levi Neely 2026-04-15 11:16:16 +02:00
parent 10a0a36681
commit f478f7545c
1 changed files with 18 additions and 0 deletions

18
main.go
View File

@ -104,7 +104,25 @@ func stopServer(sockPath, pidPath string) {
fmt.Println("olliesrv stopped")
}
func ensureEnv() {
home, _ := os.UserHomeDir()
defaults := map[string]string{
"OLLIE": filepath.Join(home, "mnt", "ollie"),
"OLLIE_TOOLS_PATH": filepath.Join(home, ".config", "ollie", "tools"),
"OLLIE_SKILLS_PATH": filepath.Join(home, ".config", "ollie", "skills"),
"OLLIE_PLAN_PATH": filepath.Join(home, ".config", "ollie", "planning"),
"OLLIE_MEMORY_PATH": filepath.Join(home, ".config", "ollie", "memory"),
}
for k, v := range defaults {
if os.Getenv(k) == "" {
os.Setenv(k, v) //nolint:errcheck
}
}
}
func runServer(sockPath, pidPath string) {
ensureEnv()
// Remove stale socket
if _, err := os.Stat(sockPath); err == nil {
os.Remove(sockPath) //nolint:errcheck