Revert "Always clear NFS exports for the VM booting [GH-529]"

This reverts commit 70705d2861.
This commit is contained in:
Mitchell Hashimoto 2012-01-12 18:23:30 -08:00
parent 9030496afd
commit 7dc5f8ca80
3 changed files with 21 additions and 14 deletions

View File

@ -60,19 +60,19 @@ module Vagrant
# task. # task.
def extract_folders def extract_folders
# Load the NFS enabled shared folders # Load the NFS enabled shared folders
@folders = {} @folders = @env[:vm].config.vm.shared_folders.inject({}) do |acc, data|
@env[:vm].config.vm.shared_folders.each do |name, opts| key, opts = data
if opts[:nfs] if opts[:nfs]
# Duplicate the options, set the hostpath, and set disabled on the original # Duplicate the options, set the hostpath, and set disabled on the original
# options so the ShareFolders middleware doesn't try to mount it. # options so the ShareFolders middleware doesn't try to mount it.
opts = opts.dup acc[key] = opts.dup
opts[:hostpath] = File.expand_path(opts[:hostpath], @env[:root_path]) acc[key][:hostpath] = File.expand_path(opts[:hostpath], @env[:root_path])
opts[:disabled] = true opts[:disabled] = true
@folders[key] = opts
end end
end
@folders acc
end
end end
# Prepares the settings for the NFS folders, such as setting the # Prepares the settings for the NFS folders, such as setting the

View File

@ -56,10 +56,14 @@ module Vagrant
return if !File.exist?("/etc/exports") return if !File.exist?("/etc/exports")
retryable(:tries => 10, :on => TypeError) do retryable(:tries => 10, :on => TypeError) do
# Use sed to just strip out the block of code which was inserted system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{id}' > /dev/null 2>&1")
# by Vagrant, and restart NFS.
system("sudo sed -e '/^# VAGRANT-BEGIN: #{id}/,/^# VAGRANT-END: #{id}/ d' -ibak /etc/exports") if $?.to_i == 0
system(@nfs_restart_command) # Use sed to just strip out the block of code which was inserted
# by Vagrant, and restart NFS.
system("sudo sed -e '/^# VAGRANT-BEGIN: #{id}/,/^# VAGRANT-END: #{id}/ d' -ibak /etc/exports")
system(@nfs_restart_command)
end
end end
end end
end end

View File

@ -52,10 +52,13 @@ module Vagrant
def nfs_cleanup(id) def nfs_cleanup(id)
return if !File.exist?("/etc/exports") return if !File.exist?("/etc/exports")
system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{id}' > /dev/null 2>&1")
# Use sed to just strip out the block of code which was inserted if $?.to_i == 0
# by Vagrant # Use sed to just strip out the block of code which was inserted
system("sudo sed -e '/^# VAGRANT-BEGIN: #{id}/,/^# VAGRANT-END: #{id}/ d' -ibak /etc/exports") # by Vagrant
system("sudo sed -e '/^# VAGRANT-BEGIN: #{id}/,/^# VAGRANT-END: #{id}/ d' -ibak /etc/exports")
end
end end
end end
end end