Download task for Capistrano

example:

cap download_file FILE=/some/remote/file.ext DEST=/local/save/path.ext

Downloads files from the remote servers and saves them as "/local/save/path.ext-#{hostname}" locally.

code:

desc 'Download a file.  Local filenames are postfixed with the origin server hostname.'
task :download_file do
  abort "Please specify a file or directory to download (via the FILE environment variable)" if ENV["FILE"].to_s.empty?
  abort "Please specify a destination file or directory (via the DEST environment variable)" if ENV["DEST"].to_s.empty?

  file = ENV["FILE"]
  dest = "#{ENV["DEST"]}-$CAPISTRANO:HOST$"

  download file, dest
end