capistrano-ash 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +22 -0
- data/VERSION +1 -1
- data/lib/ash/base.rb +38 -24
- data/lib/ash/drupal.rb +15 -10
- data/lib/ash/drupal_shared_hosting.rb +31 -0
- data/lib/ash/hosted_magento.rb +1 -0
- data/lib/ash/magento.rb +1 -0
- data/lib/ash/wordpress.rb +25 -14
- data/lib/ash/wordpress_shared_hosting.rb +32 -0
- data/lib/ash/zend_doctrine.rb +31 -22
- data/lib/ash/zend_doctrine_shared_hosting.rb +28 -0
- metadata +5 -2
data/README.textile
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
h2. Overview
|
2
|
+
|
3
|
+
Run the following commands in the command line from the project's root directory
|
4
|
+
|
5
|
+
<pre>
|
6
|
+
<code>
|
7
|
+
capify .
|
8
|
+
rm -Rf config/deploy.rb; mkdir -p config/deploy
|
9
|
+
touch config/deploy/staging.rb config/deploy/production.rb
|
10
|
+
</code>
|
11
|
+
</pre>
|
12
|
+
|
13
|
+
After you have edited your @Capfile@ and @staging.rb@ and @production.rb@ files, you will need to run the following command only once per environment:
|
14
|
+
|
15
|
+
<pre>
|
16
|
+
<code>
|
17
|
+
cap staging deploy:setup
|
18
|
+
cap production deploy:setup
|
19
|
+
</code>
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
|
1
23
|
h2. Deploying Magento
|
2
24
|
|
3
25
|
Check the "Wiki":https://github.com/augustash/capistrano-ash/wiki for detailed installation instructions.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/lib/ash/base.rb
CHANGED
@@ -4,7 +4,6 @@ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
|
4
4
|
|
5
5
|
# Required gems/libraries
|
6
6
|
require 'rubygems'
|
7
|
-
require 'railsless-deploy'
|
8
7
|
require 'ash/common'
|
9
8
|
require 'capistrano/ext/multistage'
|
10
9
|
|
@@ -92,8 +91,8 @@ configuration.load do
|
|
92
91
|
desc "Set standard permissions for Ash servers"
|
93
92
|
task :fixperms, :except => { :no_release => true } do
|
94
93
|
# chmod the files and directories.
|
95
|
-
|
96
|
-
|
94
|
+
try_sudo "find #{latest_release} -type d -exec chmod 755 {} \\;"
|
95
|
+
try_sudo "find #{latest_release} -type f -exec chmod 644 {} \\;"
|
97
96
|
end
|
98
97
|
|
99
98
|
desc "Test: Task used to verify Capistrano is working. Prints operating system name."
|
@@ -159,35 +158,50 @@ configuration.load do
|
|
159
158
|
web
|
160
159
|
end
|
161
160
|
|
162
|
-
desc
|
163
|
-
|
164
|
-
|
161
|
+
desc <<-DESC
|
162
|
+
Requires the rsync package to be installed.
|
163
|
+
|
164
|
+
Performs a file-level backup of the application and any assets \
|
165
|
+
from the shared directory that have been symlinked into the \
|
166
|
+
applications root or sub-directories.
|
165
167
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
168
|
+
You can specify which files or directories to exclude from being \
|
169
|
+
backed up (i.e., log files, sessions, cache) by setting the \
|
170
|
+
:backup_exclude variable
|
171
|
+
set(:backup_exclude) { [ "var/", "tmp/", logs/debug.log ] }
|
172
|
+
DESC
|
173
|
+
task :web, :roles => :web do
|
174
|
+
if previous_release
|
175
|
+
puts "Backing up web files (user uploaded content and previous release)"
|
176
|
+
|
177
|
+
if backup_exclude.present?
|
178
|
+
logger.debug "processing backup exclusions..."
|
179
|
+
backup_exclude.each do |pattern|
|
180
|
+
exclude_string << "--exclude '#{pattern}' "
|
181
|
+
end
|
182
|
+
logger.debug "Exclude string = #{exclude_string}"
|
170
183
|
end
|
171
|
-
|
184
|
+
|
185
|
+
# Copy the previous release to the /tmp directory
|
186
|
+
logger.debug "Copying previous release to the /tmp/#{release_name} directory"
|
187
|
+
run "rsync -avzrtpL #{exclude_string} #{current_path}/ /tmp/#{release_name}/"
|
188
|
+
# create the tarball of the previous release
|
189
|
+
set :archive_name, "release_B4_#{release_name}.tar.gz"
|
190
|
+
logger.debug "Creating a Tarball of the previous release in #{backups_path}/#{archive_name}"
|
191
|
+
run "cd /tmp && tar -cvpf - ./#{release_name}/ | gzip -c --best > #{backups_path}/#{archive_name}"
|
192
|
+
|
193
|
+
# remove the the temporary copy
|
194
|
+
logger.debug "Removing the tempory copy"
|
195
|
+
run "rm -rf /tmp/#{release_name}"
|
196
|
+
else
|
197
|
+
logger.important "no previous release to backup; backup of files skipped"
|
172
198
|
end
|
173
|
-
|
174
|
-
# Copy the previous release to the /tmp directory
|
175
|
-
logger.debug "Copying previous release to the /tmp/#{release_name} directory"
|
176
|
-
run "rsync -avzrtpL #{exclude_string} #{current_path}/ /tmp/#{release_name}/"
|
177
|
-
# create the tarball of the previous release
|
178
|
-
set :archive_name, "release_B4_#{release_name}.tar.gz"
|
179
|
-
logger.debug "Creating a Tarball of the previous release in #{backups_path}/#{archive_name}"
|
180
|
-
run "cd /tmp && tar -cvpf - ./#{release_name}/ | gzip -c --best > #{backups_path}/#{archive_name}"
|
181
|
-
|
182
|
-
# remove the the temporary copy
|
183
|
-
logger.debug "Removing the tempory copy"
|
184
|
-
run "rm -rf /tmp/#{release_name}"
|
185
199
|
end
|
186
200
|
|
187
201
|
desc "Perform a backup of database files"
|
188
202
|
task :db, :roles => :db do
|
189
203
|
puts "Backing up the database now and putting dump file in the previous release directory"
|
190
|
-
# define the filename (include the current_path so the dump file will be within the
|
204
|
+
# define the filename (include the current_path so the dump file will be within the directory)
|
191
205
|
filename = "#{current_path}/#{dbname}_dump-#{Time.now.to_s.gsub(/ /, "_")}.sql.gz"
|
192
206
|
# dump the database for the proper environment
|
193
207
|
run "mysqldump -u #{dbuser} -p #{dbname} | gzip -c --best > #{filename}" do |ch, stream, out|
|
data/lib/ash/drupal.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Require our base library.
|
2
2
|
require 'ash/base'
|
3
|
+
require 'railsless-deploy'
|
3
4
|
|
4
5
|
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
6
|
Capistrano::Configuration.instance(:must_exist) :
|
@@ -31,13 +32,15 @@ configuration.load do
|
|
31
32
|
desc "Setup shared application directories and permissions after initial setup"
|
32
33
|
task :setup_shared, :roles => :web do
|
33
34
|
# remove Capistrano specific directories
|
34
|
-
run
|
35
|
-
|
36
|
-
|
35
|
+
run<<-CMD
|
36
|
+
rm -Rf #{shared_path}/log &&
|
37
|
+
rm -Rf #{shared_path}/pids &&
|
38
|
+
rm -Rf #{shared_path}/system
|
39
|
+
CMD
|
37
40
|
|
38
41
|
# create shared directories
|
39
42
|
multisites.each_pair do |folder, url|
|
40
|
-
|
43
|
+
run "mkdir -p #{shared_path}/#{url}/files"
|
41
44
|
end
|
42
45
|
|
43
46
|
# set correct permissions
|
@@ -48,8 +51,8 @@ configuration.load do
|
|
48
51
|
task :finalize_update, :except => { :no_release => true } do
|
49
52
|
# remove shared directories
|
50
53
|
multisites.each_pair do |folder, url|
|
51
|
-
|
52
|
-
|
54
|
+
run "mv #{latest_release}/sites/#{folder} #{latest_release}/sites/#{url}"
|
55
|
+
run "rm -Rf #{latest_release}/sites/#{url}/files"
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
@@ -75,7 +78,7 @@ configuration.load do
|
|
75
78
|
task :db, :roles => :db do
|
76
79
|
puts "Backing up the database now and putting dump file in the previous release directory"
|
77
80
|
multisites.each_pair do |folder, url|
|
78
|
-
# define the filename (include the current_path so the dump file will be within the
|
81
|
+
# define the filename (include the current_path so the dump file will be within the directory)
|
79
82
|
filename = "#{current_path}/#{folder}_dump-#{Time.now.to_s.gsub(/ /, "_")}.sql.gz"
|
80
83
|
# dump the database for the proper environment
|
81
84
|
run "#{drush_bin} -l #{url} -r #{current_path} sql-dump | gzip -c --best > #{filename}"
|
@@ -90,9 +93,11 @@ configuration.load do
|
|
90
93
|
desc "Symlink shared directories"
|
91
94
|
task :symlink, :except => { :no_release => true } do
|
92
95
|
multisites.each_pair do |folder, url|
|
93
|
-
run
|
94
|
-
|
95
|
-
|
96
|
+
run<<-CMD
|
97
|
+
ln -nfs #{shared_path}/#{url}/files #{latest_release}/sites/#{url}/files &&
|
98
|
+
ln -nfs #{latest_release}/sites/#{url}/settings.php.#{stage} #{latest_release}/sites/#{url}/settings.php &&
|
99
|
+
#{drush_bin} -l #{url} -r #{current_path} vset --yes file_directory_path sites/#{url}/files
|
100
|
+
CMD
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Require our base drupal library
|
2
|
+
require 'ash/drupal'
|
3
|
+
|
4
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
|
+
Capistrano::Configuration.instance(:must_exist) :
|
6
|
+
Capistrano.configuration(:must_exist)
|
7
|
+
|
8
|
+
configuration.load do
|
9
|
+
# --------------------------------------------
|
10
|
+
# Overloaded Methods
|
11
|
+
# --------------------------------------------
|
12
|
+
namespace :deploy do
|
13
|
+
desc "Setup shared application directories and permissions after initial setup"
|
14
|
+
task :setup_shared, :roles => :web do
|
15
|
+
# remove Capistrano specific directories
|
16
|
+
run<<-CMD
|
17
|
+
rm -Rf #{shared_path}/log &&
|
18
|
+
rm -Rf #{shared_path}/pids &&
|
19
|
+
rm -Rf #{shared_path}/system
|
20
|
+
CMD
|
21
|
+
|
22
|
+
# create shared directories
|
23
|
+
multisites.each_pair do |folder, url|
|
24
|
+
run "mkdir -p #{shared_path}/#{url}/files"
|
25
|
+
end
|
26
|
+
|
27
|
+
# set correct permissions for a shared hosting environment
|
28
|
+
run "chmod -R 755 #{shared_path}/*"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ash/hosted_magento.rb
CHANGED
data/lib/ash/magento.rb
CHANGED
data/lib/ash/wordpress.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Require our base library.
|
2
2
|
require 'ash/base'
|
3
|
+
require 'railsless-deploy'
|
3
4
|
|
4
5
|
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
6
|
Capistrano::Configuration.instance(:must_exist) :
|
@@ -26,14 +27,17 @@ namespace :deploy do
|
|
26
27
|
desc "Setup shared application directories and permissions after initial setup"
|
27
28
|
task :setup_shared, :roles => :web do
|
28
29
|
# remove Capistrano specific directories
|
29
|
-
run
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
run<<-CMD
|
31
|
+
rm -Rf #{shared_path}/log &&
|
32
|
+
rm -Rf #{shared_path}/pids &&
|
33
|
+
rm -Rf #{shared_path}/system
|
34
|
+
CMD
|
35
|
+
|
33
36
|
# create shared directories
|
34
|
-
run
|
35
|
-
|
36
|
-
|
37
|
+
run<<-CMD
|
38
|
+
mkdir -p #{shared_path}/uploads &&
|
39
|
+
mkdir -p #{shared_path}/cache
|
40
|
+
CMD
|
37
41
|
# set correct permissions
|
38
42
|
run "chmod -R 777 #{shared_path}/*"
|
39
43
|
end
|
@@ -41,11 +45,16 @@ namespace :deploy do
|
|
41
45
|
desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes."
|
42
46
|
task :finalize_update, :except => { :no_release => true } do
|
43
47
|
# remove shared directories
|
44
|
-
run
|
45
|
-
|
48
|
+
run<<-CMD
|
49
|
+
rm -Rf #{latest_release}/#{uploads_path} &&
|
50
|
+
rm -Rf #{latest_release}/wp-content/cache
|
51
|
+
CMD
|
52
|
+
|
46
53
|
# Removing cruft files.
|
47
|
-
run
|
48
|
-
|
54
|
+
run<<-CMD
|
55
|
+
rm -Rf #{latest_release}/license.txt &&
|
56
|
+
rm -Rf #{latest_release}/readme.html
|
57
|
+
CMD
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
@@ -55,9 +64,11 @@ end
|
|
55
64
|
namespace :wordpress do
|
56
65
|
desc "Links the correct settings file"
|
57
66
|
task :symlink do
|
58
|
-
run
|
59
|
-
|
60
|
-
|
67
|
+
run<<-CMD
|
68
|
+
ln -nfs #{shared_path}/uploads #{current_release}/#{uploads_path} &&
|
69
|
+
ln -nfs #{shared_path}/cache #{current_release}/wp-content/cache &&
|
70
|
+
ln -nfs #{latest_release}/wp-config.php.#{stage} #{latest_release}/wp-config.php
|
71
|
+
CMD
|
61
72
|
end
|
62
73
|
|
63
74
|
desc "Set URL in database"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Require our base drupal library
|
2
|
+
require 'ash/wordpress'
|
3
|
+
|
4
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
|
+
Capistrano::Configuration.instance(:must_exist) :
|
6
|
+
Capistrano.configuration(:must_exist)
|
7
|
+
|
8
|
+
configuration.load do
|
9
|
+
# --------------------------------------------
|
10
|
+
# Overloaded Methods
|
11
|
+
# --------------------------------------------
|
12
|
+
namespace :deploy do
|
13
|
+
desc "Setup shared application directories and permissions after initial setup"
|
14
|
+
task :setup_shared, :roles => :web do
|
15
|
+
# remove Capistrano specific directories
|
16
|
+
run<<-CMD
|
17
|
+
rm -Rf #{shared_path}/log &&
|
18
|
+
rm -Rf #{shared_path}/pids &&
|
19
|
+
rm -Rf #{shared_path}/system
|
20
|
+
CMD
|
21
|
+
|
22
|
+
# create shared directories
|
23
|
+
run<<-CMD
|
24
|
+
mkdir -p #{shared_path}/uploads &&
|
25
|
+
mkdir -p #{shared_path}/cache
|
26
|
+
CMD
|
27
|
+
|
28
|
+
# set correct permissions
|
29
|
+
run "chmod -R 755 #{shared_path}/*"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ash/zend_doctrine.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Require our base library.
|
2
2
|
require 'ash/base'
|
3
|
+
require 'railsless-deploy'
|
4
|
+
|
3
5
|
|
4
6
|
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
7
|
Capistrano::Configuration.instance(:must_exist) :
|
@@ -20,38 +22,45 @@ configuration.load do
|
|
20
22
|
namespace :deploy do
|
21
23
|
desc "Setup shared directories and permissions after initial setup"
|
22
24
|
task :setup_shared, :roles => :web, :except => { :no_release => true } do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
run<<-CMD
|
26
|
+
mkdir -p #{shared_path}/var &&
|
27
|
+
mkdir -p #{shared_path}/var/logs &&
|
28
|
+
mkdir -p #{shared_path}/var/cache &&
|
29
|
+
mkdir -p #{shared_path}/var/sessions &&
|
30
|
+
mkdir -p #{shared_path}/system
|
31
|
+
CMD
|
32
|
+
try_sudo "chmod -R 777 #{shared_path}/*"
|
29
33
|
end
|
30
34
|
|
31
35
|
desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes."
|
32
36
|
task :finalize_update, :roles => :web, :except => { :no_release => true } do
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
# remove shared directories
|
38
|
+
run "rm -Rf #{latest_release}/var"
|
39
|
+
run "rm -Rf #{latest_release}/public/system"
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
namespace :zend do
|
40
44
|
desc "Symlink shared directories"
|
41
45
|
task :symlink, :except => { :no_release => true } do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
run<<-CMD
|
47
|
+
ln -nfs #{shared_path}/var #{current_release}/var &&
|
48
|
+
ln -nfs #{shared_path}/system #{current_release}/public/system &&
|
49
|
+
mv #{current_release}/application/configs/application.ini.dist #{current_release}/application/configs/application.ini &&
|
50
|
+
ln -nfs #{current_release}/application/Application.#{stage}.php #{current_release}/application/Application.php &&
|
51
|
+
mv #{current_release}/public/htaccess.#{stage} #{current_release}/public/.htaccess &&
|
52
|
+
cp #{current_release}/scripts/doctrine-cli.#{stage} #{current_release}/scripts/doctrine-cli
|
53
|
+
CMD
|
54
|
+
|
55
|
+
try_sudo "chmod +x #{current_release}/scripts/doctrine-cli"
|
56
|
+
|
57
|
+
# remove the example or other environment example files
|
58
|
+
run<<-CMD
|
59
|
+
rm -f #{current_release}/scripts/doctrine-cli.dist &&
|
60
|
+
rm -f #{current_release}/scripts/doctrine-cli.staging &&
|
61
|
+
rm -f #{current_release}/scripts/doctrine-cli.production &&
|
62
|
+
rm -f #{current_release}/application/Application.example.php
|
63
|
+
CMD
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Require our base drupal library
|
2
|
+
require 'ash/zend_doctrine'
|
3
|
+
|
4
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
5
|
+
Capistrano::Configuration.instance(:must_exist) :
|
6
|
+
Capistrano.configuration(:must_exist)
|
7
|
+
|
8
|
+
configuration.load do
|
9
|
+
# --------------------------------------------
|
10
|
+
# Overloaded Methods
|
11
|
+
# --------------------------------------------
|
12
|
+
namespace :deploy do
|
13
|
+
desc<<-DESC
|
14
|
+
Setup shared directories and permissions after initial setup \
|
15
|
+
for a shared hosting enviroment
|
16
|
+
DESC
|
17
|
+
task :setup_shared, :roles => :web, :except => { :no_release => true } do
|
18
|
+
run<<-CMD
|
19
|
+
mkdir -p #{shared_path}/var &&
|
20
|
+
mkdir -p #{shared_path}/var/logs &&
|
21
|
+
mkdir -p #{shared_path}/var/cache &&
|
22
|
+
mkdir -p #{shared_path}/var/sessions &&
|
23
|
+
mkdir -p #{shared_path}/system
|
24
|
+
CMD
|
25
|
+
try_sudo "chmod -R 755 #{shared_path}/*"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: capistrano-ash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- August Ash
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-19 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -31,10 +31,13 @@ files:
|
|
31
31
|
- lib/ash/base.rb
|
32
32
|
- lib/ash/common.rb
|
33
33
|
- lib/ash/drupal.rb
|
34
|
+
- lib/ash/drupal_shared_hosting.rb
|
34
35
|
- lib/ash/hosted_magento.rb
|
35
36
|
- lib/ash/magento.rb
|
36
37
|
- lib/ash/wordpress.rb
|
38
|
+
- lib/ash/wordpress_shared_hosting.rb
|
37
39
|
- lib/ash/zend_doctrine.rb
|
40
|
+
- lib/ash/zend_doctrine_shared_hosting.rb
|
38
41
|
has_rdoc: true
|
39
42
|
homepage: https://github.com/augustash/capistrano-ash
|
40
43
|
licenses: []
|