func (d *Driver) Remove() error {
	s, err := d.GetState()
	if err != nil {
		if err == ErrMachineNotExist {
			log.Infof("machine does not exist, assuming it has been removed already")
			return nil
		}
		return err
	}
	if s == state.Running {
		if err := d.Stop(); err != nil {
			return err
		}
	}

	if err := d.removeDiskImage(); err != nil {
		return err
	}

	if d.NFSShare {
		log.Infof("Remove NFS share folder must be root. Please insert root password.")
		if _, err := nfsexports.Remove("", d.nfsExportIdentifier()); err != nil {
			log.Errorf("failed removing nfs share: %s", err.Error())
		}

		if err := nfsexports.ReloadDaemon(); err != nil {
			log.Errorf("failed reload nfs daemon: %s", err.Error())
		}
	}
	return nil
}
// Setup NFS share
func (d *Driver) setupNFSShare() error {
	nfsConfig := fmt.Sprintf("/Users %s -alldirs -maproot=root", d.IPAddress)

	if _, err := nfsexports.Add("", d.nfsExportIdentifier(), nfsConfig); err != nil {
		return err
	}

	if err := nfsexports.ReloadDaemon(); err != nil {
		return err
	}

	hostIP, err := vmnet.GetNetAddr()
	if err != nil {
		return err
	}

	bootScriptName := "/var/lib/boot2docker/bootlocal.sh"
	bootScript := fmt.Sprintf("#/bin/bash\\n"+
		"sudo mkdir -p /Users\\n"+
		"sudo /usr/local/etc/init.d/nfs-client start\\n"+
		"sudo mount -t nfs -o noacl,async %s:/Users /Users\\n", hostIP)

	writeScriptCmd := fmt.Sprintf("echo -e \"%s\" | sudo tee %s && sudo chmod +x %s && %s",
		bootScript, bootScriptName, bootScriptName, bootScriptName)

	if _, err := drivers.RunSSHCommandFromDriver(d, writeScriptCmd); err != nil {
		return err
	}

	return nil
}
Exemple #3
0
func AddExport(uuid string) error {
	export := fmt.Sprintf("/Users %s -alldirs -mapall=%s:%s", "-network 192.168.64.0 -mask 255.255.255.0", os.Getenv("SUDO_UID"), os.Getenv("SUDO_GID"))
	_, err := nfsexports.Add("", "dlite", export)
	if err != nil {
		return err
	}

	return nfsexports.ReloadDaemon()
}
Exemple #4
0
func RemoveExport() error {
	_, err := nfsexports.Remove("", "dlite")
	if err != nil {
		return err
	}

	err = nfsexports.ReloadDaemon()
	if err != nil {
		return exec.Command("sudo", "nfsd", "start").Run()
	}

	return err
}
Exemple #5
0
func AddExport(uuid, share string) error {
	if share == "" {
		share = "/Users"
	}

	export := fmt.Sprintf("%s -network 192.168.64.0 -mask 255.255.255.0 -alldirs -maproot=root:wheel", share)
	_, err := nfsexports.Add("", "dlite", export)
	if err != nil {
		return err
	}

	err = nfsexports.ReloadDaemon()
	if err != nil {
		return exec.Command("sudo", "nfsd", "start").Run()
	}

	return err
}
Exemple #6
0
func AddExport(uuid, share string) error {
	if share == "" {
		share = "/Users"
	}

	export := fmt.Sprintf("%s -network 192.168.64.0 -mask 255.255.255.0 -alldirs -mapall=%s:%s", share, os.Getenv("SUDO_UID"), os.Getenv("SUDO_GID"))
	_, err := nfsexports.Add("", "dlite", export)
	if err != nil {
		return err
	}

	err = nfsexports.ReloadDaemon()
	if err != nil {
		return exec.Command("sudo", "nfsd", "start").Run()
	}

	return err
}