Class: Pairzone::Shell
- Inherits:
-
Object
- Object
- Pairzone::Shell
- Defined in:
- lib/pairzone/shell.rb
Instance Method Summary collapse
- #git(cmd) ⇒ Object
-
#initialize(identity) ⇒ Shell
constructor
A new instance of Shell.
- #remote(ip, command) ⇒ Object
- #remote_log(ip, msg) ⇒ Object
- #run(cmd) ⇒ Object
Constructor Details
#initialize(identity) ⇒ Shell
Returns a new instance of Shell.
3 4 5 |
# File 'lib/pairzone/shell.rb', line 3 def initialize(identity) @identity = identity end |
Instance Method Details
#git(cmd) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/pairzone/shell.rb', line 14 def git(cmd) git_ssh = Tempfile.new('git_ssh') git_ssh.puts %{#!/bin/bash\nexec ssh -i #{@identity} $1 "bash --login -c '$2'"} git_ssh.close `chmod +x #{git_ssh.path}` run "GIT_SSH='#{git_ssh.path}' #{cmd}" end |
#remote(ip, command) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/pairzone/shell.rb', line 22 def remote(ip, command) output = '' remote_log(ip, command) Net::SSH.start(ip, 'pairzone', :auth_methods => ['publickey'], :keys => [@identity]) do |ssh| output = (ssh.exec!("bash --login -c '#{command}'") || "").strip end remote_log(ip, "#=> #{output}") return output end |