示例#1
0
文件: installer.go 项目: akutz/rexray
func createEnvFile() {
	f, err := os.OpenFile(util.EnvFilePath(), os.O_CREATE|os.O_WRONLY, 0644)
	if err != nil {
		panic(err)
	}
	defer f.Close()
	if util.IsPrefixed() {
		f.WriteString("REXRAY_HOME=")
		f.WriteString(util.GetPrefix())
	}
}
示例#2
0
文件: installer.go 项目: akutz/rexray
func uninstall(pkgManager bool) {
	checkOpPerms("uninstalled")

	binFilePath := util.BinFilePath

	// if the uninstall command was executed manually we should check to see
	// if this file is owned by a package manager and remove it that way if so
	if !pkgManager {
		log.WithField("binFilePath", binFilePath).Debug(
			"is this a managed file?")
		var pkgName string
		if isRpmInstall(&pkgName) {
			uninstallRpm(pkgName)
			return
		} else if isDebInstall(&pkgName) {
			uninstallDeb(pkgName)
			return
		}
	}

	func() {
		defer func() {
			recover()
		}()
		stop()
	}()

	switch getInitSystemType() {
	case SystemD:
		uninstallSystemD()
	case UpdateRcD:
		uninstallUpdateRcd()
	case ChkConfig:
		uninstallChkConfig()
	}

	if !pkgManager {
		os.Remove(binFilePath)
		if util.IsPrefixed() {
			os.RemoveAll(util.GetPrefix())
		}
	}
}