railshoster 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.textile
CHANGED
@@ -19,7 +19,7 @@ h3. 0.0.3
|
|
19
19
|
* Enhanced error messages for invalid application tokens.
|
20
20
|
* Initial README.
|
21
21
|
|
22
|
-
h3. 0.4
|
22
|
+
h3. 0.0.4
|
23
23
|
|
24
24
|
* 0.4.0 has become 0.1.0 since features have been added.
|
25
25
|
|
@@ -49,4 +49,8 @@ h3. 0.2.1
|
|
49
49
|
|
50
50
|
h3. 0.3.0
|
51
51
|
|
52
|
-
* SSH publick key file recognition and upload to authorized_keys to enable a passwordless deploy.rb.
|
52
|
+
* SSH publick key file recognition and upload to authorized_keys to enable a passwordless deploy.rb.
|
53
|
+
|
54
|
+
h3. 0.4.0
|
55
|
+
|
56
|
+
* Now also works for RailsHoster VPS (virtual Servers).
|
data/ROADMAP.textile
CHANGED
@@ -5,12 +5,10 @@ h2. 0.0.1
|
|
5
5
|
|
6
6
|
h2. 1.0.0
|
7
7
|
|
8
|
-
* Remove password from deploy.rb by using an ssh connect at init. Find and copy lokal ssh public key to remot/authorized_keys.
|
9
8
|
* Solve database.yml issue - mysql or mysql2. Decide using bundler?
|
10
9
|
|
11
10
|
h3. Product Backlog
|
12
11
|
|
13
|
-
* RailsHoster VPS Deployments
|
14
12
|
* Mailer-Configuration
|
15
13
|
* Multistage Deployments - Deploy an app to a shared hosting (e.g. dev) and to a VPS (production).
|
16
14
|
|
@@ -5,7 +5,7 @@ require 'fileutils'
|
|
5
5
|
require 'net/sftp'
|
6
6
|
require 'sane'
|
7
7
|
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '/capistrano/
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/capistrano/config'))
|
9
9
|
|
10
10
|
module Railshoster
|
11
11
|
|
@@ -38,8 +38,8 @@ module Railshoster
|
|
38
38
|
#TODO Add connection test -> If there's already access -> no need to do this
|
39
39
|
selected_key = Railshoster::Utilities.select_public_ssh_key
|
40
40
|
app_hash["public_ssh_key"] = Pathname.new(selected_key[:path]).basename.to_s.gsub(".pub", "")
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
create_remote_authorized_key_file_from_app_hash(app_hash, selected_key)
|
43
43
|
deployrb_str = create_deployrb(app_hash)
|
44
44
|
write_deploy_rb(deployrb_str)
|
45
45
|
capify_project
|
@@ -77,30 +77,59 @@ module Railshoster
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
|
80
|
+
def create_remote_authorized_key_file_from_app_hash(app_hash, key)
|
81
|
+
if app_hash["t"].eql?("h") then
|
82
|
+
|
83
|
+
# For a hosting package the password is the deploy user's password
|
84
|
+
create_remote_authorized_key_file(app_hash["h"], app_hash["u"], app_hash["p"], key)
|
85
|
+
elsif app_hash["t"].eql?("v") then
|
86
|
+
|
87
|
+
# For a vps the given password it the root user's password -> Register key for root user
|
88
|
+
create_remote_authorized_key_file(app_hash["h"], "root", app_hash["p"], key)
|
89
|
+
|
90
|
+
# Also register the public key to enable key access to the deploy user
|
91
|
+
# This means that the
|
92
|
+
create_remote_authorized_key_file(app_hash["h"], "root", app_hash["p"], key, "/home/#{app_hash['u']}/.ssh", app_hash['u'])
|
93
|
+
else
|
94
|
+
exit_now!("Initialization aborted. Invalid product type: #{app_hash['t']}.", -1)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Creates a remote authorized keys file for the given public key
|
99
|
+
#
|
100
|
+
# === Parameters
|
101
|
+
# +host+:: SSH host to connect to
|
102
|
+
# +password+:: SSH password
|
103
|
+
# +key+:: Public key hash. Have a look at +Railshoster::Utilities.select_public_ssh_key+ for more details about the key structure.
|
104
|
+
# +remote_dot_ssh_path+:: Remote path to the user's .ssh path. Usually this is relative to the ssh-users's home path. Use absolute path names to avoid that.
|
105
|
+
# +target_username+:: Optional. If this parameter is set .ssh directory and the authorized_keys file will be assegned to the user with the given username.
|
106
|
+
def create_remote_authorized_key_file(host, ssh_username, password, key, remote_dot_ssh_path = ".ssh", target_username = nil)
|
82
107
|
remote_authorized_keys_path = remote_dot_ssh_path + "/authorized_keys"
|
83
|
-
Net::SFTP.start(
|
108
|
+
Net::SFTP.start(host, ssh_username, :password => password) do |sftp|
|
109
|
+
|
110
|
+
#TODO Smarter way to determine home directory
|
111
|
+
stats = sftp.stat!("/home/#{target_username}") if target_username
|
112
|
+
|
84
113
|
begin
|
85
114
|
sftp.mkdir!(remote_dot_ssh_path)
|
115
|
+
sftp.setstat(remote_dot_ssh_path, :uid => stats.uid, :gid => stats.gid) if target_username
|
86
116
|
rescue Net::SFTP::StatusException => e
|
87
117
|
# Most likely the .ssh folder already exists raise again if not.
|
88
118
|
raise e unless e.code == 4
|
89
119
|
end
|
90
120
|
sftp.upload!(key[:path].to_s, remote_authorized_keys_path)
|
121
|
+
sftp.setstat(remote_authorized_keys_path, :uid => stats.uid, :gid => stats.gid) if target_username
|
91
122
|
end
|
92
|
-
end
|
123
|
+
end
|
93
124
|
|
94
125
|
def create_deployrb(app_hash)
|
95
126
|
deployrb_str = ""
|
96
127
|
|
97
128
|
# Choose the further process depending on the application type by applying a strategy pattern.
|
98
129
|
case app_hash["t"].to_sym
|
99
|
-
when :h
|
130
|
+
when :h, :v
|
100
131
|
# Shared Hosting Deployments
|
101
|
-
deployrb_str = Railshoster::Capistrano::
|
102
|
-
# Later also support VPS Deployments
|
103
|
-
# when :v
|
132
|
+
deployrb_str = Railshoster::Capistrano::Config.render_deploy_rb_to_s(app_hash)
|
104
133
|
else
|
105
134
|
raise UnsupportedApplicationTypeError.new
|
106
135
|
end
|
data/lib/railshoster/version.rb
CHANGED
data/templates/h/deploy.rb.erb
CHANGED
@@ -79,7 +79,12 @@ namespace :railshoster do
|
|
79
79
|
desc "Show the url of your app."
|
80
80
|
task :appurl do
|
81
81
|
puts "\nThe default RailsHoster.com URL of your app is:"
|
82
|
-
|
82
|
+
|
83
|
+
<% if app["t"].eql?("h") then %>
|
84
|
+
puts "\nhttp://#{user}-<%= app["aid"] %>.<%= app["h"]%>"
|
85
|
+
<% else %>
|
86
|
+
puts "\nhttp://#{user}.<%= app["h"]%>"
|
87
|
+
<% end %>
|
83
88
|
puts "\n"
|
84
89
|
end
|
85
90
|
end
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.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-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bundler
|
@@ -202,8 +202,7 @@ files:
|
|
202
202
|
- lib/railshoster/bad_application_json_hash_error.rb
|
203
203
|
- lib/railshoster/bad_appliction_token_error.rb
|
204
204
|
- lib/railshoster/capify_project_failed_error.rb
|
205
|
-
- lib/railshoster/capistrano/
|
206
|
-
- lib/railshoster/capistrano/v.rb
|
205
|
+
- lib/railshoster/capistrano/config.rb
|
207
206
|
- lib/railshoster/command.rb
|
208
207
|
- lib/railshoster/deploy_command.rb
|
209
208
|
- lib/railshoster/error.rb
|