Method: CloudRunner::Ssh#run_script

Defined in:
lib/cloud_runner/ssh.rb

#run_script(local_path, out, err, opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cloud_runner/ssh.rb', line 19

def run_script(local_path, out, err, opts={})
  ssh_opts = DEFAULT_OPTIONS.clone.merge(
    :keys => [@ssh_key.private_path],
    :host_key => "ssh-#{@ssh_key.type}",
    :logger => opts[:ssh_logger] || StringIO.new,
    :verbose => :debug,
  )

  # Assume the worst
  @exit_code = 1

  Net::SSH.start(@host, @user, ssh_opts) do |ssh|
    ssh.scp.upload!(local_path, remote_path)
    ssh.exec!("chmod +x #{remote_path}")
    full_exec(ssh, remote_path, out, err)
  end

  @exit_code
end