capistrano-ash 1.1.16 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/capistrano-ash.gemspec +10 -10
- data/lib/ash/base.rb +50 -12
- data/lib/ash/common.rb +10 -0
- data/lib/ash/magento.rb +4 -4
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.17
|
data/capistrano-ash.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.1.
|
7
|
+
s.name = "capistrano-ash"
|
8
|
+
s.version = "1.1.17"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["August Ash"]
|
12
|
+
s.date = "2012-04-06"
|
13
|
+
s.description = "August Ash recipes for Capistrano"
|
14
|
+
s.email = "code@augustash.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.textile"
|
17
17
|
]
|
@@ -32,10 +32,10 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/ash/zend_doctrine.rb",
|
33
33
|
"lib/ash/zend_doctrine_shared_hosting.rb"
|
34
34
|
]
|
35
|
-
s.homepage =
|
36
|
-
s.require_paths = [
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
35
|
+
s.homepage = "https://github.com/augustash/capistrano-ash"
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = "1.8.21"
|
38
|
+
s.summary = "Useful task libraries for August Ash recipes for Capistrano"
|
39
39
|
|
40
40
|
if s.respond_to? :specification_version then
|
41
41
|
s.specification_version = 3
|
data/lib/ash/base.rb
CHANGED
@@ -37,6 +37,8 @@ configuration.load do
|
|
37
37
|
set :dbuser, proc{text_prompt("Database username: ")}
|
38
38
|
set :dbpass, proc{Capistrano::CLI.password_prompt("Database password for '#{dbuser}':")}
|
39
39
|
set :dbname, proc{text_prompt("Database name: ")}
|
40
|
+
_cset :mysqldump, "mysqldump"
|
41
|
+
_cset :dump_options, "--single-transaction --create-options --quick"
|
40
42
|
|
41
43
|
# Source Control
|
42
44
|
set :group_writable, false
|
@@ -56,8 +58,9 @@ configuration.load do
|
|
56
58
|
set :pma_version, "3.4.5"
|
57
59
|
|
58
60
|
# Backups Path
|
59
|
-
_cset(:backups_path)
|
60
|
-
_cset(:
|
61
|
+
_cset(:backups_path) { File.join(deploy_to, "backups") }
|
62
|
+
_cset(:tmp_backups_path) { File.join("#{backups_path}", "tmp") }
|
63
|
+
_cset(:backups) { capture("ls -x #{backups_path}", :except => { :no_release => true }).split.sort }
|
61
64
|
|
62
65
|
# Define which files or directories you want to exclude from being backed up
|
63
66
|
_cset(:backup_exclude) { [] }
|
@@ -86,6 +89,25 @@ configuration.load do
|
|
86
89
|
# Overloaded tasks
|
87
90
|
# --------------------------------------------
|
88
91
|
namespace :deploy do
|
92
|
+
desc <<-DESC
|
93
|
+
Prepares one or more servers for deployment. Before you can use any \
|
94
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
95
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
96
|
+
you add a new server to your cluster, you can easily run the setup task \
|
97
|
+
on just that server by specifying the HOSTS environment variable:
|
98
|
+
|
99
|
+
$ cap HOSTS=new.server.com deploy:setup
|
100
|
+
|
101
|
+
It is safe to run this task on servers that have already been set up; it \
|
102
|
+
will not destroy any deployed revisions or data.
|
103
|
+
DESC
|
104
|
+
task :setup, :except => { :no_release => true } do
|
105
|
+
dirs = [deploy_to, releases_path, shared_path]
|
106
|
+
dirs += shared_children.map { |d| File.join(shared_path, d.split('/').last) }
|
107
|
+
run "#{try_sudo} mkdir -p #{dirs.join(' ')}"
|
108
|
+
run "#{try_sudo} chmod 755 #{dirs.join(' ')}" if fetch(:group_writable, true)
|
109
|
+
end
|
110
|
+
|
89
111
|
desc "Setup shared application directories and permissions after initial setup"
|
90
112
|
task :setup_shared do
|
91
113
|
puts "STUB: Setup"
|
@@ -93,7 +115,7 @@ configuration.load do
|
|
93
115
|
|
94
116
|
desc "Setup backup directory for database and web files"
|
95
117
|
task :setup_backup, :except => { :no_release => true } do
|
96
|
-
run "#{try_sudo} mkdir -p #{backups_path} && #{try_sudo} chmod
|
118
|
+
run "#{try_sudo} mkdir -p #{backups_path} && #{try_sudo} chmod 755 #{backups_path}"
|
97
119
|
end
|
98
120
|
end
|
99
121
|
|
@@ -104,8 +126,8 @@ configuration.load do
|
|
104
126
|
desc "Set standard permissions for Ash servers"
|
105
127
|
task :fixperms, :roles => :web, :except => { :no_release => true } do
|
106
128
|
# chmod the files and directories.
|
107
|
-
|
108
|
-
|
129
|
+
set_perms_dirs("#{latest_release}")
|
130
|
+
set_perms_files("#{latest_release}")
|
109
131
|
end
|
110
132
|
|
111
133
|
desc "Test: Task used to verify Capistrano is working. Prints operating system name."
|
@@ -181,7 +203,10 @@ configuration.load do
|
|
181
203
|
end
|
182
204
|
|
183
205
|
task :local_export do
|
184
|
-
|
206
|
+
mysqldump = fetch(:mysqldump, "mysqldump")
|
207
|
+
dump_options = fetch(:dump_options, "--single-transaction --create-options --quick")
|
208
|
+
|
209
|
+
system "#{mysqldump} #{dump_options} --opt -h#{db_local_host} -u#{db_local_user} -p#{db_local_pass} #{db_local_name} | gzip -c --best > #{db_local_name}.sql.gz"
|
185
210
|
end
|
186
211
|
|
187
212
|
desc "Upload locally created MySQL dumpfile to remote server via SCP"
|
@@ -211,7 +236,10 @@ configuration.load do
|
|
211
236
|
|
212
237
|
desc "Create a compressed MySQL dumpfile of the remote database"
|
213
238
|
task :remote_export, :roles => :db do
|
214
|
-
|
239
|
+
mysqldump = fetch(:mysqldump, "mysqldump")
|
240
|
+
dump_options = fetch(:dump_options, "--single-transaction --create-options --quick")
|
241
|
+
|
242
|
+
run "#{mysqldump} #{dump_options} --opt -h#{db_remote_host} -u#{db_remote_user} -p#{db_remote_pass} #{db_remote_name} | gzip -c --best > #{deploy_to}/#{db_remote_name}.sql.gz"
|
215
243
|
end
|
216
244
|
|
217
245
|
desc "Download remotely created MySQL dumpfile to local machine via SCP"
|
@@ -253,6 +281,7 @@ configuration.load do
|
|
253
281
|
task :default do
|
254
282
|
db
|
255
283
|
web
|
284
|
+
cleanup
|
256
285
|
end
|
257
286
|
|
258
287
|
desc <<-DESC
|
@@ -280,16 +309,16 @@ configuration.load do
|
|
280
309
|
end
|
281
310
|
|
282
311
|
# Copy the previous release to the /tmp directory
|
283
|
-
logger.debug "Copying previous release to the
|
284
|
-
run "rsync -avzrtpL #{exclude_string} #{current_path}/
|
312
|
+
logger.debug "Copying previous release to the #{tmp_backups_path}/#{release_name} directory"
|
313
|
+
run "rsync -avzrtpL #{exclude_string} #{current_path}/ #{tmp_backups_path}/#{release_name}/"
|
285
314
|
# create the tarball of the previous release
|
286
315
|
set :archive_name, "release_B4_#{release_name}.tar.gz"
|
287
316
|
logger.debug "Creating a Tarball of the previous release in #{backups_path}/#{archive_name}"
|
288
|
-
run "cd
|
317
|
+
run "cd #{tmp_backups_path} && tar -cvpf - ./#{release_name}/ | gzip -c --best > #{backups_path}/#{archive_name}"
|
289
318
|
|
290
319
|
# remove the the temporary copy
|
291
320
|
logger.debug "Removing the tempory copy"
|
292
|
-
run "rm -rf
|
321
|
+
run "rm -rf #{tmp_backups_path}/#{release_name}"
|
293
322
|
else
|
294
323
|
logger.important "no previous release to backup; backup of files skipped"
|
295
324
|
end
|
@@ -298,11 +327,14 @@ configuration.load do
|
|
298
327
|
desc "Perform a backup of database files"
|
299
328
|
task :db, :roles => :db do
|
300
329
|
if previous_release
|
330
|
+
mysqldump = fetch(:mysqldump, "mysqldump")
|
331
|
+
dump_options = fetch(:dump_options, "--single-transaction --create-options --quick")
|
332
|
+
|
301
333
|
puts "Backing up the database now and putting dump file in the previous release directory"
|
302
334
|
# define the filename (include the current_path so the dump file will be within the directory)
|
303
335
|
filename = "#{current_path}/#{dbname}_dump-#{Time.now.to_s.gsub(/ /, "_")}.sql.gz"
|
304
336
|
# dump the database for the proper environment
|
305
|
-
run "mysqldump -u #{dbuser} -p #{dbname} | gzip -c --best > #{filename}" do |ch, stream, out|
|
337
|
+
run "#{mysqldump} #{dump_options} -u #{dbuser} -p #{dbname} | gzip -c --best > #{filename}" do |ch, stream, out|
|
306
338
|
ch.send_data "#{dbpass}\n" if out =~ /^Enter password:/
|
307
339
|
end
|
308
340
|
else
|
@@ -327,6 +359,12 @@ configuration.load do
|
|
327
359
|
archives = (backups - backups.last(count)).map { |backup|
|
328
360
|
File.join(backups_path, backup) }.join(" ")
|
329
361
|
|
362
|
+
# fix permissions on the the files and directories before removing them
|
363
|
+
archives.split(" ").each do |backup|
|
364
|
+
set_perms_dirs("#{backup}", 755)
|
365
|
+
set_perms_files("#{backup}", 644)
|
366
|
+
end
|
367
|
+
|
330
368
|
try_sudo "rm -rf #{archives}"
|
331
369
|
end
|
332
370
|
end
|
data/lib/ash/common.rb
CHANGED
@@ -41,3 +41,13 @@ end
|
|
41
41
|
def remote_dir_exists?(dir_path)
|
42
42
|
'true' == capture("if [[ -d #{dir_path} ]]; then echo 'true'; fi").strip
|
43
43
|
end
|
44
|
+
|
45
|
+
# set the permissions for files recurisvely from the starting directory (dir_path)
|
46
|
+
def set_perms_files(dir_path, perm = 644)
|
47
|
+
try_sudo "find #{dir_path} -type f -exec chmod #{perm} {} \\;"
|
48
|
+
end
|
49
|
+
|
50
|
+
# set the permissions for directories recurisvely from the starting directory (dir_path)
|
51
|
+
def set_perms_dirs(dir_path, perm = 755)
|
52
|
+
try_sudo "find #{dir_path} -type d -exec chmod #{perm} {} \\;"
|
53
|
+
end
|
data/lib/ash/magento.rb
CHANGED
@@ -94,10 +94,10 @@ configuration.load do
|
|
94
94
|
|
95
95
|
desc "Symlink shared directories"
|
96
96
|
task :symlink, :roles => :web, :except => { :no_release => true } do
|
97
|
-
run "ln -nfs #{shared_path}/includes #{
|
98
|
-
run "ln -nfs #{shared_path}/media #{
|
99
|
-
run "ln -nfs #{shared_path}/sitemap #{
|
100
|
-
run "ln -nfs #{shared_path}/var #{
|
97
|
+
run "ln -nfs #{shared_path}/includes #{latest_release}/includes"
|
98
|
+
run "ln -nfs #{shared_path}/media #{latest_release}/media"
|
99
|
+
run "ln -nfs #{shared_path}/sitemap #{latest_release}/sitemap"
|
100
|
+
run "ln -nfs #{shared_path}/var #{latest_release}/var"
|
101
101
|
end
|
102
102
|
|
103
103
|
desc "Purge Magento cache directory"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: August Ash recipes for Capistrano
|
15
15
|
email: code@augustash.com
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 1.8.
|
56
|
+
rubygems_version: 1.8.21
|
57
57
|
signing_key:
|
58
58
|
specification_version: 3
|
59
59
|
summary: Useful task libraries for August Ash recipes for Capistrano
|