chmod and execute shell provisioning script in a single session

This commit is contained in:
Mitchell Hashimoto 2011-01-25 11:43:25 -08:00
parent 5a2dc84fca
commit 1e931eaba6
2 changed files with 7 additions and 6 deletions

View File

@ -31,16 +31,16 @@ module Vagrant
end
def provision!
commands = ["chmod +x #{config.upload_path}", config.upload_path]
# Upload the script to the VM
vm.ssh.upload!(config.expanded_path.to_s, config.upload_path)
# Execute it with sudo
vm.ssh.execute do |ssh|
ssh.sudo!("chmod +x #{config.upload_path}")
ssh.sudo!(config.upload_path) do |ch, type, data|
ssh.sudo!(commands) do |ch, type, data|
if type == :exit_status
ssh.check_exit_status(data, config.upload_path)
ssh.check_exit_status(data, commands)
else
env.ui.info(data)
end

View File

@ -56,10 +56,11 @@ class ShellProvisionerTest < Test::Unit::TestCase
end
should "upload the file, chmod, then execute it" do
commands = ["chmod +x #{@config.upload_path}", @config.upload_path]
p_seq = sequence("provisioning")
@action.vm.ssh.expects(:upload!).with(@config.expanded_path.to_s, @config.upload_path).in_sequence(p_seq)
@ssh.expects(:sudo!).with("chmod +x #{@config.upload_path}").in_sequence(p_seq)
@ssh.expects(:sudo!).with(@config.upload_path).in_sequence(p_seq)
@ssh.expects(:sudo!).with(commands).in_sequence(p_seq)
@action.provision!
end