package config import ( "fmt" "os" "path" "path/filepath" ocncc "git.loafle.net/overflow/commons-go/noauthprobe/constants" ocpcc "git.loafle.net/overflow/commons-go/probe/constants" "log" "os/user" ) var ( rootDir string ) func init() { exePath, err := os.Executable() if err != nil { panic(err) } binDir := filepath.Dir(exePath) if "debug" == filepath.Base(exePath) { rootDir = path.Join(binDir, "_build") } else if "/tmp" == binDir { usr, err := user.Current() if err != nil { log.Fatal(err) } rootDir = path.Join(usr.HomeDir, "/go/src/git.loafle.net/overflow/probe/_build") } else { rootDir = filepath.Clean(fmt.Sprintf("%s/..", binDir)) } } func RootDir() string { return rootDir } func BinDir() string { return path.Join(RootDir(), ocpcc.PathBin) } func ConfigDir() string { return path.Join(RootDir(), ocpcc.PathConfig) } func JREDir() string { return path.Join(RootDir(), ocpcc.PathJRE) } func JavaBinPath() string { return path.Join(JREDir(), "bin", "java") } func LogsDir() string { return path.Join(RootDir(), ocpcc.PathLogs) } func PIDDir() string { return path.Join(RootDir(), ocpcc.PathPID) } func ProbeConfigFilePath() string { return path.Join(BinDir(), ocpcc.ConfigFileName) } func ProbeLoggingConfigFilePath() string { return path.Join(BinDir(), ocpcc.LoggingConfigFileName) } func NoAuthProbeConfigFilePath() string { return path.Join(BinDir(), ocncc.ConfigFileName) }