From 14ddb1faa09a37c4018a59a28ff5f81c1d0cb5c8 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 21 Jan 2023 00:08:02 +0700 Subject: [PATCH] cmd/ctrld: ensure writing config message is printed on non-Windows --- cmd/ctrld/cli.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/ctrld/cli.go b/cmd/ctrld/cli.go index 0235b1c..17baa8c 100644 --- a/cmd/ctrld/cli.go +++ b/cmd/ctrld/cli.go @@ -187,6 +187,7 @@ func initCLI() { osArgs = os.Args[3:] } sc.Arguments = append([]string{"run"}, osArgs...) + isWindows := runtime.GOOS == "windows" if dir, err := os.UserHomeDir(); err == nil { // WorkingDirectory is not supported on Windows. sc.WorkingDirectory = dir @@ -195,14 +196,14 @@ func initCLI() { writeDefaultConfig := !noConfigStart && configBase64 == "" if configPath == "" && writeDefaultConfig { defaultConfigFile = filepath.Join(dir, defaultConfigFile) - readConfigFile(writeDefaultConfig && cdUID == "") + readConfigFile(writeDefaultConfig && (cdUID == "" || !isWindows)) } sc.Arguments = append(sc.Arguments, "--homedir="+dir) } // On Windows, the service will be run as SYSTEM, so if ctrld start as Admin, // the user home dir is different, so pass specific arguments that relevant here. - if runtime.GOOS == "windows" { + if isWindows { processCDFlags() if configPath == "" { sc.Arguments = append(sc.Arguments, "--config="+defaultConfigFile)