Ejemplo n.º 1
0
func uninstallKBFS(g *libkb.GlobalContext) error {
	err := uninstallKBFSServices(g, g.Env.GetRunMode())
	if err != nil {
		return err
	}

	mountPath := kbfsMountPath(g.Env.GetRunMode())
	if _, err := os.Stat(mountPath); os.IsNotExist(err) {
		return nil
	}
	mounted, err := mounter.IsMounted(g, mountPath)
	if err != nil {
		return err
	}
	if mounted {
		err = mounter.Unmount(g, mountPath, false)
		if err != nil {
			return err
		}
	}
	empty, err := libkb.IsDirEmpty(mountPath)
	if err != nil {
		return err
	}
	if !empty {
		return fmt.Errorf("Mount has files after unmounting: %s", mountPath)
	}
	return trashDir(g, mountPath)
}
Ejemplo n.º 2
0
func uninstallKBFS(g *libkb.GlobalContext) error {
	err := uninstallKBFSServices(g, g.Env.GetRunMode())
	if err != nil {
		return err
	}

	mountPath := kbfsMountPath(g.Env.GetRunMode())
	if _, err := os.Stat(mountPath); os.IsNotExist(err) {
		return nil
	}
	g.Log.Debug("Checking if mounted: %s", mountPath)
	mounted, err := mounter.IsMounted(g, mountPath)
	if err != nil {
		return err
	}
	g.Log.Debug("Mounted: %s", mounted)
	if mounted {
		err = mounter.Unmount(g, mountPath, false)
		if err != nil {
			return err
		}
	}
	empty, err := libkb.IsDirEmpty(mountPath)
	if err != nil {
		return err
	}
	if !empty {
		return fmt.Errorf("Mount has files after unmounting: %s", mountPath)
	}
	// TODO: We should remove the mountPath via trashDir(g, mountPath) but given
	// permissions of /keybase we'll need the priviledged tool to do it instead.
	return nil
}
Ejemplo n.º 3
0
// UninstallKBFS uninstalls all KBFS services and unmounts the directory
func UninstallKBFS(runMode libkb.RunMode, mountDir string, forceUnmount bool, log Log) error {
	err := uninstallKBFSServices(runMode, log)
	if err != nil {
		return err
	}

	if _, serr := os.Stat(mountDir); os.IsNotExist(serr) {
		return nil
	}
	log.Debug("Checking if mounted: %s", mountDir)
	mounted, err := mounter.IsMounted(mountDir, log)
	if err != nil {
		return err
	}
	log.Debug("Mounted: %s", strconv.FormatBool(mounted))
	if mounted {
		err = mounter.Unmount(mountDir, forceUnmount, log)
		if err != nil {
			return err
		}
	}
	empty, err := libkb.IsDirEmpty(mountDir)
	if err != nil {
		return err
	}
	if !empty {
		return fmt.Errorf("Mount has files after unmounting: %s", mountDir)
	}
	// TODO: We should remove the mountPath via trashDir(g, mountPath) but given
	// permissions of /keybase we'll need the privileged tool to do it instead.
	return nil
}