Merge branch 'nfs-per-user' of https://github.com/davedevelopment/vagrant into davedevelopment-nfs-per-user
Conflicts: plugins/hosts/arch/host.rb plugins/hosts/bsd/host.rb plugins/hosts/linux/host.rb templates/nfs/exports.erb templates/nfs/exports_freebsd.erb templates/nfs/exports_linux.erb
This commit is contained in:
commit
65ef8d2477
|
@ -26,8 +26,9 @@ module VagrantPlugins
|
|||
def nfs_export(id, ips, folders)
|
||||
output = TemplateRenderer.render('nfs/exports_linux',
|
||||
:uuid => id,
|
||||
:ips => ips,
|
||||
:folders => folders)
|
||||
:ip => ips,
|
||||
:folders => folders,
|
||||
:user => Process.uid)
|
||||
|
||||
@ui.info I18n.t("vagrant.hosts.arch.nfs_export.prepare")
|
||||
sleep 0.5
|
||||
|
|
|
@ -84,7 +84,8 @@ module VagrantPlugins
|
|||
output = TemplateRenderer.render(@nfs_exports_template,
|
||||
:uuid => id,
|
||||
:ips => ips,
|
||||
:folders => dirmap)
|
||||
:folders => dirmap,
|
||||
:user => Process.uid)
|
||||
|
||||
# The sleep ensures that the output is truly flushed before any `sudo`
|
||||
# commands are issued.
|
||||
|
@ -112,9 +113,10 @@ module VagrantPlugins
|
|||
@logger.info("Pruning invalid NFS entries...")
|
||||
|
||||
output = false
|
||||
user = Process.uid
|
||||
|
||||
File.read("/etc/exports").lines.each do |line|
|
||||
if id = line[/^# VAGRANT-BEGIN: (.+?)$/, 1]
|
||||
if id = line[/^# VAGRANT-BEGIN:( #{user})? ([A-Za-z0-9-]+?)$/, 2]
|
||||
if valid_ids.include?(id)
|
||||
@logger.debug("Valid ID: #{id}")
|
||||
else
|
||||
|
@ -142,9 +144,11 @@ module VagrantPlugins
|
|||
id = id.gsub("/", "\\/")
|
||||
id = id.gsub(".", "\\.")
|
||||
|
||||
user = Process.uid
|
||||
|
||||
# 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("sudo sed -e '/^# VAGRANT-BEGIN:\\( #{user}\\)\\? #{id}/,/^# VAGRANT-END:\\( #{user}\\)\\? #{id}/ d' -ibak /etc/exports")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,8 +37,9 @@ module VagrantPlugins
|
|||
def nfs_export(id, ips, folders)
|
||||
output = TemplateRenderer.render('nfs/exports_linux',
|
||||
:uuid => id,
|
||||
:ips => ips,
|
||||
:folders => folders)
|
||||
:ip => ip,
|
||||
:folders => folders,
|
||||
:user => Process.uid)
|
||||
|
||||
@ui.info I18n.t("vagrant.hosts.linux.nfs_export")
|
||||
sleep 0.5
|
||||
|
@ -62,9 +63,10 @@ module VagrantPlugins
|
|||
@logger.info("Pruning invalid NFS entries...")
|
||||
|
||||
output = false
|
||||
user = Process.uid
|
||||
|
||||
File.read("/etc/exports").lines.each do |line|
|
||||
if id = line[/^# VAGRANT-BEGIN: (.+?)$/, 1]
|
||||
if id = line[/^# VAGRANT-BEGIN:( #{user})? ([A-Za-z0-9-]+?)$/, 2]
|
||||
if valid_ids.include?(id)
|
||||
@logger.debug("Valid ID: #{id}")
|
||||
else
|
||||
|
@ -86,9 +88,10 @@ module VagrantPlugins
|
|||
def nfs_cleanup(id)
|
||||
return if !File.exist?("/etc/exports")
|
||||
|
||||
user = Process.uid
|
||||
# Use sed to just strip out the block of code which was inserted
|
||||
# by Vagrant
|
||||
system("sudo sed -e '/^# VAGRANT-BEGIN: #{id}/,/^# VAGRANT-END: #{id}/ d' -ibak /etc/exports")
|
||||
system("sudo sed -e '/^# VAGRANT-BEGIN:\\( #{user}\\)\\? #{id}/,/^# VAGRANT-END:\\( #{user}\\)\\? #{id}/ d' -ibak /etc/exports")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# VAGRANT-BEGIN: <%= uuid %>
|
||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||
<% folders.each do |dirs, opts| %>
|
||||
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %><% if opts[:map_uid] -%> -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%>
|
||||
<% end %>
|
||||
# VAGRANT-END: <%= uuid %>
|
||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# VAGRANT-BEGIN: <%= uuid %>
|
||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||
<% folders.each do |dirs, opts| %>
|
||||
<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ips.join(" ") %><% if opts[:map_uid] -%> -alldirs -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%>
|
||||
<% end %>
|
||||
# VAGRANT-END: <%= uuid %>
|
||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# VAGRANT-BEGIN: <%= uuid %>
|
||||
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
|
||||
<% ips.each do |ip| %>
|
||||
<% folders.each do |name, opts| %>
|
||||
"<%= opts[:hostpath] %>" <%= ip %>(rw,no_subtree_check,all_squash<% if opts[:map_uid] %>,anonuid=<%= opts[:map_uid] %><% end %><% if opts[:map_gid] %>,anongid=<%= opts[:map_gid] %><% end %>,fsid=<%= opts[:uuid] %>)
|
||||
<% end %>
|
||||
<% end %>
|
||||
# VAGRANT-END: <%= uuid %>
|
||||
# VAGRANT-END: <%= user %> <%= uuid %>
|
||||
|
|
Loading…
Reference in New Issue