Skip to content

Instantly share code, notes, and snippets.

@pixie79
Created February 13, 2013 12:22
Show Gist options
  • Save pixie79/4944219 to your computer and use it in GitHub Desktop.
Save pixie79/4944219 to your computer and use it in GitHub Desktop.
This file works with from_cloud.rb and allows you to download any missing or complete any partially downloaded cloud files.
#!/usr/bin/env ruby
require 'rubygems'
require 'cloudfiles'
guest = ARGV[0]
path = ARGV[1] ||= "/opt/dump"
container = ARGV[2] ||= "eudc"
def list_file(guest, container, cf, path)
cfcontainer = cf.container("#{container}")
cloud_files = cfcontainer.objects
cmd = "curl -C - -o #{path}/#{guest} -H 'X-Auth-Token: #{cf.authtoken}' https://#{cf.storagehost}/v1/MossoCloudFS_d6b9d71d-fd4c-44d6-9a7e-6578cad25d3a/#{container}/#{guest}"
system(cmd)
end
if !(guest)
puts "No guest code entered"
exit 1
end
unless File.directory?(path)
puts "Dump Directory #{path} does not exist!"
exit 1
end
cf = CloudFiles::Connection.new(:username => "XXXXX", :api_key => "XXXXX", :auth_url => CloudFiles::AUTH_UK)
list_file(guest, container, cf, path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment