lib/bebox/vagrant_helper.rb in bebox-0.1.0 vs lib/bebox/vagrant_helper.rb in bebox-0.1.1

- old
+ new

@@ -41,12 +41,12 @@ `sudo cp #{local_hosts_path}/hosts #{hosts_backup_file}` unless File.exist?(hosts_backup_file) end # Add the vagrant hosts to the local hosts file def add_to_local_hosts(node) - host_command = `echo '#{node.ip} #{node.hostname} # Added by bebox' >> #{local_hosts_path}/hosts` - host_command if (file_content_trimmed("#{local_hosts_path}/hosts") =~ /#{node.ip}\s+#{node.hostname}/) + host_command = "sudo echo '#{node.ip} #{node.hostname} # Added by bebox' >> #{local_hosts_path}/hosts" + `#{host_command}` unless (file_content_trimmed("#{local_hosts_path}/hosts") =~ /#{node.ip}\s+#{node.hostname}/) end # Obtain the local hosts file for the OS def local_hosts_path RUBY_PLATFORM =~ /darwin/ ? '/private/etc' : '/etc' @@ -62,16 +62,18 @@ # Add the boxes to vagrant for each node def add_vagrant_node(project_name, vagrant_box_base, node) already_installed_boxes = installed_vagrant_box_names(node) box_name = "#{project_name}-#{node.hostname}" - info "Adding server to vagrant: #{node.hostname}..." + info "Adding server to vagrant: #{node.hostname}" + info "Please enter the network interface number if asked, and wait until the machine is up." `cd #{node.project_root} && vagrant box add #{box_name} #{vagrant_box_base}` unless already_installed_boxes.include? box_name end # Up the vagrant boxes in Vagrantfile def self.up_vagrant_nodes(project_root) - `cd #{project_root} && vagrant up --provision` + pid = fork {exec("cd #{project_root} && vagrant up --provision")} + Process.wait(pid) end # Halt the vagrant boxes running def self.halt_vagrant_nodes(project_root) `cd #{project_root} && vagrant halt` \ No newline at end of file