X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsconfig%2Ffileconfig.go;h=efe94bf0c06ddb58fc39c1355ae478ed9abac7be;hb=3f1c6dbe6b6;hp=2358a31dd2ab347056dfd16325e9adfc404553e8;hpb=1c6af6236743aa0963d4919b5ef42627efa6aca7;p=src%2Fxds%2Fxds-agent.git diff --git a/lib/xdsconfig/fileconfig.go b/lib/xdsconfig/fileconfig.go index 2358a31..efe94bf 100644 --- a/lib/xdsconfig/fileconfig.go +++ b/lib/xdsconfig/fileconfig.go @@ -40,14 +40,21 @@ func updateConfigFromFile(c *Config, confFile string) (*FileConfig, error) { if usr, err := user.Current(); err == nil { searchIn = append(searchIn, path.Join(usr.HomeDir, ".xds", "agent", "agent-config.json")) } - cwd, err := os.Getwd() - if err == nil { - searchIn = append(searchIn, path.Join(cwd, "agent-config.json")) - } - exePath, err := filepath.Abs(filepath.Dir(os.Args[0])) + + searchIn = append(searchIn, "/etc/xds-agent/agent-config.json") + + exePath := os.Args[0] + ee, _ := os.Executable() + exeAbsPath, err := filepath.Abs(ee) if err == nil { - searchIn = append(searchIn, path.Join(exePath, "agent-config.json")) + exePath, err = filepath.EvalSymlinks(exeAbsPath) + if err == nil { + exePath = filepath.Dir(ee) + } else { + exePath = filepath.Dir(exeAbsPath) + } } + searchIn = append(searchIn, path.Join(exePath, "agent-config.json")) var cFile *string for _, p := range searchIn {