forked from cloudfoundry/cflinuxfs2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_stack
More file actions
executable file
·30 lines (24 loc) · 944 Bytes
/
upload_stack
File metadata and controls
executable file
·30 lines (24 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env ruby
require "aws/s3"
STACK_NAME = ARGV[0]
FILE= "#{STACK_NAME}/rootfs.tgz"
ENVIRONMENT = ARGV.include?("--latest") ? "latest" : "dev"
AWS_ID = ENV['AMAZON_ACCESS_KEY_ID']
AWS_KEY = ENV['AMAZON_SECRET_ACCESS_KEY']
BUCKET_NAME = "cfstacks"
raise "Usage: upload <stack_name> (e.g. lucid64)" unless STACK_NAME
raise "rootfs file not found: #{FILE}" unless File.exists?(FILE)
begin
AWS::S3::Base.establish_connection!(
:access_key_id => AWS_ID,
:secret_access_key => AWS_KEY
)
AWS::S3::Bucket.find(BUCKET_NAME)
rescue AWS::S3::MissingAccessKey
puts "Access denied, please set AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY like so:"
puts "export AMAZON_ACCESS_KEY_ID=", "export AMAZON_SECRET_ACCESS_KEY="
exit
end
SIZE = File.size(FILE) / (1024 * 1024)
puts "Uploading #{FILE} (#{SIZE}M)"
AWS::S3::S3Object.store("#{STACK_NAME}.#{ENVIRONMENT}.tgz", File.open(FILE), BUCKET_NAME, :access => :public_read)