diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 26cde0ed8..7e1326408 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -40,7 +40,7 @@ module Vagrant # The sleep ensures that the output is truly flushed before any `sudo` # commands are issued. - @ui.info I18n.t("vagrant.hosts.bsd.nfs_export.prepare") + @ui.info I18n.t("vagrant.hosts.bsd.nfs_export") sleep 0.5 # First, clean up the old entry @@ -60,11 +60,19 @@ module Vagrant def nfs_prune(valid_ids) @logger.info("Pruning invalid NFS entries...") + output = false + File.read("/etc/exports").lines.each do |line| if line =~ /^# VAGRANT-BEGIN: (.+?)$/ if valid_ids.include?($1.to_s) @logger.debug("Valid ID: #{$1.to_s}") else + if !output + # We want to warn the user but we only want to output once + @ui.info I18n.t("vagrant.hosts.bsd.nfs_prune") + output = true + end + @logger.info("Invalid ID, pruning: #{$1.to_s}") nfs_cleanup($1.to_s) end diff --git a/lib/vagrant/hosts/linux.rb b/lib/vagrant/hosts/linux.rb index 59784dd40..5b03db77b 100644 --- a/lib/vagrant/hosts/linux.rb +++ b/lib/vagrant/hosts/linux.rb @@ -39,7 +39,7 @@ module Vagrant :ip => ip, :folders => folders) - @ui.info I18n.t("vagrant.hosts.linux.nfs_export.prepare") + @ui.info I18n.t("vagrant.hosts.linux.nfs_export") sleep 0.5 nfs_cleanup(id) @@ -58,11 +58,19 @@ module Vagrant def nfs_prune(valid_ids) @logger.info("Pruning invalid NFS entries...") + output = false + File.read("/etc/exports").lines.each do |line| if line =~ /^# VAGRANT-BEGIN: (.+?)$/ if valid_ids.include?($1.to_s) @logger.debug("Valid ID: #{$1.to_s}") else + if !output + # We want to warn the user but we only want to output once + @ui.info I18n.t("vagrant.hosts.linux.nfs_prune") + output = true + end + @logger.info("Invalid ID, pruning: #{$1.to_s}") nfs_cleanup($1.to_s) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 73b02b0fe..cac2cb01c 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -541,12 +541,15 @@ en: hosts: bsd: - nfs_export: - prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..." + nfs_export: |- + Preparing to edit /etc/exports. Administrator privileges will be required... + nfs_prune: |- + Pruning invalid NFS exports. Administrator privileges will be required... linux: - nfs_export: - prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..." - + nfs_export: |- + Preparing to edit /etc/exports. Administrator privileges will be required... + nfs_prune: |- + Pruning invalid NFS exports. Administrator privileges will be required... arch: nfs_export: prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..."