func init() { initDrivers() gofig.SetGlobalConfigPath(util.EtcDirPath()) gofig.SetUserConfigPath(fmt.Sprintf("%s/.rexray", gotil.HomeDir())) gofig.Register(globalRegistration()) gofig.Register(driverRegistration()) }
func NewConfig( loadGlobalConfig, loadUserConfig bool, configName, configType string) *Config { log.Debug("initializing configuration") c := &Config{ plainTextConfig: plainTextConfig{ secureConfig: secureConfig{}, }, Viper: viper.New(), GlobalFlags: &flag.FlagSet{}, AdditionalFlags: &flag.FlagSet{}, jsonMarshalStrategy: JsonMarshalSecure, } c.Viper.SetTypeByDefaultValue(true) c.Viper.SetConfigName(configName) c.Viper.SetConfigType(configType) cfgFile := fmt.Sprintf("%s.%s", configName, configType) etcRexRayFile := fmt.Sprintf("%s/%s", util.EtcDirPath(), cfgFile) usrRexRayFile := fmt.Sprintf("%s/.rexray/%s", util.HomeDir(), cfgFile) if loadGlobalConfig && util.FileExists(etcRexRayFile) { log.WithField("path", etcRexRayFile).Debug("loading global config file") if err := c.ReadConfigFile(etcRexRayFile); err != nil { log.WithFields(log.Fields{ "path": etcRexRayFile, "error": err}).Error( "error reading global config file") } } if loadUserConfig && util.FileExists(usrRexRayFile) { log.WithField("path", usrRexRayFile).Debug("loading user config file") if err := c.ReadConfigFile(usrRexRayFile); err != nil { log.WithFields(log.Fields{ "path": usrRexRayFile, "error": err}).Error( "error reading user config file") } } c.initConfigKeys() return c }
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()) } } }