drupistrano 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/drupistrano/version.rb +1 -1
- data/lib/drupistrano.rb +56 -7
- metadata +4 -4
data/lib/drupistrano/version.rb
CHANGED
data/lib/drupistrano.rb
CHANGED
@@ -8,6 +8,7 @@ Capistrano::Configuration.instance.load do
|
|
8
8
|
_cset(:site_uri) { "default" }
|
9
9
|
_cset(:drush_path) { "drush" }
|
10
10
|
_cset(:drush_cmd) { "#{drush_path} --uri=#{site_uri}" }
|
11
|
+
_cset(:ispconfig) { false }
|
11
12
|
|
12
13
|
namespace :deploy do
|
13
14
|
task :start do ; end
|
@@ -16,7 +17,11 @@ Capistrano::Configuration.instance.load do
|
|
16
17
|
|
17
18
|
desc "Backup the DB before this update"
|
18
19
|
task :backup_db, :roles => :db do
|
19
|
-
run "
|
20
|
+
on_rollback { run "rm #{previous_release}/dump.sql" if previous_release }
|
21
|
+
|
22
|
+
if previous_release
|
23
|
+
run "cd #{previous_release} && #{drush_cmd} sql-dump > dump.sql"
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
desc "Move default drupal files if they exist and symlink to shared path"
|
@@ -27,29 +32,73 @@ Capistrano::Configuration.instance.load do
|
|
27
32
|
rsync -avz files/ #{shared_path}/files && \
|
28
33
|
rm -rf files; \
|
29
34
|
fi; \
|
30
|
-
ln -nsf
|
35
|
+
cd #{release_path}/sites/default && ln -nsf ../../../../shared/files/ .
|
36
|
+
CMD
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Copy site configuration into place"
|
40
|
+
task :copy_configuration, :roles => :app do
|
41
|
+
run <<-CMD
|
42
|
+
if [ -f #{shared_path}/sites/#{site_uri}/settings.php ]; then \
|
43
|
+
mkdir -p #{release_path}/sites/#{site_uri} && \
|
44
|
+
cp #{shared_path}/sites/#{site_uri}/settings.php #{current_release}/sites/#{site_uri}/; \
|
45
|
+
fi
|
31
46
|
CMD
|
32
47
|
end
|
33
48
|
|
34
49
|
desc "Revert all features"
|
35
|
-
task :revert_features, :roles => :
|
36
|
-
run "cd #{
|
50
|
+
task :revert_features, :roles => :app do
|
51
|
+
run "cd #{current_release} && #{drush_cmd} -y features-revert-all"
|
37
52
|
end
|
38
53
|
|
39
54
|
desc "Clear all cache"
|
40
55
|
task :clear_cache, :roles => :app do
|
41
|
-
run "cd #{
|
56
|
+
run "cd #{current_release} && #{drush_cmd} cache-clear all"
|
42
57
|
end
|
43
58
|
|
44
59
|
desc "Execute database updates"
|
45
60
|
task :migrate, :roles => :db do
|
46
|
-
run "cd #{
|
61
|
+
run "cd #{current_release} && #{drush_cmd} -y updatedb"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Rewrite symlink task to add support for ISPConfig
|
65
|
+
desc <<-DESC
|
66
|
+
Updates the symlink to the most recently deployed version. Capistrano works \
|
67
|
+
by putting each new release of your application in its own directory. When \
|
68
|
+
you deploy a new version, this task's job is to update the `current' symlink \
|
69
|
+
to point at the new version. You will rarely need to call this task \
|
70
|
+
directly; instead, use the `deploy' task (which performs a complete \
|
71
|
+
deploy, including `restart') or the 'update' task (which does everything \
|
72
|
+
except `restart').
|
73
|
+
DESC
|
74
|
+
task :symlink, :except => { :no_release => true } do
|
75
|
+
if ispconfig
|
76
|
+
previous_normalized = previous_release.gsub(deploy_to, '').gsub(/^\//,'')
|
77
|
+
latest_normalized = latest_release.gsub(deploy_to, '').gsub(/^\//,'')
|
78
|
+
|
79
|
+
rollback_cmd = "rm -f #{current_path}; cd #{deploy_to} && ln -s #{previous_normalized} current; true"
|
80
|
+
symlink_cmd = "rm -f #{current_path}; cd #{deploy_to} && ln -s #{latest_normalized} current"
|
81
|
+
else
|
82
|
+
rollback_cmd = "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true"
|
83
|
+
symlink_cmd = "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
|
84
|
+
end
|
85
|
+
|
86
|
+
on_rollback do
|
87
|
+
if previous_release
|
88
|
+
run rollback_cmd
|
89
|
+
else
|
90
|
+
logger.important "no previous release to rollback to, rollback of symlink skipped"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
run symlink_cmd
|
47
95
|
end
|
48
96
|
end
|
49
97
|
|
50
98
|
# Hooks
|
51
|
-
after "deploy:update_code", "deploy:
|
99
|
+
after "deploy:update_code", "deploy:copy_configuration"
|
52
100
|
|
101
|
+
before "deploy:symlink", "deploy:backup_db"
|
53
102
|
before "deploy:symlink", "deploy:move_default_files"
|
54
103
|
before "deploy:symlink", "deploy:revert_features"
|
55
104
|
before "deploy:symlink", "deploy:clear_cache"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drupistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jorge Dias
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-09 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|