rails_pwnerer 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/pwnage/app/cluster_config.rb +28 -1
- data/lib/pwnage/app/database.rb +24 -1
- data/lib/pwnage/app/main.rb +8 -0
- data/lib/pwnage/app/nginx_config.rb +4 -0
- data/lib/pwnage/app/svn.rb +10 -0
- data/lib/pwnage/executor.rb +4 -0
- data/lib/pwnage/scaffolds/gems.rb +1 -1
- data/rails_pwnerer.gemspec +3 -3
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
v0.3. Supports 'update' to update application from svn. Still no configuration outside of config/main.rb.
|
2
|
+
|
1
3
|
v0.2. Supports 'install' to install application from svn. No configuration outside of config/main.rb.
|
2
4
|
|
3
5
|
v0.1. Initial release. Supports 'den00b' to setup the environment.
|
@@ -31,6 +31,21 @@ class RailsPwnage::App::ClusterConfig
|
|
31
31
|
|
32
32
|
# copy the configuration to the launch directory
|
33
33
|
FileUtils.cp('config/mongrel_cluster.yml', "#{RailsPwnage::Config.path_to :mongrel_configs}#{File::SEPARATOR}#{app_name}.yml")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def stop_mongrels(app_name)
|
38
|
+
with_dir(RailsPwnage::Config.path_to(app_name)) do
|
39
|
+
system 'mongrel_rails cluster::stop'
|
40
|
+
|
41
|
+
# clean up PID files in case the mongrels died and left them behind
|
42
|
+
Dir.glob('tmp/pids/*.pid').each { |f| File.delete(f) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def start_mongrels(app_name)
|
47
|
+
with_dir(RailsPwnage::Config.path_to(app_name)) do
|
48
|
+
system 'mongrel_rails cluster::start'
|
34
49
|
end
|
35
50
|
end
|
36
51
|
|
@@ -39,7 +54,19 @@ class RailsPwnage::App::ClusterConfig
|
|
39
54
|
fix_permissions app_name
|
40
55
|
end
|
41
56
|
|
57
|
+
def update(app_name, &update_proc)
|
58
|
+
stop_mongrels(app_name)
|
59
|
+
yield
|
60
|
+
ensure
|
61
|
+
# TODO: reconfigure the mongrels if the configuration database changed
|
62
|
+
start_mongrels(app_name)
|
63
|
+
end
|
64
|
+
|
42
65
|
def self.setup(app_name)
|
43
66
|
self.new.setup(app_name)
|
44
|
-
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.update(app_name, &update_proc)
|
70
|
+
self.new.update(app_name, &update_proc)
|
71
|
+
end
|
45
72
|
end
|
data/lib/pwnage/app/database.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# sets up the application database
|
2
2
|
|
3
|
+
require 'yaml'
|
4
|
+
|
3
5
|
class RailsPwnage::App::Database
|
4
6
|
include RailsPwnage::Base
|
5
7
|
|
@@ -27,7 +29,19 @@ ENDSQL
|
|
27
29
|
|
28
30
|
# configures rails to use the database in the production environment
|
29
31
|
def configure_rails(app_name)
|
30
|
-
|
32
|
+
db_name = RailsPwnage::Config.app_dbname(app_name)
|
33
|
+
db_user = RailsPwnage::Config.app_db_user(app_name)
|
34
|
+
db_pass = RailsPwnage::Config.app_db_password(app_name)
|
35
|
+
|
36
|
+
config_file = RailsPwnage::Config.path_to(app_name) + File::SEPARATOR + 'config' + File::SEPARATOR + 'database.yml'
|
37
|
+
configuration = File.open(config_file, 'r') { |f| YAML.load f }
|
38
|
+
configuration['production'].merge! 'adapter' => 'mysql', 'database' => db_name, 'username' => db_user, 'password' => db_pass
|
39
|
+
File.open(config_file, 'w') { |f| YAML.dump(configuration, f) }
|
40
|
+
|
41
|
+
# bonus: lock down the database so only the right user can access it
|
42
|
+
pwnerer_user = RailsPwnage::Config.pwnerer_user
|
43
|
+
File.chmod(0600, config_file)
|
44
|
+
File.chown(uid_for_username(pwnerer_user), gid_for_username(pwnerer_user), config_file)
|
31
45
|
end
|
32
46
|
|
33
47
|
# migrates the database so it's ready
|
@@ -44,7 +58,16 @@ ENDSQL
|
|
44
58
|
migrate_database app_name
|
45
59
|
end
|
46
60
|
|
61
|
+
def update(app_name)
|
62
|
+
configure_rails app_name
|
63
|
+
migrate_database app_name
|
64
|
+
end
|
65
|
+
|
47
66
|
def self.setup(app_name)
|
48
67
|
self.new.setup(app_name)
|
49
68
|
end
|
69
|
+
|
70
|
+
def self.update(app_name)
|
71
|
+
self.new.update(app_name)
|
72
|
+
end
|
50
73
|
end
|
data/lib/pwnage/app/main.rb
CHANGED
@@ -6,4 +6,12 @@ module RailsPwnage::App
|
|
6
6
|
ClusterConfig.setup(app_name)
|
7
7
|
NginxConfig.setup(app_name)
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.update(app_name)
|
11
|
+
ClusterConfig.update(app_name) do
|
12
|
+
Svn.update(app_name)
|
13
|
+
Database.update(app_name)
|
14
|
+
end
|
15
|
+
NginxConfig.update(app_name)
|
16
|
+
end
|
9
17
|
end
|
data/lib/pwnage/app/svn.rb
CHANGED
@@ -16,6 +16,12 @@ class RailsPwnage::App::Svn
|
|
16
16
|
|
17
17
|
return app_name
|
18
18
|
end
|
19
|
+
|
20
|
+
def update(app_name)
|
21
|
+
with_dir(RailsPwnage::Config.path_to(app_name)) do
|
22
|
+
system "svn update"
|
23
|
+
end
|
24
|
+
end
|
19
25
|
|
20
26
|
def setup(svn_path)
|
21
27
|
app_name = checkout(svn_path)
|
@@ -28,6 +34,10 @@ class RailsPwnage::App::Svn
|
|
28
34
|
def self.setup(svn_path)
|
29
35
|
self.new.setup(svn_path)
|
30
36
|
end
|
37
|
+
|
38
|
+
def self.update(app_name)
|
39
|
+
self.new.update(app_name)
|
40
|
+
end
|
31
41
|
|
32
42
|
# TODO: uninstallation
|
33
43
|
end
|
data/lib/pwnage/executor.rb
CHANGED
data/rails_pwnerer.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Rails_pwnerer-0.
|
2
|
+
# Gem::Specification for Rails_pwnerer-0.3
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{rails_pwnerer}
|
7
|
-
s.version = "0.
|
7
|
+
s.version = "0.3"
|
8
8
|
|
9
9
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Victor Costan"]
|
13
|
-
s.date = %q{2008-04-
|
13
|
+
s.date = %q{2008-04-14}
|
14
14
|
s.default_executable = %q{rpwn}
|
15
15
|
s.description = %q{Rails deployment tool/hack.}
|
16
16
|
s.email = %q{victor@costan.us}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pwnerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-14 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|