From 587e9b3283ef99ac8ab4ea7046dde241d4751430 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 8 Nov 2015 14:47:20 +0000 Subject: Add possibility to download a file after executing a command remotely --- rubyfy.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rubyfy.rb b/rubyfy.rb index a4de5a0..3cf411a 100755 --- a/rubyfy.rb +++ b/rubyfy.rb @@ -70,6 +70,7 @@ class Rubyfy :PRECONDITION => @conf["precondition"], :ROOT => @conf["root"], :SCRIPT => @conf["script"], + :DOWNLOAD => @conf["download"], :SERVER => server, :STATUS => :NONE, :USER => @conf["user"], @@ -109,7 +110,7 @@ class Rubyfy private - def run_command(server, user=ENV["USER"], pcond=nil, command="id", background=false, root=false, script=nil) + def run_command(server, user=ENV["USER"], pcond=nil, command="id", background=false, root=false, script=nil, download=nil) log(:VERBOSE,"#{server}::Connecting") sudo = root ? "sudo " : "" if background @@ -149,6 +150,11 @@ private return end end + + if download + log(:VERBOSE, "#{server}::Downloading #{download} to file #{server}") + ssh.scp.download!(download, server) + end end end @@ -167,7 +173,7 @@ private if File.exists?("#{server}.ignore") log(:INFO, "#{server}::Ignoring this server") else - run_command server, job[:USER], pcond, command, job[:BACKGROUND], job[:ROOT], job[:SCRIPT] + run_command server, job[:USER], pcond, command, job[:BACKGROUND], job[:ROOT], job[:SCRIPT], job[:DOWNLOAD] end job[:STATUS] = :OK end @@ -210,6 +216,7 @@ begin [ "--precondition", "-P", GetoptLong::OPTIONAL_ARGUMENT ], [ "--root", "-r", GetoptLong::OPTIONAL_ARGUMENT ], [ "--script", "-s", GetoptLong::OPTIONAL_ARGUMENT ], + [ "--download", "-D", GetoptLong::OPTIONAL_ARGUMENT ], [ "--silent", "-S", GetoptLong::OPTIONAL_ARGUMENT ], [ "--timestamp", "-t", GetoptLong::OPTIONAL_ARGUMENT ], [ "--user", "-u", GetoptLong::OPTIONAL_ARGUMENT ], -- cgit v1.2.3