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:
parent
14c1ebfd7c
commit
ad41c445a4
3 changed files with 29 additions and 14 deletions
|
@ -26,7 +26,12 @@ module Vagrant
|
||||||
|
|
||||||
if @env[:forwarded_ports].any?
|
if @env[:forwarded_ports].any?
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
|
env[:ui].info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
|
||||||
|
|
||||||
|
if redir_installed?
|
||||||
forward_ports
|
forward_ports
|
||||||
|
else
|
||||||
|
raise Errors::RedirNotInstalled
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,6 +84,10 @@ module Vagrant
|
||||||
pid_file.write(redir_pid)
|
pid_file.write(redir_pid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def redir_installed?
|
||||||
|
system "sudo which redir"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,9 @@ module Vagrant
|
||||||
class IncompatibleBox < Vagrant::Errors::VagrantError
|
class IncompatibleBox < Vagrant::Errors::VagrantError
|
||||||
error_key(:lxc_incompatible_box)
|
error_key(:lxc_incompatible_box)
|
||||||
end
|
end
|
||||||
|
class RedirNotInstalled < Vagrant::Errors::VagrantError
|
||||||
|
error_key(:lxc_redir_not_installed)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,3 +40,6 @@ en:
|
||||||
lxc_template_file_missing: |-
|
lxc_template_file_missing: |-
|
||||||
The template file used for creating the container was not found for %{name}
|
The template file used for creating the container was not found for %{name}
|
||||||
box.
|
box.
|
||||||
|
|
||||||
|
lxc_redir_not_installed: |-
|
||||||
|
`redir` is not installed or is not accessible on the PATH.
|
||||||
|
|
Loading…
Reference in a new issue