gorges_capistrano_ext 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/LICENSE +20 -0
- data/Manifest +16 -0
- data/README +57 -0
- data/Rakefile +2 -0
- data/gorges_capistrano_ext.gemspec +30 -0
- data/lib/application.rb +5 -0
- data/lib/config.sample.yml +65 -0
- data/lib/environments/development.rb +8 -0
- data/lib/environments/production.rb +8 -0
- data/lib/environments/staging.rb +8 -0
- data/lib/recipes/configure.rb +127 -0
- data/lib/recipes/database.rb +90 -0
- data/lib/recipes/deploy.rb +70 -0
- data/lib/recipes/hosting.rb +58 -0
- data/lib/recipes/sync.rb +71 -0
- data/lib/recipes/update.rb +10 -0
- metadata +102 -0
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v0.1.1 Initial Release
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 GORGES Inc (http://GORGES.us)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
LICENSE
|
3
|
+
README
|
4
|
+
Rakefile
|
5
|
+
lib/application.rb
|
6
|
+
lib/config.sample.yml
|
7
|
+
lib/environments/development.rb
|
8
|
+
lib/environments/production.rb
|
9
|
+
lib/environments/staging.rb
|
10
|
+
lib/recipes/configure.rb
|
11
|
+
lib/recipes/database.rb
|
12
|
+
lib/recipes/deploy.rb
|
13
|
+
lib/recipes/hosting.rb
|
14
|
+
lib/recipes/sync.rb
|
15
|
+
lib/recipes/update.rb
|
16
|
+
Manifest
|
data/README
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
##### HOSTING #####
|
2
|
+
|
3
|
+
Comprehensively prepare a target environment for deployment
|
4
|
+
|
5
|
+
> cap production hosting:setup
|
6
|
+
|
7
|
+
Comprehensively tear down target environment
|
8
|
+
|
9
|
+
> cap production hosting:teardown
|
10
|
+
|
11
|
+
##### DEPLOY #####
|
12
|
+
|
13
|
+
Deploy application to target environment
|
14
|
+
|
15
|
+
> cap production deploy
|
16
|
+
|
17
|
+
Rollback deployment to previous version in target environment
|
18
|
+
|
19
|
+
> cap production deploy:rollback
|
20
|
+
|
21
|
+
##### DATABASE #####
|
22
|
+
|
23
|
+
Save database in target environment to data directory
|
24
|
+
|
25
|
+
> cap production database:save
|
26
|
+
|
27
|
+
Load database from data directory in traget environment
|
28
|
+
|
29
|
+
> cap production database:populate
|
30
|
+
|
31
|
+
Push local database to target environment
|
32
|
+
|
33
|
+
> cap production database:publish
|
34
|
+
|
35
|
+
Dump database in target environment and check into subversion
|
36
|
+
|
37
|
+
> cap production database:export
|
38
|
+
|
39
|
+
##### SYNC #####
|
40
|
+
|
41
|
+
Synchronize both database and assets from target environment to local environment
|
42
|
+
|
43
|
+
> cap production sync
|
44
|
+
|
45
|
+
Synchronize only database from target environment to local environment
|
46
|
+
|
47
|
+
> cap production sync:database
|
48
|
+
|
49
|
+
Synchronize only assets from target environment to local environment
|
50
|
+
|
51
|
+
> cap production sync:assets
|
52
|
+
|
53
|
+
##### UPDATE #####
|
54
|
+
|
55
|
+
Update cap scripts from central gorges repository
|
56
|
+
|
57
|
+
> cap update
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gorges_capistrano_ext}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [""]
|
9
|
+
s.date = %q{2010-09-17}
|
10
|
+
s.description = %q{}
|
11
|
+
s.email = %q{}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/application.rb", "lib/config.sample.yml", "lib/environments/development.rb", "lib/environments/production.rb", "lib/environments/staging.rb", "lib/recipes/configure.rb", "lib/recipes/database.rb", "lib/recipes/deploy.rb", "lib/recipes/hosting.rb", "lib/recipes/sync.rb", "lib/recipes/update.rb"]
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "README", "Rakefile", "lib/application.rb", "lib/config.sample.yml", "lib/environments/development.rb", "lib/environments/production.rb", "lib/environments/staging.rb", "lib/recipes/configure.rb", "lib/recipes/database.rb", "lib/recipes/deploy.rb", "lib/recipes/hosting.rb", "lib/recipes/sync.rb", "lib/recipes/update.rb", "Manifest", "gorges_capistrano_ext.gemspec"]
|
14
|
+
s.homepage = %q{}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gorges_capistrano_ext", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{gorges_capistrano_ext}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
data/lib/application.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
application:
|
2
|
+
name:
|
3
|
+
framework:
|
4
|
+
|
5
|
+
subversion:
|
6
|
+
repository:
|
7
|
+
username:
|
8
|
+
password:
|
9
|
+
|
10
|
+
development:
|
11
|
+
specs:
|
12
|
+
os:
|
13
|
+
path:
|
14
|
+
webroot:
|
15
|
+
servers:
|
16
|
+
domain:
|
17
|
+
appservers:
|
18
|
+
dbservers:
|
19
|
+
database:
|
20
|
+
adapter: mysql
|
21
|
+
host: localhost
|
22
|
+
username:
|
23
|
+
password:
|
24
|
+
database:
|
25
|
+
ssh:
|
26
|
+
username:
|
27
|
+
password:
|
28
|
+
|
29
|
+
staging:
|
30
|
+
specs:
|
31
|
+
os:
|
32
|
+
path:
|
33
|
+
webroot:
|
34
|
+
servers:
|
35
|
+
domain:
|
36
|
+
appservers:
|
37
|
+
dbservers:
|
38
|
+
database:
|
39
|
+
adapter: mysql
|
40
|
+
host: localhost
|
41
|
+
username:
|
42
|
+
password:
|
43
|
+
database:
|
44
|
+
ssh:
|
45
|
+
username:
|
46
|
+
password:
|
47
|
+
|
48
|
+
production:
|
49
|
+
specs:
|
50
|
+
os:
|
51
|
+
path:
|
52
|
+
webroot:
|
53
|
+
servers:
|
54
|
+
domain:
|
55
|
+
appservers:
|
56
|
+
dbservers:
|
57
|
+
database:
|
58
|
+
adapter: mysql
|
59
|
+
host: localhost
|
60
|
+
username:
|
61
|
+
password:
|
62
|
+
database:
|
63
|
+
ssh:
|
64
|
+
username:
|
65
|
+
password:
|
@@ -0,0 +1,127 @@
|
|
1
|
+
set :stage_dir, "config/environments"
|
2
|
+
set :default_stage, "development"
|
3
|
+
require 'capistrano/ext/multistage'
|
4
|
+
|
5
|
+
namespace :configure do
|
6
|
+
|
7
|
+
task :default do
|
8
|
+
load_config
|
9
|
+
load_local
|
10
|
+
load_application
|
11
|
+
load_specs
|
12
|
+
load_servers
|
13
|
+
load_database
|
14
|
+
load_ssh
|
15
|
+
load_filesystem
|
16
|
+
end
|
17
|
+
|
18
|
+
task :check do
|
19
|
+
check_config
|
20
|
+
end
|
21
|
+
|
22
|
+
##### HELPER METHODS #####
|
23
|
+
|
24
|
+
def load_config
|
25
|
+
set :config, YAML.load_file("#{File.dirname(__FILE__)}/../config.yml")
|
26
|
+
set :application, config['application']
|
27
|
+
set :svn, config['subversion']
|
28
|
+
set :specs, config[environment]['specs']
|
29
|
+
set :servers, config[environment]['servers']
|
30
|
+
set :ssh, config[environment]['ssh']
|
31
|
+
set :db, config[environment]['database']
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_application
|
35
|
+
set :name, application['name']
|
36
|
+
set :framework, application['framework']
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_local
|
40
|
+
set :local, config["development"]
|
41
|
+
set :local_db, local["database"]
|
42
|
+
set :local_tmp_dir, local['specs']['path'] + '/tmp'
|
43
|
+
set :local_config_dir, local['specs']['path'] + '/config'
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_specs
|
47
|
+
set :os, specs['os']
|
48
|
+
set :webroot, specs['webroot']
|
49
|
+
set :path, specs['path']
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_servers
|
53
|
+
set :domain, servers['domain']
|
54
|
+
set :appservers, servers['appservers']
|
55
|
+
set :dbservers, servers['dbservers']
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_database
|
59
|
+
set :mysql, "mysql"
|
60
|
+
set :mysqldump, "mysqldump"
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_ssh
|
64
|
+
set :user, ssh['username']
|
65
|
+
set :password, ssh['password']
|
66
|
+
end
|
67
|
+
|
68
|
+
def load_filesystem
|
69
|
+
set :deploy_dir, "#{path}"
|
70
|
+
set :cache_dir, "#{path}/cache"
|
71
|
+
set :current_dir, "#{path}/#{webroot}"
|
72
|
+
set :data_dir, (environment == 'development') ? "#{path}/data" : "#{path}/cache/data"
|
73
|
+
set :shared_dir, "#{path}/shared"
|
74
|
+
set :tmp_dir, "#{path}/tmp"
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_config
|
78
|
+
set :config, YAML.load_file("#{File.dirname(__FILE__)}/../config.yml")
|
79
|
+
status = true
|
80
|
+
localpath = config["development"]["specs"]["path"]
|
81
|
+
status = (test_variable(['application',['name','framework']])) ? status : false
|
82
|
+
status = (test_variable(['subversion',['repository','username','password']])) ? status : false
|
83
|
+
status = (test_variable(['development',['specs',['os','path','webroot'],'servers',['domain','appservers','dbservers'],'database',['adapter','host','username','password','database']]])) ? status : false
|
84
|
+
status = (test_variable(['staging',['specs',['os','path','webroot'],'servers',['domain','appservers','dbservers'],'database',['adapter','host','username','password','database'],'ssh',['username','password']]])) ? status : false
|
85
|
+
status = (test_variable(['production',['specs',['os','path','webroot'],'servers',['domain','appservers','dbservers'],'database',['adapter','host','username','password','database'],'ssh',['username','password']]])) ? status : false
|
86
|
+
status = (test_directory("#{localpath}/tmp")) ? status : false
|
87
|
+
status = (test_directory("#{localpath}/data")) ? status : false
|
88
|
+
abort unless status
|
89
|
+
return status
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_directory(path)
|
93
|
+
unless File.directory? path
|
94
|
+
puts
|
95
|
+
puts '>> Missing directory ' + path
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
return true
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_variable(keys, hash = config, namespace = "config")
|
102
|
+
last = ""
|
103
|
+
keys.length.times do |i|
|
104
|
+
key = keys[i]
|
105
|
+
if key.class == Array
|
106
|
+
subnamespace = namespace + "[" + last + "]"
|
107
|
+
subhash = hash[last]
|
108
|
+
if !test_variable(key, subhash, subnamespace)
|
109
|
+
return false
|
110
|
+
end
|
111
|
+
else
|
112
|
+
last = key
|
113
|
+
status = (hash.key?(key)) ? true : false
|
114
|
+
if(status)
|
115
|
+
status = (hash[key].nil?) ? false : true
|
116
|
+
end
|
117
|
+
unless status
|
118
|
+
puts
|
119
|
+
puts '>> Missing variable ' + namespace + "[" + key + "]"
|
120
|
+
return false
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
return true
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
namespace :database do
|
2
|
+
|
3
|
+
desc "Save database"
|
4
|
+
task :save, :roles => :db do
|
5
|
+
preprocess_database
|
6
|
+
dump_database
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Populate database"
|
10
|
+
task :populate, :roles => :db do
|
11
|
+
empty_database
|
12
|
+
load_database
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Publish database"
|
16
|
+
task :publish, :roles => :db do
|
17
|
+
preprocess_database
|
18
|
+
save_database
|
19
|
+
upload_database
|
20
|
+
extract_database
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Export database"
|
24
|
+
task :export, :roles => :db do
|
25
|
+
preprocess_database
|
26
|
+
dump_database
|
27
|
+
checkin_database
|
28
|
+
end
|
29
|
+
|
30
|
+
##### HELPER METHODS #####
|
31
|
+
|
32
|
+
def preprocess_database
|
33
|
+
send('preprocess_' + framework + '_database')
|
34
|
+
end
|
35
|
+
|
36
|
+
def preprocess_drupal_database
|
37
|
+
tables = "cache,cache_block,cache_filter,cache_form,cache_menu,cache_page"
|
38
|
+
sql = ""
|
39
|
+
tables.split(",").each { |table|
|
40
|
+
sql += "DELETE FROM #{table};"
|
41
|
+
}
|
42
|
+
execute(sql);
|
43
|
+
end
|
44
|
+
|
45
|
+
def preprocess_yii_database
|
46
|
+
end
|
47
|
+
|
48
|
+
def dump_database
|
49
|
+
dbcmd("#{mysqldump} -u #{db['username']} -p#{db['password']} #{db['database']} > #{data_dir}/database.sql")
|
50
|
+
end
|
51
|
+
|
52
|
+
def save_database
|
53
|
+
localdb = config['development']['database']
|
54
|
+
localpath = config['development']['specs']['path']
|
55
|
+
system("#{mysqldump} -u #{localdb['username']} -p#{localdb['password']} #{localdb['database']} > #{localpath}/tmp/database.sql")
|
56
|
+
end
|
57
|
+
|
58
|
+
def upload_database
|
59
|
+
data = File.open(File.join('tmp', 'database.sql')).read
|
60
|
+
put data, "#{tmp_dir}/database.sql"
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_database
|
64
|
+
dbcmd("cat #{tmp_dir}/database.sql | #{mysql} -u #{db['username']} -p#{db['password']} #{db['database']}")
|
65
|
+
run("rm -rf #{tmp_dir}/database.sql")
|
66
|
+
end
|
67
|
+
|
68
|
+
def load_database
|
69
|
+
dbcmd("cat #{data_dir}/database.sql | #{mysql} -u #{db['username']} -p#{db['password']} #{db['database']}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def empty_database
|
73
|
+
execute("DROP DATABASE #{db['database']};CREATE DATABASE #{db['database']};");
|
74
|
+
end
|
75
|
+
|
76
|
+
def checkin_database
|
77
|
+
run("svn -q --username=#{svn['username']} --password=#{svn['password']} update #{cache_dir};")
|
78
|
+
run("cd #{cache_dir};svn -q --username=#{svn['username']} --password=#{svn['password']} commit -m 'Saving database'")
|
79
|
+
end
|
80
|
+
|
81
|
+
def execute(sql)
|
82
|
+
sql = (environment != 'development') ? "'#{sql}'" : sql
|
83
|
+
dbcmd("echo #{sql} | #{mysql} -u #{db['username']} -p#{db['password']} #{db['database']}")
|
84
|
+
end
|
85
|
+
|
86
|
+
def dbcmd(args)
|
87
|
+
command = (environment == 'development') ? "system" : "run"
|
88
|
+
send(command, args)
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
|
3
|
+
desc "Default deployment"
|
4
|
+
task :default, :roles => :app do
|
5
|
+
switch_cache
|
6
|
+
update_cache
|
7
|
+
copy_cache
|
8
|
+
move_source
|
9
|
+
symnlink
|
10
|
+
end
|
11
|
+
|
12
|
+
task :rollback, :roles => :app do
|
13
|
+
revert_source
|
14
|
+
end
|
15
|
+
|
16
|
+
##### HELPER METHODS #####
|
17
|
+
|
18
|
+
def switch_cache
|
19
|
+
svnrevision = ENV['revision'].nil? ? "" : "-r #{ENV['revision']}"
|
20
|
+
run("svn -q --username=#{svn['username']} --password=#{svn['password']} #{svnrevision} switch #{svn['repository']} #{cache_dir};")
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_cache
|
24
|
+
run("svn -q --username=#{svn['username']} --password=#{svn['password']} update #{cache_dir};")
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_cache
|
28
|
+
command = "rm -rf #{current_dir}.old;"
|
29
|
+
command += "cp -frp #{cache_dir}/public #{current_dir}.new;"
|
30
|
+
run(command)
|
31
|
+
end
|
32
|
+
|
33
|
+
def move_source
|
34
|
+
command = "mv #{current_dir} #{current_dir}.old;"
|
35
|
+
command += "mv #{current_dir}.new #{current_dir};"
|
36
|
+
run(command)
|
37
|
+
end
|
38
|
+
|
39
|
+
def symlink
|
40
|
+
send('symlink_' + framework)
|
41
|
+
end
|
42
|
+
|
43
|
+
def symlink_drupal
|
44
|
+
command = "rm -rf #{current_dir}/sites/all/files;"
|
45
|
+
command += "ln -s #{shared_dir}/files #{current_dir}/sites/all/files;"
|
46
|
+
command += "ln -s #{shared_dir}/settings.php #{current_dir}/sites/#{domain}/settings.php;"
|
47
|
+
run(command)
|
48
|
+
end
|
49
|
+
|
50
|
+
def symlink_yii
|
51
|
+
command = "rm -rf #{current_dir}/sites/all/files;"
|
52
|
+
command += "ln -s #{shared_dir}/files #{current_dir}/sites/all/files;"
|
53
|
+
command += "ln -s #{shared_dir}/settings.php #{current_dir}/sites/#{domain}/settings.php;"
|
54
|
+
run(command)
|
55
|
+
end
|
56
|
+
|
57
|
+
def refresh_cache
|
58
|
+
command = "chmod 755 #{current_dir}/scripts/drupal.sh;"
|
59
|
+
command += "#{current_dir}/scripts/drupal.sh --root #{current_dir} http://#{domain}/dev/cache;"
|
60
|
+
run(command)
|
61
|
+
end
|
62
|
+
|
63
|
+
def revert_source
|
64
|
+
command = "rm -rf #{current_dir};"
|
65
|
+
command += "mv #{current_dir}.old #{current_dir};"
|
66
|
+
command += "mkdir #{current_dir}.old;"
|
67
|
+
run(command)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
namespace :hosting do
|
2
|
+
|
3
|
+
desc "Setup"
|
4
|
+
task :setup do
|
5
|
+
command = "svn -q --username=#{svn['username']} --password=#{svn['password']} checkout #{svn['repository']} #{deploy_dir}/cache;"
|
6
|
+
command += "rm -rf #{current_dir};"
|
7
|
+
command += "mkdir #{shared_dir};"
|
8
|
+
command += "mkdir #{current_dir};"
|
9
|
+
command += "mkdir #{current_dir}.old;"
|
10
|
+
command += "mkdir #{tmp_dir};"
|
11
|
+
command += "echo '#{domain}' > #{deploy_dir}/web/index.htm;"
|
12
|
+
run(command)
|
13
|
+
send(framework + '_config')
|
14
|
+
send(framework + '_setup')
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Teardown"
|
18
|
+
task :teardown do
|
19
|
+
command = "rm -rf cache;"
|
20
|
+
command += "rm -rf shared;"
|
21
|
+
command += "rm -rf tmp;"
|
22
|
+
command += "rm -rf web;"
|
23
|
+
command += "rm -rf web.old;"
|
24
|
+
run(command)
|
25
|
+
end
|
26
|
+
|
27
|
+
##### CONFIG METHODS #####
|
28
|
+
|
29
|
+
def drupal_config
|
30
|
+
template = "<?php\n"
|
31
|
+
template += "$db_url = \"mysqli://#{db['username']}:#{db['password']}@#{db['host']}/#{db['database']}\";\n"
|
32
|
+
template += "include_once(\"#{current_dir}/sites/all/settings.php\");\n"
|
33
|
+
template += "?>"
|
34
|
+
config = ERB.new(template)
|
35
|
+
put config.result(binding), "#{shared_dir}/settings.php"
|
36
|
+
end
|
37
|
+
|
38
|
+
def yii_config
|
39
|
+
template = "<?php\n"
|
40
|
+
template += "$db_url = \"mysqli://#{db['username']}:#{db['password']}@#{db['host']}/#{db['database']}\";\n"
|
41
|
+
template += "include_once(\"#{current_dir}/sites/all/settings.php\");\n"
|
42
|
+
template += "?>"
|
43
|
+
config = ERB.new(template)
|
44
|
+
put config.result(binding), "#{shared_dir}/local.php"
|
45
|
+
end
|
46
|
+
|
47
|
+
##### SETUP METHODS #####
|
48
|
+
|
49
|
+
def drupal_setup
|
50
|
+
command = "mkdir -m777 #{shared_dir}/files;"
|
51
|
+
command += "mkdir -m777 #{shared_dir}/files/temp;"
|
52
|
+
run(command)
|
53
|
+
end
|
54
|
+
|
55
|
+
def yii_setup
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/lib/recipes/sync.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
namespace :sync do
|
2
|
+
|
3
|
+
task :default do
|
4
|
+
database
|
5
|
+
assets
|
6
|
+
end
|
7
|
+
|
8
|
+
task :database, :roles => :db do
|
9
|
+
dump_database
|
10
|
+
download_database
|
11
|
+
populate_database
|
12
|
+
end
|
13
|
+
|
14
|
+
task :assets, :roles => :app do
|
15
|
+
dump_assets
|
16
|
+
download_assets
|
17
|
+
populate assets
|
18
|
+
end
|
19
|
+
|
20
|
+
##### HELPER METHODS #####
|
21
|
+
|
22
|
+
def dump_database
|
23
|
+
command = "#{mysqldump} -u #{db['username']} -p#{db['password']} -h #{db['host']} #{db['database']} > #{tmp_dir}/database.sql;"
|
24
|
+
command += "cd #{tmp_dir};"
|
25
|
+
command += "tar -czf backup.tgz database.sql;"
|
26
|
+
command += "rm -rf database.sql;"
|
27
|
+
run(command)
|
28
|
+
end
|
29
|
+
|
30
|
+
def download_database
|
31
|
+
get "#{tmp_dir}/backup.tgz", "#{local_tmp_dir}/backup.tgz"
|
32
|
+
end
|
33
|
+
|
34
|
+
def populate_database
|
35
|
+
system("tar -xzf ./tmp/backup.tgz -C ./tmp")
|
36
|
+
system("cat #{local_tmp_dir}/database.sql | #{mysql} -u #{local_db['username']} -p#{local_db['password']} -h #{local_db['host']} #{local_db['database']}")
|
37
|
+
system("rm -rf ./tmp/*")
|
38
|
+
end
|
39
|
+
|
40
|
+
def dump_assets
|
41
|
+
send("dump_"+framework+"_assets")
|
42
|
+
end
|
43
|
+
|
44
|
+
def dump_drupal_assets
|
45
|
+
command = "cd #{shared_dir};"
|
46
|
+
command += "tar -czf assets.tgz files;"
|
47
|
+
command += "mv assets.tgz #{tmp_dir}/assets.tgz;"
|
48
|
+
run(command)
|
49
|
+
end
|
50
|
+
|
51
|
+
def dump_yii_assets
|
52
|
+
end
|
53
|
+
|
54
|
+
def download_assets
|
55
|
+
get "#{tmp_dir}/assets.tgz", "#{local_tmp_dir}/assets.tgz"
|
56
|
+
end
|
57
|
+
|
58
|
+
def populate_assets
|
59
|
+
send("populate_"+framework+"_assets")
|
60
|
+
end
|
61
|
+
|
62
|
+
def populate_drupal_assets
|
63
|
+
system("tar -xzf ./tmp/assets.tgz -C ./tmp")
|
64
|
+
system("mv ./tmp/files/* ./public/sites/all/files")
|
65
|
+
system("rm -rf ./tmp/*")
|
66
|
+
end
|
67
|
+
|
68
|
+
def populate_yii_assets
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :update do
|
2
|
+
|
3
|
+
desc "Default Update"
|
4
|
+
task :default do
|
5
|
+
system("svn -q --force --username=#{svn['username']} --password=#{svn['password']} export https://source.gorges.us/svn/gorges/capistrano/environments #{local_config_dir}/environments")
|
6
|
+
system("svn -q --force --username=#{svn['username']} --password=#{svn['password']} export https://source.gorges.us/svn/gorges/capistrano/recipes #{local_config_dir}/recipes")
|
7
|
+
system("svn -q --force --username=#{svn['username']} --password=#{svn['password']} export https://source.gorges.us/svn/gorges/capistrano/README #{local_config_dir}/README")
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gorges_capistrano_ext
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- ""
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-17 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: ""
|
23
|
+
email: ""
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- CHANGELOG
|
30
|
+
- LICENSE
|
31
|
+
- README
|
32
|
+
- lib/application.rb
|
33
|
+
- lib/config.sample.yml
|
34
|
+
- lib/environments/development.rb
|
35
|
+
- lib/environments/production.rb
|
36
|
+
- lib/environments/staging.rb
|
37
|
+
- lib/recipes/configure.rb
|
38
|
+
- lib/recipes/database.rb
|
39
|
+
- lib/recipes/deploy.rb
|
40
|
+
- lib/recipes/hosting.rb
|
41
|
+
- lib/recipes/sync.rb
|
42
|
+
- lib/recipes/update.rb
|
43
|
+
files:
|
44
|
+
- CHANGELOG
|
45
|
+
- LICENSE
|
46
|
+
- README
|
47
|
+
- Rakefile
|
48
|
+
- lib/application.rb
|
49
|
+
- lib/config.sample.yml
|
50
|
+
- lib/environments/development.rb
|
51
|
+
- lib/environments/production.rb
|
52
|
+
- lib/environments/staging.rb
|
53
|
+
- lib/recipes/configure.rb
|
54
|
+
- lib/recipes/database.rb
|
55
|
+
- lib/recipes/deploy.rb
|
56
|
+
- lib/recipes/hosting.rb
|
57
|
+
- lib/recipes/sync.rb
|
58
|
+
- lib/recipes/update.rb
|
59
|
+
- Manifest
|
60
|
+
- gorges_capistrano_ext.gemspec
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: ""
|
63
|
+
licenses: []
|
64
|
+
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --line-numbers
|
68
|
+
- --inline-source
|
69
|
+
- --title
|
70
|
+
- Gorges_capistrano_ext
|
71
|
+
- --main
|
72
|
+
- README
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 11
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 2
|
93
|
+
version: "1.2"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project: gorges_capistrano_ext
|
97
|
+
rubygems_version: 1.3.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: ""
|
101
|
+
test_files: []
|
102
|
+
|