railshoster 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.textile +5 -1
- data/ROADMAP.textile +1 -1
- data/bin/railshoster +1 -6
- data/gemfiles/Gemfile.ci +1 -0
- data/lib/init.rb +5 -0
- data/lib/railshoster/init_command.rb +32 -10
- data/lib/railshoster/invalid_public_ssh_key_error.rb +5 -0
- data/lib/railshoster/possibly_not_a_git_repo_error.rb +1 -1
- data/lib/railshoster/utilities.rb +58 -0
- data/lib/railshoster/version.rb +1 -1
- data/lib/railshoster.rb +1 -0
- data/railshoster.gemspec +1 -0
- data/spec/fake_dot_ssh/1_valid_key/bullshit.pub +1 -0
- data/spec/fake_dot_ssh/1_valid_key/id_rsa.pub +1 -0
- data/spec/fake_dot_ssh/2_valid_keys/github_rsa.pub +1 -0
- data/spec/fake_dot_ssh/2_valid_keys/id_dsa.pub +1 -0
- data/spec/lib/railshoster/command_spec.rb +1 -1
- data/spec/lib/railshoster/init_command_spec.rb +1 -1
- data/spec/lib/railshoster/utilities_spec.rb +51 -10
- data/spec/spec_helper.rb +4 -3
- data/templates/h/deploy.rb.erb +8 -2
- metadata +29 -5
data/CHANGELOG.textile
CHANGED
@@ -45,4 +45,8 @@ bc. railshoster init -json '{"t":"h","u":"user999999999","a":"rails1","h":"zeta.
|
|
45
45
|
h3. 0.2.1
|
46
46
|
|
47
47
|
* Updated ROADMAP
|
48
|
-
* Added bundler as railshoster gem dependency to avoid problems with "rake" vs "bundle exec rake".
|
48
|
+
* Added bundler as railshoster gem dependency to avoid problems with "rake" vs "bundle exec rake".
|
49
|
+
|
50
|
+
h3. 0.3.0
|
51
|
+
|
52
|
+
* SSH publick key file recognition and upload to authorized_keys to enable a passwordless deploy.rb.
|
data/ROADMAP.textile
CHANGED
@@ -16,6 +16,6 @@ h3. Product Backlog
|
|
16
16
|
|
17
17
|
h3. General TODOs
|
18
18
|
|
19
|
-
* Railshoster::InitCommand - Check wether it is possible to replace "system" call with a pure ruby version possibly by using the capistrano gem directly via ruby.
|
19
|
+
* Railshoster::InitCommand - Check wether it is possible to replace "system" call with a pure ruby version possibly by using the capistrano gem directly via ruby. See branch "run_cap_task_from_ruby-2011-11-08" for a try on how to do it.
|
20
20
|
* Test bin/railshoster
|
21
21
|
* railshoster deploy should check capistrano's exit status and respond to that in case of a failure.
|
data/bin/railshoster
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
4
|
-
# require 'bundler/setup'
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'init'))
|
5
4
|
|
6
|
-
gem "json"
|
7
|
-
gem "git"
|
8
|
-
gem 'erubis'
|
9
|
-
gem "gli"
|
10
5
|
require 'fileutils'
|
11
6
|
|
12
7
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'railshoster'))
|
data/gemfiles/Gemfile.ci
CHANGED
data/lib/init.rb
ADDED
@@ -2,6 +2,7 @@ require 'base64'
|
|
2
2
|
require 'json'
|
3
3
|
require 'git'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'net/sftp'
|
5
6
|
|
6
7
|
require File.expand_path(File.join(File.dirname(__FILE__), '/capistrano/h'))
|
7
8
|
|
@@ -31,9 +32,38 @@ module Railshoster
|
|
31
32
|
def run_by_application_hash(application_hash_as_json_string)
|
32
33
|
app_hash = parse_application_json_hash(application_hash_as_json_string)
|
33
34
|
|
35
|
+
# Extract GIT URL from project and add it to the app_hash
|
34
36
|
git_url = get_git_remote_url_from_git_config
|
35
37
|
app_hash["git"] = git_url
|
36
38
|
|
39
|
+
#TODO Add connection test -> If there's already access -> no need to do this
|
40
|
+
selected_key = Railshoster::Utilities.select_public_ssh_key
|
41
|
+
app_hash["public_ssh_key"] = Pathname.new(selected_key[:path]).basename.to_s.gsub(".pub", "")
|
42
|
+
|
43
|
+
create_remote_authorized_key_file_from_public_ssh_key(app_hash, selected_key)
|
44
|
+
deployrb_str = create_deployrb(app_hash)
|
45
|
+
write_deploy_rb(deployrb_str)
|
46
|
+
capify_project
|
47
|
+
success_message
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def create_remote_authorized_key_file_from_public_ssh_key(app_hash, key)
|
53
|
+
remote_dot_ssh_path = ".ssh"
|
54
|
+
remote_authorized_keys_path = remote_dot_ssh_path + "/authorized_keys"
|
55
|
+
Net::SFTP.start(app_hash["h"], app_hash["u"], :password => app_hash["p"]) do |sftp|
|
56
|
+
begin
|
57
|
+
sftp.mkdir!(remote_dot_ssh_path)
|
58
|
+
rescue Net::SFTP::StatusException => e
|
59
|
+
# Most likely the .ssh folder already exists raise again if not.
|
60
|
+
raise e unless e.code == 4
|
61
|
+
end
|
62
|
+
sftp.upload!(key[:path].to_s, remote_authorized_keys_path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_deployrb(app_hash)
|
37
67
|
deployrb_str = ""
|
38
68
|
|
39
69
|
# Choose the further process depending on the application type by applying a strategy pattern.
|
@@ -46,13 +76,7 @@ module Railshoster
|
|
46
76
|
else
|
47
77
|
raise UnsupportedApplicationTypeError.new
|
48
78
|
end
|
49
|
-
|
50
|
-
write_deploy_rb(deployrb_str)
|
51
|
-
capify_project
|
52
|
-
success_message
|
53
|
-
end
|
54
|
-
|
55
|
-
protected
|
79
|
+
end
|
56
80
|
|
57
81
|
# Decodoes token to get the JSON hash back.
|
58
82
|
# gQkUSMakKRPhm0EIaer => {"key":"value"}
|
@@ -82,9 +106,7 @@ module Railshoster
|
|
82
106
|
deployrb_path = File.join(deployrb_basepath, "deploy.rb")
|
83
107
|
Railshoster::Utilities.backup_file(deployrb_path) if File.exists?(deployrb_path)
|
84
108
|
|
85
|
-
File.open(deployrb_path, "w+")
|
86
|
-
f << deployrb_str
|
87
|
-
end
|
109
|
+
File.open(deployrb_path, "w+") { |f| f << deployrb_str }
|
88
110
|
end
|
89
111
|
|
90
112
|
def capify_project
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'etc'
|
3
|
+
require 'pathname'
|
2
4
|
|
3
5
|
module Railshoster
|
4
6
|
class Utilities
|
@@ -21,5 +23,61 @@ module Railshoster
|
|
21
23
|
|
22
24
|
FileUtils.cp(path, backup_path)
|
23
25
|
end
|
26
|
+
|
27
|
+
def self.get_user_home
|
28
|
+
homes = ["HOME", "HOMEPATH"]
|
29
|
+
home_key = homes.detect { |h| ENV[h] != nil }
|
30
|
+
ENV[home_key]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.select_public_ssh_key(ssh_dir = File.join(get_user_home, ".ssh"), options = {:verbose => true})
|
34
|
+
keys = Railshoster::Utilities.find_public_ssh_keys(ssh_dir, options)
|
35
|
+
return keys.first if keys.size == 1
|
36
|
+
|
37
|
+
puts "\nThere are multiple public ssh keys. Please choose your deploy key:"
|
38
|
+
keys.each_with_index do |key, i|
|
39
|
+
puts "#{i+1}) #{Pathname.new(key[:path]).basename.to_s}"
|
40
|
+
end
|
41
|
+
|
42
|
+
selected_key = nil
|
43
|
+
while selected_key.nil? do
|
44
|
+
print "Your choice: "
|
45
|
+
index = (STDIN.gets.chomp.to_i - 1)
|
46
|
+
selected_key = keys[index]
|
47
|
+
puts "Invalid choice!" unless selected_key
|
48
|
+
end
|
49
|
+
|
50
|
+
selected_key
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.find_public_ssh_keys(ssh_dir = File.join(get_user_home, ".ssh"), options = {:verbose => true})
|
54
|
+
files_in_ssh_dir = Dir.glob(File.join(ssh_dir, "*.pub"))
|
55
|
+
|
56
|
+
ssh_keys = []
|
57
|
+
|
58
|
+
files_in_ssh_dir.each do |filepath|
|
59
|
+
filepathname = Pathname.new(filepath)
|
60
|
+
|
61
|
+
begin
|
62
|
+
ssh_keys << parse_public_ssh_key_file(filepathname)
|
63
|
+
rescue InvalidPublicSshKeyError => e
|
64
|
+
puts "\tNotice: #{filepathname} is not a valid public ssh key: #{e.message}" if (options && options[:verbose])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
ssh_keys
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.parse_public_ssh_key_file(path_to_key)
|
71
|
+
key = File.open(path_to_key).read
|
72
|
+
key_hash = parse_public_ssh_key(key)
|
73
|
+
key_hash[:path] = path_to_key
|
74
|
+
key_hash
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.parse_public_ssh_key(key)
|
78
|
+
format_identifier, key_data = key.split(" ")
|
79
|
+
raise InvalidPublicSshKeyError.new("Couldn't recognize both format_identifier and/or key_data. One is missing") unless(format_identifier && key_data)
|
80
|
+
{:format => format_identifier.chomp, :key_data => key_data.chomp, :key => key.chomp}
|
81
|
+
end
|
24
82
|
end
|
25
83
|
end
|
data/lib/railshoster/version.rb
CHANGED
data/lib/railshoster.rb
CHANGED
@@ -7,6 +7,7 @@ require File.join(File.dirname(__FILE__), 'railshoster/unsupported_application_t
|
|
7
7
|
require File.join(File.dirname(__FILE__), 'railshoster/capify_project_failed_error')
|
8
8
|
require File.join(File.dirname(__FILE__), 'railshoster/bad_application_json_hash_error')
|
9
9
|
require File.join(File.dirname(__FILE__), 'railshoster/bad_appliction_token_error')
|
10
|
+
require File.join(File.dirname(__FILE__), 'railshoster/invalid_public_ssh_key_error')
|
10
11
|
require File.join(File.dirname(__FILE__), 'railshoster/init_command')
|
11
12
|
require File.join(File.dirname(__FILE__), 'railshoster/deploy_command')
|
12
13
|
require File.join(File.dirname(__FILE__), 'railshoster/app_url_command')
|
data/railshoster.gemspec
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
thisisbullshit
|
@@ -0,0 +1 @@
|
|
1
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwnMABQ9xWwYdhHaaoNSzFMfXmytWHgkBmDg6v8Fn3oILqOMs99IPd7ChPetDdUWYV2pzLVVKB/kwrcoodRC4H6YHn8xk1oI+gDsv4Yg7ytWwgnDf5zXwWMVQ/IqfOdfxRwS1UCrKL7UsVfIUPzXmkia7PoMoQNnM8jbDRDcfyis3Q1VZ9OjIlM/RfqjH0hGFS95nd6geNwpSbSpg4HxNmfltQ6GpoqclQXX0QdBO+q93sn33JjFPEhYuLvQcoea7Tl0zRY0AGQ9r7562QFlWqMmB+9YXcsZu2OZSk7t5a39jral0jEuEeJB56kb5ZUqRA1DJI5En09/WUPLCYprdb enterprise-rails
|
@@ -0,0 +1 @@
|
|
1
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwnMABQ9xWwYdhHaaoNSzFMfXmytWHgkBmDg6v8Fn3oILqOMs99IPd7ChPetDdUWYV2pzLVVKB/kwrcoodRC4H6YHn8xk1oI+gDsv4Yg7ytWwgnDf5zXwWMVQ/IqfOdfxRwS1UCrKL7UsVfIUPzXmkia7PoMoQNnM8jbDRDcfyis3Q1VZ9OjIlM/RfqjH0hGFS95nd6geNwpSbSpg4HxNmfltQ6GpoqclQXX0QdBO+q93sn33JjFPEhYuLvQcoea7Tl0zRY0AGQ9r7562QFlWqMmB+9YXcsZu2OZSk7t5a39jral0jEuEeJB56kb5ZUqRA1DJI5En09/WUPLCYprdb enterprise-rails
|
@@ -0,0 +1 @@
|
|
1
|
+
ssh-dss AAAAB3NzaC1kc3MAAACASb4K1r69pd07CdApimtQvDD6VfKNCxv3BjyApoG4jQrrzhyMbuu1CKlbn7fIP4b18nQw3j02KIihcK/m6eN3pEkdI2+EbfGdpZeyZsxu7T0TgUDdB5+9wBHK46djOcB9n0PvY+uC/wO+nOXLMaL6dTzPOAF88QKr4Y88QMLzyNcAAAAVAIyNiIdszugwRjAefsa+JhGv+DR7AAAAgBonQljDlrI71sryROfA0KCu+wzB2mhou1iJEuFu0X079Urs6vhniT0qNXHMhLHFCxfZTrjbAGM3PY1SjW2XKmPLfyDwWoJrKtB10WZSlGZqSajMHahFdQ0fruibR/jGPI/etWbMSOHNZ2bBrM19LzuxPoZ2yWdigfCTLNl0bct6AAAAgDjakQkN1VfL/qFaAaX9VNS91ztUZo7HW2XuarGQ8GlTANsfWRhJLwXGJXkFaLB3Ja8DFeBLdnNBLKlMBh0MUIxOryrR6ShC5Ul5bmWfzpHq9WyTF6G/qmm7dIOSFJpe5OfAaZitaNjb7dHe6ruryYZ9IuPwuKWwy+BNJih+EEFJ
|
@@ -1,12 +1,13 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
2
2
|
|
3
3
|
describe Railshoster::Utilities do
|
4
|
-
|
5
|
-
before do
|
6
|
-
FakeFS.activate!
|
7
|
-
end
|
8
|
-
|
4
|
+
|
9
5
|
describe "#Backup" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
FakeFS.activate!
|
9
|
+
end
|
10
|
+
|
10
11
|
include FakeFS::SpecHelpers
|
11
12
|
|
12
13
|
it "should create a backup file" do
|
@@ -41,9 +42,49 @@ describe Railshoster::Utilities do
|
|
41
42
|
# But the old backup is still there - being moved to .bak.bak.
|
42
43
|
File.open("myfile.txt.bak.bak").read.should eql("2")
|
43
44
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
|
46
|
+
after do
|
47
|
+
FakeFS.deactivate!
|
48
|
+
end
|
48
49
|
end
|
50
|
+
|
51
|
+
describe "#ssh_tools" do
|
52
|
+
it "should parse a valid ssh public key" do
|
53
|
+
key = Railshoster::Utilities.parse_public_ssh_key("ssh-dss AAAAB3NzaC1kc3MAAACASb4K1r69pd07CdApimtQvDD6VfKNCxv3BjyApoG4jQrrzhyMbuu1CKlbn7fIP4b18nQw3j02KIihcK/m6eN3pEkdI2+EbfGdpZeyZsxu7T0TgUDdB5+9wBHK46djOcB9n0PvY+uC/wO+nOXLMaL6dTzPOAF88QKr4Y88QMLzyNcAAAAVAIyNiIdszugwRjAefsa+JhGv+DR7AAAAgBonQljDlrI71sryROfA0KCu+wzB2mhou1iJEuFu0X079Urs6vhniT0qNXHMhLHFCxfZTrjbAGM3PY1SjW2XKmPLfyDwWoJrKtB10WZSlGZqSajMHahFdQ0fruibR/jGPI/etWbMSOHNZ2bBrM19LzuxPoZ2yWdigfCTLNl0bct6AAAAgDjakQkN1VfL/qFaAaX9VNS91ztUZo7HW2XuarGQ8GlTANsfWRhJLwXGJXkFaLB3Ja8DFeBLdnNBLKlMBh0MUIxOryrR6ShC5Ul5bmWfzpHq9WyTF6G/qmm7dIOSFJpe5OfAaZitaNjb7dHe6ruryYZ9IuPwuKWwy+BNJih+EEFJ")
|
54
|
+
key[:format].should eql("ssh-dss")
|
55
|
+
key[:key_data].should eql("AAAAB3NzaC1kc3MAAACASb4K1r69pd07CdApimtQvDD6VfKNCxv3BjyApoG4jQrrzhyMbuu1CKlbn7fIP4b18nQw3j02KIihcK/m6eN3pEkdI2+EbfGdpZeyZsxu7T0TgUDdB5+9wBHK46djOcB9n0PvY+uC/wO+nOXLMaL6dTzPOAF88QKr4Y88QMLzyNcAAAAVAIyNiIdszugwRjAefsa+JhGv+DR7AAAAgBonQljDlrI71sryROfA0KCu+wzB2mhou1iJEuFu0X079Urs6vhniT0qNXHMhLHFCxfZTrjbAGM3PY1SjW2XKmPLfyDwWoJrKtB10WZSlGZqSajMHahFdQ0fruibR/jGPI/etWbMSOHNZ2bBrM19LzuxPoZ2yWdigfCTLNl0bct6AAAAgDjakQkN1VfL/qFaAaX9VNS91ztUZo7HW2XuarGQ8GlTANsfWRhJLwXGJXkFaLB3Ja8DFeBLdnNBLKlMBh0MUIxOryrR6ShC5Ul5bmWfzpHq9WyTF6G/qmm7dIOSFJpe5OfAaZitaNjb7dHe6ruryYZ9IuPwuKWwy+BNJih+EEFJ")
|
56
|
+
key[:key].should eql("ssh-dss AAAAB3NzaC1kc3MAAACASb4K1r69pd07CdApimtQvDD6VfKNCxv3BjyApoG4jQrrzhyMbuu1CKlbn7fIP4b18nQw3j02KIihcK/m6eN3pEkdI2+EbfGdpZeyZsxu7T0TgUDdB5+9wBHK46djOcB9n0PvY+uC/wO+nOXLMaL6dTzPOAF88QKr4Y88QMLzyNcAAAAVAIyNiIdszugwRjAefsa+JhGv+DR7AAAAgBonQljDlrI71sryROfA0KCu+wzB2mhou1iJEuFu0X079Urs6vhniT0qNXHMhLHFCxfZTrjbAGM3PY1SjW2XKmPLfyDwWoJrKtB10WZSlGZqSajMHahFdQ0fruibR/jGPI/etWbMSOHNZ2bBrM19LzuxPoZ2yWdigfCTLNl0bct6AAAAgDjakQkN1VfL/qFaAaX9VNS91ztUZo7HW2XuarGQ8GlTANsfWRhJLwXGJXkFaLB3Ja8DFeBLdnNBLKlMBh0MUIxOryrR6ShC5Ul5bmWfzpHq9WyTF6G/qmm7dIOSFJpe5OfAaZitaNjb7dHe6ruryYZ9IuPwuKWwy+BNJih+EEFJ")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should fail to parse a ssh key without a public key format identifier" do
|
60
|
+
expect {
|
61
|
+
Railshoster::Utilities.parse_public_ssh_key("AAAAB3NzaC1kc3MAAACASb4K1r69pd07CdApimtQvDD6VfKNCxv3BjyApoG4jQrrzhyMbuu1CKlbn7fIP4b18nQw3j02KIihcK/m6eN3pEkdI2+EbfGdpZeyZsxu7T0TgUDdB5+9wBHK46djOcB9n0PvY+uC/wO+nOXLMaL6dTzPOAF88QKr4Y88QMLzyNcAAAAVAIyNiIdszugwRjAefsa+JhGv+DR7AAAAgBonQljDlrI71sryROfA0KCu+wzB2mhou1iJEuFu0X079Urs6vhniT0qNXHMhLHFCxfZTrjbAGM3PY1SjW2XKmPLfyDwWoJrKtB10WZSlGZqSajMHahFdQ0fruibR/jGPI/etWbMSOHNZ2bBrM19LzuxPoZ2yWdigfCTLNl0bct6AAAAgDjakQkN1VfL/qFaAaX9VNS91ztUZo7HW2XuarGQ8GlTANsfWRhJLwXGJXkFaLB3Ja8DFeBLdnNBLKlMBh0MUIxOryrR6ShC5Ul5bmWfzpHq9WyTF6G/qmm7dIOSFJpe5OfAaZitaNjb7dHe6ruryYZ9IuPwuKWwy+BNJih+EEFJ")
|
62
|
+
}.to raise_error(Railshoster::InvalidPublicSshKeyError)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should fail to parse a ssh key without a public key/certificate data" do
|
66
|
+
expect {
|
67
|
+
Railshoster::Utilities.parse_public_ssh_key("ssh-dss ")
|
68
|
+
}.to raise_error(Railshoster::InvalidPublicSshKeyError)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should parse a public ssh key file" do
|
72
|
+
keys = Railshoster::Utilities.find_public_ssh_keys(File.join(File.dirname(__FILE__), "..", "..", "fake_dot_ssh", "1_valid_key"), :verbose => false)
|
73
|
+
keys.size.should be(1)
|
74
|
+
keys.first[:format].should eql("ssh-rsa")
|
75
|
+
keys.first[:key_data].should eql("AAAAB3NzaC1yc2EAAAADAQABAAABAQDwnMABQ9xWwYdhHaaoNSzFMfXmytWHgkBmDg6v8Fn3oILqOMs99IPd7ChPetDdUWYV2pzLVVKB/kwrcoodRC4H6YHn8xk1oI+gDsv4Yg7ytWwgnDf5zXwWMVQ/IqfOdfxRwS1UCrKL7UsVfIUPzXmkia7PoMoQNnM8jbDRDcfyis3Q1VZ9OjIlM/RfqjH0hGFS95nd6geNwpSbSpg4HxNmfltQ6GpoqclQXX0QdBO+q93sn33JjFPEhYuLvQcoea7Tl0zRY0AGQ9r7562QFlWqMmB+9YXcsZu2OZSk7t5a39jral0jEuEeJB56kb5ZUqRA1DJI5En09/WUPLCYprdb")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should select a public ssh key without a dialog if there is only a single valid key" do
|
79
|
+
key = Railshoster::Utilities.select_public_ssh_key(File.join(File.dirname(__FILE__), "..", "..", "fake_dot_ssh", "1_valid_key"), :verbose => false)
|
80
|
+
key[:format].should eql("ssh-rsa")
|
81
|
+
key[:key_data].should eql("AAAAB3NzaC1yc2EAAAADAQABAAABAQDwnMABQ9xWwYdhHaaoNSzFMfXmytWHgkBmDg6v8Fn3oILqOMs99IPd7ChPetDdUWYV2pzLVVKB/kwrcoodRC4H6YHn8xk1oI+gDsv4Yg7ytWwgnDf5zXwWMVQ/IqfOdfxRwS1UCrKL7UsVfIUPzXmkia7PoMoQNnM8jbDRDcfyis3Q1VZ9OjIlM/RfqjH0hGFS95nd6geNwpSbSpg4HxNmfltQ6GpoqclQXX0QdBO+q93sn33JjFPEhYuLvQcoea7Tl0zRY0AGQ9r7562QFlWqMmB+9YXcsZu2OZSk7t5a39jral0jEuEeJB56kb5ZUqRA1DJI5En09/WUPLCYprdb")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should select a public ssh key using a dialog if there is more than one valid public ssh key" do
|
85
|
+
STDIN.stubs(:gets).returns("1")
|
86
|
+
key = Railshoster::Utilities.select_public_ssh_key(File.join(File.dirname(__FILE__), "..", "..", "fake_dot_ssh", "2_valid_keys"), :verbose => false)
|
87
|
+
key[:format].size.should > 1
|
88
|
+
end
|
89
|
+
end
|
49
90
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
|
2
3
|
require 'fakefs/safe'
|
3
4
|
require 'fakefs/spec_helpers'
|
4
5
|
|
@@ -10,6 +11,6 @@ require 'fakefs/spec_helpers'
|
|
10
11
|
|
11
12
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'railshoster')
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
RSpec.configure do |c|
|
15
|
+
c.mock_with :mocha
|
16
|
+
end
|
data/templates/h/deploy.rb.erb
CHANGED
@@ -16,11 +16,17 @@ require 'bundler/capistrano'
|
|
16
16
|
# user to login to the target server
|
17
17
|
set :user, "<%= app["u"] %>"
|
18
18
|
|
19
|
+
<% if app["public_ssh_key"] then %>
|
20
|
+
|
21
|
+
# allow SSH-Key-Forwarding
|
22
|
+
set :ssh_options, { :forward_agent => true }
|
23
|
+
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "<%= app["public_ssh_key"] %>")]
|
24
|
+
<% else %>
|
25
|
+
|
19
26
|
# password to login to the target server
|
20
27
|
set :password, "<%= app["p"] %>"
|
21
28
|
|
22
|
-
|
23
|
-
set :ssh_options, { :forward_agent => true }
|
29
|
+
<% end %>
|
24
30
|
|
25
31
|
## Application name and repository
|
26
32
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railshoster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julian Fischer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bundler
|
@@ -147,6 +147,20 @@ dependencies:
|
|
147
147
|
version: "0"
|
148
148
|
type: :development
|
149
149
|
version_requirements: *id009
|
150
|
+
- !ruby/object:Gem::Dependency
|
151
|
+
name: mocha
|
152
|
+
prerelease: false
|
153
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
version: "0"
|
162
|
+
type: :development
|
163
|
+
version_requirements: *id010
|
150
164
|
description: Easily deploy your Rails app to RailsHoster.com by using this gem.
|
151
165
|
email:
|
152
166
|
- fischer@enterprise-rails.de
|
@@ -167,6 +181,7 @@ files:
|
|
167
181
|
- Rakefile
|
168
182
|
- bin/railshoster
|
169
183
|
- gemfiles/Gemfile.ci
|
184
|
+
- lib/init.rb
|
170
185
|
- lib/railshoster.rb
|
171
186
|
- lib/railshoster/app_url_command.rb
|
172
187
|
- lib/railshoster/bad_application_json_hash_error.rb
|
@@ -178,11 +193,16 @@ files:
|
|
178
193
|
- lib/railshoster/deploy_command.rb
|
179
194
|
- lib/railshoster/error.rb
|
180
195
|
- lib/railshoster/init_command.rb
|
196
|
+
- lib/railshoster/invalid_public_ssh_key_error.rb
|
181
197
|
- lib/railshoster/possibly_not_a_git_repo_error.rb
|
182
198
|
- lib/railshoster/unsupported_application_type_error.rb
|
183
199
|
- lib/railshoster/utilities.rb
|
184
200
|
- lib/railshoster/version.rb
|
185
201
|
- railshoster.gemspec
|
202
|
+
- spec/fake_dot_ssh/1_valid_key/bullshit.pub
|
203
|
+
- spec/fake_dot_ssh/1_valid_key/id_rsa.pub
|
204
|
+
- spec/fake_dot_ssh/2_valid_keys/github_rsa.pub
|
205
|
+
- spec/fake_dot_ssh/2_valid_keys/id_dsa.pub
|
186
206
|
- spec/lib/railshoster/command_spec.rb
|
187
207
|
- spec/lib/railshoster/init_command_spec.rb
|
188
208
|
- spec/lib/railshoster/utilities_spec.rb
|
@@ -222,6 +242,10 @@ signing_key:
|
|
222
242
|
specification_version: 3
|
223
243
|
summary: RailsHoster Applicatoin Deployment Suite
|
224
244
|
test_files:
|
245
|
+
- spec/fake_dot_ssh/1_valid_key/bullshit.pub
|
246
|
+
- spec/fake_dot_ssh/1_valid_key/id_rsa.pub
|
247
|
+
- spec/fake_dot_ssh/2_valid_keys/github_rsa.pub
|
248
|
+
- spec/fake_dot_ssh/2_valid_keys/id_dsa.pub
|
225
249
|
- spec/lib/railshoster/command_spec.rb
|
226
250
|
- spec/lib/railshoster/init_command_spec.rb
|
227
251
|
- spec/lib/railshoster/utilities_spec.rb
|