diff --git a/cmd/ctrld/cli.go b/cmd/ctrld/cli.go index 17baa8c..ab0fc2f 100644 --- a/cmd/ctrld/cli.go +++ b/cmd/ctrld/cli.go @@ -187,7 +187,6 @@ 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 @@ -196,15 +195,15 @@ func initCLI() { writeDefaultConfig := !noConfigStart && configBase64 == "" if configPath == "" && writeDefaultConfig { defaultConfigFile = filepath.Join(dir, defaultConfigFile) - readConfigFile(writeDefaultConfig && (cdUID == "" || !isWindows)) + readConfigFile(writeDefaultConfig && cdUID == "") } sc.Arguments = append(sc.Arguments, "--homedir="+dir) } + processCDFlags() // 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 isWindows { - processCDFlags() + if runtime.GOOS == "windows" { if configPath == "" { sc.Arguments = append(sc.Arguments, "--config="+defaultConfigFile) }