summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <rubyfy@dev.buetow.org>2015-11-08 14:47:20 +0000
committerPaul Buetow <rubyfy@dev.buetow.org>2015-11-08 14:47:20 +0000
commit587e9b3283ef99ac8ab4ea7046dde241d4751430 (patch)
tree24c93ce1da2f35d5206ee53827f026f4b09cc54f
parentbc16abddf658210932b58a41fe8ee5c5d4a9f3d7 (diff)
Add possibility to download a file after executing a command remotely
-rwxr-xr-xrubyfy.rb11
1 files 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 ],