Beispiel #1
0
func createEnvFile() {
	f, err := os.OpenFile(
		util.EtcFilePath(util.EnvFileName), 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())
	}
}
Beispiel #2
0
func uninstall(pkgManager bool) {
	checkOpPerms("uninstalled")

	_, _, binFile := util.GetThisPathParts()

	// 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("binFile", binFile).Debug("is this a managed file?")
		var pkgName string
		if isRpmInstall(binFile, &pkgName) {
			uninstallRpm(pkgName)
			return
		} else if isDebInstall(binFile, &pkgName) {
			uninstallDeb(pkgName)
			return
		}
	}

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

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

	os.RemoveAll(util.EtcDirPath())
	os.RemoveAll(util.RunDirPath())
	os.RemoveAll(util.LibDirPath())
	os.RemoveAll(util.LogDirPath())

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