Install writes a fully commented sample env file when no config exists

This commit is contained in:
mram
2026-09-21 08:48:51 +02:00
parent dd3187f951
commit cf48796183
6 changed files with 145 additions and 18 deletions
+10 -4
View File
@@ -172,10 +172,16 @@ func Install(configPath string, copyBin bool) error {
}
}
}
// A service has no console: without LOG_FILE the output vanishes, so
// the installed env file defaults to logging into ProgramData. An
// existing LOG_FILE setting is left alone.
if err := ensureLogFile(targetCfg, filepath.Join(dataDir, "gpu-turnstile.log")); err != nil {
// A service has no console: without LOG_FILE the output vanishes.
// With no config at all, install a fully commented sample covering
// every setting (only LOG_FILE active); an existing config just gets
// a LOG_FILE line appended if it has none.
logPath := filepath.Join(dataDir, "gpu-turnstile.log")
if _, statErr := os.Stat(targetCfg); os.IsNotExist(statErr) {
if err := os.WriteFile(targetCfg, []byte(config.SampleEnv(logPath)), 0o644); err != nil {
return fmt.Errorf("write %s: %w", targetCfg, err)
}
} else if err := ensureLogFile(targetCfg, logPath); err != nil {
return err
}
configPath = targetCfg