This repository was archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcapfile
85 lines (67 loc) · 2.52 KB
/
capfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy.rb'
require 'capistrano/ext/multistage'
# Get rid of the rails-specific features
require 'railsless-deploy'
# Here we setup the shared files directory
after 'deploy:finalize_update', 'drupal:finalize_update'
# After symlinking the code we symlink the shared dirs
after 'deploy:symlink', 'drupal:symlink'
after 'deploy:symlink', 'stage_tasks:symlink'
after "deploy", "drupal:cacheclear"
# Allow stage-specific tasks to be run. e.g. Put site into main mode if dev or
# stag stage
after "deploy", "stage_tasks:cleanup"
# Set group on all files added in the build process
after "deploy", "drupal:set_group"
after "deploy:setup", "drupal:setup"
# Override default Cap deploy task
namespace :deploy do
# adjusted finalize_update, removed non rails stuff
task :finalize_update, :roles => :web, :except => { :no_release => true } do
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
end
end
# Drupal=specific tasks
namespace :drupal do
task :finalize_update, :roles => :web, :except => { :no_release => true } do
# Locate the make file and run it
args = fetch(:make_args, "")
run "ls #{latest_release} | grep make" do |channel, stream, data|
run "cd #{latest_release}; #{drush} make #{args} #{data} ."
end
end
# Symlink shared directories
task :symlink, :roles => :web, :except => { :no_release => true } do
run "ln -s #{shared_path}/default/files #{latest_release}/sites/default/files"
run "ln -s #{shared_path}/default/settings.php #{latest_release}/sites/default/settings.php"
end
# Enforce use of a particular group
task :set_group, :roles => :web, :except => { :no_release => true } do
# Parent folders should have had the sticky group id set, but just in case
# they haven't, ensure the group is set
run "chgrp -R #{group} #{deploy_to}/current"
run "chgrp -R #{group} #{latest_release}"
run "chmod -R g+w #{latest_release}"
end
# Drush cache clear
task :cacheclear, :roles => :web, :except => { :no_release => true } do
run "#{drush} cc all"
end
# Take site out of maintenance mode
task :online do
run "#{drush} vset --yes site_offline 0"
cacheclear
end
# Put site into maintenance mode
task :offline do
run "#{drush} vset --yes site_offline 1"
cacheclear
end
# Setup tasks
task :setup, :roles => :web do
# Place to stick custom .htaccess files and the like
run "mkdir #{shared_path}/conf"
run "mkdir #{shared_path}/default"
end
end