capistrano-ash 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/capistrano-ash.gemspec +3 -2
- data/lib/ash/base.rb +116 -12
- data/lib/ash/common.rb +7 -0
- data/lib/ash/drupal.rb +17 -6
- data/lib/ash/magento.rb +107 -0
- metadata +4 -3
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/capistrano-ash.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{capistrano-ash}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["August Ash"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-15}
|
13
13
|
s.description = %q{August Ash recipes for Capistrano}
|
14
14
|
s.email = %q{jake@augustash.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"lib/ash/base.rb",
|
25
25
|
"lib/ash/common.rb",
|
26
26
|
"lib/ash/drupal.rb",
|
27
|
+
"lib/ash/magento.rb",
|
27
28
|
"lib/ash/zend_doctrine.rb"
|
28
29
|
]
|
29
30
|
s.homepage = %q{https://github.com/augustash/capistrano-ash}
|
data/lib/ash/base.rb
CHANGED
@@ -1,51 +1,155 @@
|
|
1
|
+
# Capistrano2 differentiator
|
2
|
+
load 'deploy' if respond_to?(:namespace)
|
3
|
+
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
4
|
+
|
1
5
|
# Required gems/libraries
|
2
6
|
require 'rubygems'
|
3
7
|
require 'railsless-deploy'
|
4
8
|
require 'ash/common'
|
5
9
|
require 'capistrano/ext/multistage'
|
6
10
|
|
11
|
+
# Bootstrap Capistrano instance
|
7
12
|
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
8
13
|
Capistrano::Configuration.instance(:must_exist) :
|
9
14
|
Capistrano.configuration(:must_exist)
|
10
15
|
|
11
16
|
configuration.load do
|
12
17
|
|
13
|
-
#
|
18
|
+
# Set default stages
|
14
19
|
set :stages, %w(staging production)
|
15
20
|
set :default_stge, "staging"
|
16
21
|
|
17
22
|
# --------------------------------------------
|
18
|
-
#
|
23
|
+
# Task chains
|
19
24
|
# --------------------------------------------
|
20
|
-
|
21
|
-
|
25
|
+
after "deploy:setup", "deploy:setup_shared"
|
26
|
+
after "deploy", "deploy:cleanup"
|
27
|
+
|
28
|
+
# --------------------------------------------
|
29
|
+
# Default variables
|
30
|
+
# --------------------------------------------
|
31
|
+
# SSH
|
32
|
+
set :user, proc{text_prompt("SSH username: ")}
|
33
|
+
set :password, proc{Capistrano::CLI.password_prompt("SSH password for '#{user}':")}
|
34
|
+
|
35
|
+
# Database
|
36
|
+
set :dbuser, proc{text_prompt("Database username: ")}
|
37
|
+
set :dbpass, proc{Capistrano::CLI.password_prompt("Database password for '#{dbuser}':")}
|
38
|
+
set :dbname, proc{text_prompt("Database name: ")}
|
39
|
+
|
40
|
+
# Source Control
|
22
41
|
set :group_writable, false
|
23
42
|
set :use_sudo, false
|
24
43
|
set :scm, :subversion
|
25
44
|
set :scm_verbose, true
|
45
|
+
set :scm_username, proc{text_prompt("Subversion username: ")}
|
46
|
+
set :scm_password, proc{Capistrano::CLI.password_prompt("Subversion password for '#{scm_username}': ")}
|
47
|
+
set :keep_releases, 3
|
48
|
+
set :deploy_via, :remote_cache
|
49
|
+
set :copy_strategy, :checkout
|
50
|
+
set :copy_compression, :bz2
|
51
|
+
set :copy_exclude, [".svn", ".DS_Store", "*.sample", "LICENSE*", "Capfile",
|
52
|
+
"config", "*.rb", "*.sql", "nbproject", "_template"]
|
53
|
+
# phpMyAdmin version
|
54
|
+
set :pma_version, "3.3.8"
|
26
55
|
|
27
|
-
# show password requests on windows
|
56
|
+
# show password requests on windows
|
57
|
+
# (http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1)
|
28
58
|
default_run_options[:pty] = true
|
29
59
|
|
30
60
|
# --------------------------------------------
|
31
|
-
#
|
61
|
+
# Overloaded tasks
|
62
|
+
# --------------------------------------------
|
63
|
+
namespace :deploy do
|
64
|
+
desc "Setup shared application directories and permissions after initial setup"
|
65
|
+
task :setup_shared do
|
66
|
+
puts "STUB: Setup"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# --------------------------------------------
|
71
|
+
# Ash tasks
|
32
72
|
# --------------------------------------------
|
33
73
|
namespace :ash do
|
34
|
-
desc "
|
74
|
+
desc "Set standard permissions for Ash servers"
|
35
75
|
task :fixperms, :except => { :no_release => true } do
|
36
76
|
# chmod the files and directories.
|
37
|
-
|
38
|
-
|
77
|
+
sudo "find #{latest_release} -type d -exec chmod 755 {} \\;"
|
78
|
+
sudo "find #{latest_release} -type f -exec chmod 644 {} \\;"
|
39
79
|
end
|
40
80
|
|
41
|
-
desc "Task
|
81
|
+
desc "Test: Task used to verify Capistrano is working. Prints operating system name."
|
42
82
|
task :uname do
|
43
83
|
run "uname -a"
|
44
84
|
end
|
45
85
|
|
46
|
-
desc "
|
86
|
+
desc "Test: Task used to verify Capistrano is working. Prints environment of Capistrano user."
|
47
87
|
task :getpath do
|
48
88
|
run "echo $PATH"
|
49
89
|
end
|
50
90
|
end
|
51
|
-
|
91
|
+
|
92
|
+
# --------------------------------------------
|
93
|
+
# PHP tasks
|
94
|
+
# --------------------------------------------
|
95
|
+
namespace :php do
|
96
|
+
namespace :apc do
|
97
|
+
desc "Disable the APC administrative panel"
|
98
|
+
task :disable, :except => { :no_release => true } do
|
99
|
+
run "rm #{current_path}/apc.php"
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "Enable the APC administrative panel"
|
103
|
+
task :enable, :except => { :no_release => true } do
|
104
|
+
run "ln -s /usr/local/lib/php/apc.php #{current_path}/apc.php"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# --------------------------------------------
|
110
|
+
# phpMyAdmin tasks
|
111
|
+
# --------------------------------------------
|
112
|
+
namespace :pma do
|
113
|
+
desc "Disable the phpMyAdmin utility"
|
114
|
+
task :disable, :roles => :web, :except => { :no_release => true } do
|
115
|
+
run "rm -f #{current_path}/pma"
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "Enable the phpMyAdmin utility"
|
119
|
+
task :enable, :roles => :web, :except => { :no_release => true } do
|
120
|
+
run "ln -s #{shared_path}/pma #{current_path}/pma"
|
121
|
+
end
|
122
|
+
|
123
|
+
desc "Install phpMyAdmin utility"
|
124
|
+
task :install, :roles => :web do
|
125
|
+
# fetch PMA
|
126
|
+
run "wget -O #{shared_path}/pma.tar.gz http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/#{pma_version}/phpMyAdmin-#{pma_version}-english.tar.gz"
|
127
|
+
# decompress and install
|
128
|
+
run "tar -zxf #{shared_path}/pma.tar.gz -C #{shared_path}"
|
129
|
+
run "mv #{shared_path}/phpMyAdmin-#{pma_version}-english/ #{shared_path}/pma/"
|
130
|
+
run "rm -f #{shared_path}/pma.tar.gz"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# --------------------------------------------
|
135
|
+
# Backup tasks
|
136
|
+
# --------------------------------------------
|
137
|
+
namespace :backup do
|
138
|
+
desc "Perform a backup of web and database files"
|
139
|
+
task :default do
|
140
|
+
web
|
141
|
+
db
|
142
|
+
end
|
143
|
+
|
144
|
+
desc "Perform a backup of web files"
|
145
|
+
task :web, :roles => :web do
|
146
|
+
puts "STUB: Backing up web server"
|
147
|
+
end
|
148
|
+
|
149
|
+
desc "Perform a backup of database files"
|
150
|
+
task :db, :roles => :db do
|
151
|
+
puts "STUB: Backing up db server"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
data/lib/ash/common.rb
CHANGED
data/lib/ash/drupal.rb
CHANGED
@@ -10,12 +10,15 @@ configuration.load do
|
|
10
10
|
# --------------------------------------------
|
11
11
|
# Setting defaults
|
12
12
|
# --------------------------------------------
|
13
|
-
_cset :multisites, {"default" => "
|
13
|
+
proc{_cset( :multisites, {"default" => "#{application}"} )}
|
14
|
+
set :drush_bin, "drush"
|
14
15
|
|
15
16
|
# --------------------------------------------
|
16
17
|
# Calling our Methods
|
17
18
|
# --------------------------------------------
|
18
19
|
after "deploy:setup", "deploy:setup_shared"
|
20
|
+
after "deploy:finalize_update", "ash:fixperms"
|
21
|
+
after "ash:fixperms", "drupal:protect"
|
19
22
|
after "deploy:symlink", "drupal:symlink"
|
20
23
|
after "deploy", "drupal:clearcache"
|
21
24
|
after "deploy", "deploy:cleanup"
|
@@ -53,14 +56,14 @@ namespace :deploy do
|
|
53
56
|
desc "Disable the application and show a message screen"
|
54
57
|
task :disable do
|
55
58
|
multisites.each_pair do |folder, url|
|
56
|
-
run "
|
59
|
+
run "#{drush_bin} -l #{url} -r #{latest_release} vset --yes site_offline 1"
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
63
|
desc "Enable the application and remove the message screen"
|
61
64
|
task :enable do
|
62
65
|
multisites.each_pair do |folder, url|
|
63
|
-
run "
|
66
|
+
run "#{drush_bin} -l #{url} -r #{latest_release} vdel --yes site_offline"
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
@@ -75,23 +78,31 @@ namespace :drupal do
|
|
75
78
|
multisites.each_pair do |folder, url|
|
76
79
|
run "ln -nfs #{shared_path}/#{url}/files #{current_release}/sites/#{url}/files"
|
77
80
|
run "ln -nfs #{latest_release}/sites/#{url}/settings.php.#{stage} #{latest_release}/sites/#{url}/settings.php"
|
78
|
-
run "
|
81
|
+
run "#{drush_bin} -l #{url} -r #{current_path} vset --yes file_directory_path sites/#{url}/files"
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
85
|
desc "Replace local database paths with remote paths"
|
83
86
|
task :updatedb, :except => { :no_release => true } do
|
84
87
|
multisites.each_pair do |folder, url|
|
85
|
-
run "
|
88
|
+
run "#{drush_bin} -l #{url} -r #{current_path} sqlq \"UPDATE {files} SET filepath = REPLACE(filepath,'sites/#{folder}/files','sites/#{url}/files');\""
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
89
92
|
desc "Clear all Drupal cache"
|
90
93
|
task :clearcache, :except => { :no_release => true } do
|
91
94
|
multisites.each_pair do |folder, url|
|
92
|
-
run "
|
95
|
+
run "#{drush_bin} -l #{url} -r #{current_path} cache-clear all"
|
93
96
|
end
|
94
97
|
end
|
98
|
+
|
99
|
+
desc "Protect system files"
|
100
|
+
task :protect, :except => { :no_release => true } do
|
101
|
+
multisites.each_pair do |folder, url|
|
102
|
+
run "chmod 644 #{latest_release}/sites/#{url}/settings.php*"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
95
106
|
end
|
96
107
|
|
97
108
|
end
|
data/lib/ash/magento.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# Required base libraries
|
2
|
+
require 'ash/base'
|
3
|
+
|
4
|
+
# Bootstrap Capistrano instance
|
5
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
6
|
+
Capistrano::Configuration.instance(:must_exist) :
|
7
|
+
Capistrano.configuration(:must_exist)
|
8
|
+
|
9
|
+
configuration.load do
|
10
|
+
# --------------------------------------------
|
11
|
+
# Task chains
|
12
|
+
# --------------------------------------------
|
13
|
+
after "deploy:setup_shared", "pma:install"
|
14
|
+
after "deploy:finalize_update", "magento:activate_config"
|
15
|
+
after "deploy:symlink", "magento:symlink"
|
16
|
+
after "deploy", "magento:purge_cache"
|
17
|
+
|
18
|
+
# --------------------------------------------
|
19
|
+
# Overloaded tasks
|
20
|
+
# --------------------------------------------
|
21
|
+
namespace :deploy do
|
22
|
+
desc "Setup shared application directories and permissions after initial setup"
|
23
|
+
task :setup_shared do
|
24
|
+
# remove Capistrano specific directories
|
25
|
+
run "rm -Rf #{shared_path}/log"
|
26
|
+
run "rm -Rf #{shared_path}/pids"
|
27
|
+
run "rm -Rf #{shared_path}/system"
|
28
|
+
|
29
|
+
# create shared directories
|
30
|
+
run "mkdir -p #{shared_path}/includes"
|
31
|
+
run "mkdir -p #{shared_path}/media"
|
32
|
+
run "mkdir -p #{shared_path}/sitemap"
|
33
|
+
run "mkdir -p #{shared_path}/var"
|
34
|
+
|
35
|
+
# set correct permissions
|
36
|
+
run "chmod 777 #{shared_path}/*"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes."
|
40
|
+
task :finalize_update, :except => { :no_release => true } do
|
41
|
+
# synchronize media directory with shared data
|
42
|
+
sudo "rsync -rltDvzog #{latest_release}/media/ #{shared_path}/media/"
|
43
|
+
sudo "chmod -R 777 #{shared_path}/media/"
|
44
|
+
|
45
|
+
# remove directories that will be shared
|
46
|
+
run "rm -Rf #{latest_release}/includes"
|
47
|
+
run "rm -Rf #{latest_release}/media"
|
48
|
+
run "rm -Rf #{latest_release}/sitemap"
|
49
|
+
run "rm -Rf #{latest_release}/var"
|
50
|
+
|
51
|
+
# set the file and directory permissions
|
52
|
+
ash.fixperms
|
53
|
+
run "chmod 400 #{latest_release}/pear"
|
54
|
+
run "chmod o+w #{latest_release}/app/etc"
|
55
|
+
end
|
56
|
+
|
57
|
+
namespace :web do
|
58
|
+
desc "Disable the application and show a message screen"
|
59
|
+
task :disable, :except => { :no_release => true } do
|
60
|
+
run "touch #{current_path}/maintenance.flag"
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Enable the application and remove the message screen"
|
64
|
+
task :enable, :except => { :no_release => true } do
|
65
|
+
run "rm #{current_path}/maintenance.flag"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# --------------------------------------------
|
71
|
+
# Magento specific tasks
|
72
|
+
# --------------------------------------------
|
73
|
+
namespace :magento do
|
74
|
+
desc "Set appropriate configuration values for the stage"
|
75
|
+
task :activate_config, :except => { :no_release => true } do
|
76
|
+
run "cp -f #{latest_release}/app/etc/local.xml.#{stage} #{latest_release}/app/etc/local.xml"
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Symlink shared directories"
|
80
|
+
task :symlink, :except => { :no_release => true } do
|
81
|
+
run "ln -nfs #{shared_path}/includes #{current_release}/includes"
|
82
|
+
run "ln -nfs #{shared_path}/media #{current_release}/media"
|
83
|
+
run "ln -nfs #{shared_path}/sitemap #{current_release}/sitemap"
|
84
|
+
run "ln -nfs #{shared_path}/var #{current_release}/var"
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Purge Magento cache directory"
|
88
|
+
task :purge_cache, :except => { :no_release => true } do
|
89
|
+
sudo "rm -Rf #{shared_path}/var/cache/*"
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Watch Magento system log"
|
93
|
+
task :watch_logs, :except => { :no_release => true } do
|
94
|
+
stream("tail -f #{shared_path}/var/log/system.log")
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Watch Magento exception log"
|
98
|
+
task :watch_exceptions, :except => { :no_release => true } do
|
99
|
+
stream("tail -f #{shared_path}/var/log/exception.log")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# --------------------------------------------
|
104
|
+
# Custom tasks
|
105
|
+
# --------------------------------------------
|
106
|
+
|
107
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 12
|
9
|
+
version: 0.0.12
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- August Ash
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-15 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/ash/base.rb
|
36
36
|
- lib/ash/common.rb
|
37
37
|
- lib/ash/drupal.rb
|
38
|
+
- lib/ash/magento.rb
|
38
39
|
- lib/ash/zend_doctrine.rb
|
39
40
|
has_rdoc: true
|
40
41
|
homepage: https://github.com/augustash/capistrano-ash
|