drupal-cap 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/capistrano-drupal.rb +101 -0
- metadata +45 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
require 'capistrano/recipes/deploy/scm'
|
4
|
+
require 'capistrano/recipes/deploy/strategy'
|
5
|
+
|
6
|
+
# =========================================================================
|
7
|
+
# These variables may be set in the client capfile if their default values
|
8
|
+
# are not sufficient.
|
9
|
+
# =========================================================================
|
10
|
+
|
11
|
+
set :scm, :git
|
12
|
+
set :deploy_via, :remote_cache
|
13
|
+
_cset :branch, "master"
|
14
|
+
set :git_enable_submodules, true
|
15
|
+
|
16
|
+
set :drush_cmd, "drush"
|
17
|
+
|
18
|
+
set :runner_group, "www-data"
|
19
|
+
set :group_writable, false
|
20
|
+
|
21
|
+
set(:deploy_to) { "/var/www/#{application}" }
|
22
|
+
set :shared_children, ['files', 'private']
|
23
|
+
|
24
|
+
after "deploy:update_code", "drupal:symlink_shared", "drush:site_offline", "drush:updatedb", "drush:cache_clear", "drush:site_online"
|
25
|
+
|
26
|
+
namespace :deploy do
|
27
|
+
desc <<-DESC
|
28
|
+
Prepares one or more servers for deployment. Before you can use any \
|
29
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
30
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
31
|
+
you add a new server to your cluster, you can easily run the setup task \
|
32
|
+
on just that server by specifying the HOSTS environment variable:
|
33
|
+
|
34
|
+
$ cap HOSTS=new.server.com deploy:setup
|
35
|
+
|
36
|
+
It is safe to run this task on servers that have already been set up; it \
|
37
|
+
will not destroy any deployed revisions or data.
|
38
|
+
DESC
|
39
|
+
task :setup, :except => { :no_release => true } do
|
40
|
+
dirs = [deploy_to, releases_path, shared_path].join(' ')
|
41
|
+
run "#{try_sudo} mkdir -p #{releases_path} #{shared_path}"
|
42
|
+
run "#{try_sudo} chown -R #{user}:#{runner_group} #{deploy_to}"
|
43
|
+
sub_dirs = shared_children.map { |d| File.join(shared_path, d) }
|
44
|
+
run "#{try_sudo} chmod 2775 #{sub_dirs.join(' ')}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
namespace :drupal do
|
49
|
+
desc "Symlink settings and files to shared directory. This allows the settings.php and \
|
50
|
+
and sites/default/files directory to be correctly linked to the shared directory on a new deployment."
|
51
|
+
task :symlink_shared do
|
52
|
+
["files", "private", "settings.php"].each do |asset|
|
53
|
+
run "rm -rf #{latest_release}/#{asset} && ln -nfs #{shared_path}/#{asset} #{latest_release}/sites/default/#{asset}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :drush do
|
59
|
+
|
60
|
+
desc "Backup the database"
|
61
|
+
task :backupdb, :on_error => :continue do
|
62
|
+
run "#{drush_cmd} -r #{latest_release} bam-backup"
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Run Drupal database migrations if required"
|
66
|
+
task :updatedb, :on_error => :continue do
|
67
|
+
run "#{drush_cmd} -r #{latest_release} updatedb -y"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Clear the drupal cache"
|
71
|
+
task :cache_clear, :on_error => :continue do
|
72
|
+
run "#{drush_cmd} -r #{latest_release} cc all"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Set the site offline"
|
76
|
+
task :site_offline, :on_error => :continue do
|
77
|
+
run "#{drush_cmd} -r #{latest_release} vset site_offline 1 -y"
|
78
|
+
run "#{drush_cmd} -r #{latest_release} vset maintenance_mode 1 -y"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Set the site online"
|
82
|
+
task :site_online, :on_error => :continue do
|
83
|
+
run "#{drush_cmd} -r #{latest_release} vset site_offline 0 -y"
|
84
|
+
run "#{drush_cmd} -r #{latest_release} vset maintenance_mode 0 -y"
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Copy local database to the server"
|
88
|
+
task :copy_local do
|
89
|
+
sql = %x[/usr/bin/drush sql-dump]; success = $?.success?
|
90
|
+
if success
|
91
|
+
drush.site_offline
|
92
|
+
put sql, "#{latest_release}/sqldump-capistrano-drupal.sql"
|
93
|
+
run "`#{drush_cmd} -r #{latest_release} sql-connect` < #{latest_release}/sqldump-capistrano-drupal.sql"
|
94
|
+
run "rm #{latest_release}/sqldump-capistrano-drupal.sql"
|
95
|
+
drush.site_online
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drupal-cap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sandor Czettner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Capistrano task collection for Drupal development
|
15
|
+
email: sandor@czettner.hu
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/capistrano-drupal.rb
|
21
|
+
homepage: https://github.com/czettnersandor/capistrano-drupal
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.23
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Capistrano tasks for Drupal
|
45
|
+
test_files: []
|