Sha256: c0c5a558e1df9f0d03f6702bdfea5959300e0474dd0183889c645558543474b8
Contents?: true
Size: 918 Bytes
Versions: 1
Compression:
Stored size: 918 Bytes
Contents
module Pairzone class Shell def initialize(identity) @identity = identity end def run(cmd) Logger.debug(cmd) output = `#{cmd}` Logger.debug("#=> #{output}") output end 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 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 def remote_log(ip, msg) Logger.debug("<%= color('[pairzone@#{ip}]:', CYAN + BOLD) %> #{msg}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pairzone-0.0.1 | lib/pairzone/shell.rb |