Sha256: d36ce4d38ba96e14acf6cb8da7f1b61814152a35dfb420529d1ff362e1e34803

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

Jaysus::Local.store_dir = File.expand_path("~/.kalipso")
Jaysus::Local.store_dir.mkpath unless Jaysus::Local.store_dir.exist?

token_path = Jaysus::Local.store_dir.join('token')

if token_path.exist?
  token = token_path.read
else
  email = ask("Enter your email:  ") { |q| q.echo = true }
  password = ask("Enter your password:  ") { |q| q.echo = "*" }
  token = ActiveSupport::JSON.decode(RestClient.get("http://#{CGI.escape(email)}:#{CGI.escape(password)}@oncalypso.com/api/v1/users.json"))['token']
  token_path.open('w') do |file|
    file.write token
  end
end

Jaysus::Remote.base_url = "http://#{token}:x@oncalypso.com/api/v1"

if !Jaysus::Local.store_dir.join('keys').exist?
  key_dir = Jaysus::Local.store_dir.join('keys')
  key_dir.mkpath unless key_dir.exist?
  key_path = key_dir.join('id_rsa')
  public_key_path = key_dir.join('id_rsa.pub')
  puts "generating and uploading public key"
  `ssh-keygen -N '' -t rsa -f #{key_path.to_s.strip}`
  Kalipso::PublicKey::Remote.create(:key => public_key_path.read)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kalipso-0.1.8 lib/kalipso/cli_init.rb