Check for redir before forwarding ports

Make a system call out to `which` to see if redir exists on the PATH
before trying to forward ports.  Raises a VagrantError if it does not.
This commit is contained in:
Darrell Hamilton 2013-07-14 22:42:49 -07:00
parent 14c1ebfd7c
commit ad41c445a4
3 changed files with 29 additions and 14 deletions

View file

@ -26,7 +26,12 @@ module Vagrant
if @env[:forwarded_ports].any?
env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
if redir_installed?
forward_ports
else
raise Errors::RedirNotInstalled
end
end
end
@ -79,6 +84,10 @@ module Vagrant
pid_file.write(redir_pid)
end
end
def redir_installed?
system "sudo which redir"
end
end
end
end

View file

@ -17,6 +17,9 @@ module Vagrant
class IncompatibleBox < Vagrant::Errors::VagrantError
error_key(:lxc_incompatible_box)
end
class RedirNotInstalled < Vagrant::Errors::VagrantError
error_key(:lxc_redir_not_installed)
end
end
end
end

View file

@ -40,3 +40,6 @@ en:
lxc_template_file_missing: |-
The template file used for creating the container was not found for %{name}
box.
lxc_redir_not_installed: |-
`redir` is not installed or is not accessible on the PATH.