Sha256: 65bcba57c7683e55cb909ac182e45781440ca391ac3d119dbc87dac79db68f49

Contents?: true

Size: 1.36 KB

Versions: 21

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'aws/s3'

include AWS::S3

USER_DATA = `wget -q -O - http://169.254.169.254/latest/user-data`.split("\n")

bucket_name = 'rhoconnect'
channel     = ARGV[0]

exit if ARGV.length != 1

def cmd(cmd)
  puts cmd
  system(cmd)
end #cmd

def get_access_keys
  access_key        = USER_DATA[0].to_s.strip
  secret_access_key = USER_DATA[1].to_s.strip
  keys = { :access_key_id => access_key, :secret_access_key => secret_access_key}
end

AWS::S3::Base.establish_connection!(get_access_keys)
objects = Bucket.objects(bucket_name, :prefix => channel)
files = []
objects.each { |obj| files << "#{obj.key}" }

# Remove the files before downloading new in case they already exist
cmd "rm -rf #{channel}" if File.directory? channel
cmd "rm -f #{channel}/SHA1/checksum" if File.exists?("#{channel}/SHA1/checksum")

puts "Downloading S3 files"
files.each do |file|
  cmd = "wget -qx -t 3 -P #{channel} \"http://s3.amazonaws.com/#{bucket_name}/#{file}\""
  puts cmd
  puts "Failed to download #{file}" unless system(cmd)
end

# The download increases the depth of the files by two folders.
# Remove exess directory levels.
cmd "mv -f #{channel}/s3.amazonaws.com/#{bucket_name}/#{channel}/* #{channel}"
cmd "rm -rf #{channel}/s3.amazonaws.com"

# Pull the SHA1 checksum and hash out
cmd "mv -f #{channel}/SHA1/sha1_hash ./old_sha1_hash"
cmd "rm -rf #{channel}/SHA1"

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 installer/utils/download_from_s3.rb
rhoconnect-7.5.1 installer/utils/download_from_s3.rb
rhoconnect-7.4.1 installer/utils/download_from_s3.rb
rhoconnect-7.1.17 installer/utils/download_from_s3.rb
rhoconnect-6.2.0 installer/utils/download_from_s3.rb
rhoconnect-6.0.11 installer/utils/download_from_s3.rb
rhoconnect-5.5.18 installer/utils/download_from_s3.rb
rhoconnect-5.5.17 installer/utils/download_from_s3.rb
rhoconnect-5.5.15 installer/utils/download_from_s3.rb
rhoconnect-5.5.0.22 installer/utils/download_from_s3.rb
rhoconnect-5.5.2 installer/utils/download_from_s3.rb
rhoconnect-5.5.0.7 installer/utils/download_from_s3.rb
rhoconnect-5.5.0.3 installer/utils/download_from_s3.rb
rhoconnect-5.5.0 installer/utils/download_from_s3.rb
rhoconnect-5.1.1 installer/utils/download_from_s3.rb
rhoconnect-4.0.4 installer/utils/download_from_s3.rb
rhoconnect-4.0.3 installer/utils/download_from_s3.rb
rhoconnect-4.0.2 installer/utils/download_from_s3.rb
rhoconnect-4.0.1 installer/utils/download_from_s3.rb
rhoconnect-4.0.0 installer/utils/download_from_s3.rb