Example #1
0
func (x *cmdShell) Execute(args []string) error {
	shellType := x.Positional.ShellType
	if shellType == "classic" {
		if !classic.Enabled() {
			return fmt.Errorf(i18n.G(`Classic dimension disabled on this system.
Use "sudo snappy enable-classic" to enable it.`))
		}

		// we need to re-exec if we do not run as root
		if os.Getuid() != 0 {
			if err := reexecWithSudo(); err != nil {
				return err
			}
		}

		fmt.Println(i18n.G(`Entering classic dimension`))
		fmt.Println(i18n.G(`

The home directory is shared between snappy and the classic dimension.
Run "exit" to leave the classic shell.
`))
		return classic.RunShell()
	}

	return fmt.Errorf(i18n.G("unsupported shell %v"), shellType)
}
Example #2
0
func (x *cmdDestroyClassic) doDisable() (err error) {
	if !classic.Enabled() {
		return fmt.Errorf(i18n.G("Classic dimension is not enabled."))
	}

	if err := classic.Destroy(); err != nil {
		return err
	}

	fmt.Println(i18n.G(`Classic dimension destroyed on this snappy system.`))
	return nil
}
Example #3
0
func (x *cmdEnableClassic) doEnable() (err error) {
	if classic.Enabled() {
		return fmt.Errorf(i18n.G("Classic dimension is already enabled."))
	}

	pbar := progress.NewTextProgress()
	if err := classic.Create(pbar); err != nil {
		return err
	}

	fmt.Println(i18n.G(`Classic dimension enabled on this snappy system.
Use “snappy shell classic” to enter the classic dimension.`))
	return nil
}