// 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
}
示例#2
0
文件: hosts.go 项目: kylebrandt/dlite
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()
}
示例#3
0
文件: hosts.go 项目: goist/dlite
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
}
示例#4
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
}