Exemplo n.º 1
0
func getOpenvpnPath() (pth string) {
	switch runtime.GOOS {
	case "windows":
		pth = filepath.Join(utils.GetRootDir(), "openvpn",
			utils.GetWinArch(), "openvpn.exe")
		if _, err := os.Stat(pth); os.IsNotExist(err) {
			pth = filepath.Join(utils.GetRootDir(), "..",
				"openvpn_win", utils.GetWinArch(), "openvpn.exe")
		}
	case "darwin":
		pth = filepath.Join(string(os.PathSeparator), "usr", "local",
			"bin", "pritunl-openvpn")
		if _, err := os.Stat(pth); os.IsNotExist(err) {
			pth = filepath.Join(utils.GetRootDir(), "..",
				"openvpn_osx", "openvpn")
		}
	case "linux":
		pth = "openvpn"
	default:
		panic("profile: Not implemented")
	}

	return
}
Exemplo n.º 2
0
// Watch for Pritunl.app removal for next 10 minutes and uninstall if missing
func CheckAndCleanWatch() {
	root := utils.GetRootDir()
	if runtime.GOOS != "darwin" || root != "/usr/local/bin" {
		return
	}

	go func() {
		for i := 0; i < 30; i++ {
			time.Sleep(10 * time.Second)

			err := CheckAndClean()
			if err != nil {
				logrus.WithFields(logrus.Fields{
					"error": err,
				}).Error("autoclean: Failed to run check and clean")
				return
			}
		}
	}()
}
Exemplo n.º 3
0
// Check for Pritunl.app and uninstall if missing
func CheckAndClean() (err error) {
	root := utils.GetRootDir()
	if runtime.GOOS != "darwin" || root != "/usr/local/bin" {
		return
	}

	path := filepath.Join(pathSep, "Applications", "Pritunl.app")
	if _, e := os.Stat(path); !os.IsNotExist(e) {
		return
	}

	err = clean()
	if err != nil {
		return
	}

	os.Exit(0)

	return
}