cap-drupal-multisite 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +97 -0
- data/cap-drupal-multisite.gemspec +23 -0
- data/lib/cap-drupal-multisite.rb +2 -0
- data/lib/cap-drupal-multisite/drupal.rb +172 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 905a61b9d5ae508f30e561c3c23968b299048d64
|
4
|
+
data.tar.gz: 1719cfe0fe3146406de663471d4e00249cbee6ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3766410982381499a649e57c7f1cb9a2fb88407ce762677e737112eb1f446c99c3fab9b74c46528070db181db6817f626a3f30a242154eda59fa4ee13d187b0
|
7
|
+
data.tar.gz: 585a08c349149f5c8ab993197a78ffaa372a432d45c8afe83718bdc0a819a618023f0b0b7cce750725930710dd084188df59ffb1ebeec93618e75040111b6b9a
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
cap-drupal-multisite
|
2
|
+
====================
|
3
|
+
|
4
|
+
Various capistrano tasks to deploy and maintain drupal sites.
|
5
|
+
|
6
|
+
It currently only works with Drupal 7.x and Capistrano 3.x.
|
7
|
+
|
8
|
+
Features:
|
9
|
+
* Specify and upload settings.php file for each site and stage.
|
10
|
+
* Automatically symlinking `files` and `private` directory for each site.
|
11
|
+
* Integration of some basic Drush tasks.
|
12
|
+
* Synchronize assets and database.
|
13
|
+
|
14
|
+
|
15
|
+
Installation
|
16
|
+
------------
|
17
|
+
|
18
|
+
Add it as gem to `Gemfile`:
|
19
|
+
|
20
|
+
source 'https://rubygems.org'
|
21
|
+
group :development do
|
22
|
+
gem "capistrano", '~> 3.3.5'
|
23
|
+
gem "capistrano-ext"
|
24
|
+
gem 'cap-drupal-multisite'
|
25
|
+
end
|
26
|
+
|
27
|
+
Install using 'bundle':
|
28
|
+
|
29
|
+
bundle install
|
30
|
+
|
31
|
+
|
32
|
+
Configuration
|
33
|
+
-------------
|
34
|
+
|
35
|
+
Add the following line to your `Capfile`:
|
36
|
+
|
37
|
+
require 'capistrano-drupal-multisite'
|
38
|
+
|
39
|
+
Add the following configuration to your `config/deploy.rb`:
|
40
|
+
|
41
|
+
# Path to drupal installation inside the release directory
|
42
|
+
set :drupal_path, "public"
|
43
|
+
# List of all sites in the sites directory
|
44
|
+
set :drupal_sites, %w{default site2}
|
45
|
+
# Group owner of the assets files
|
46
|
+
set :drupal_group, "www-data"
|
47
|
+
|
48
|
+
You have to specify an own settings.php file for each site and each stage like:
|
49
|
+
|
50
|
+
config/<stage>/settings.<site>.php
|
51
|
+
|
52
|
+
You also have to specify an own sites.php for each stage like:
|
53
|
+
|
54
|
+
config/<stage>/sites.php
|
55
|
+
|
56
|
+
|
57
|
+
Usage
|
58
|
+
-----
|
59
|
+
|
60
|
+
Add to following additional optional deploy hooks to your `config/deploy.rb`:
|
61
|
+
|
62
|
+
namespace :deploy do
|
63
|
+
after :publishing, "drupal:cache_clear" # clears all caches
|
64
|
+
after :publishing, "drupal:updatedb" # updates all databases
|
65
|
+
after :publishing, "drupal:feature_revert" # reverts all features
|
66
|
+
end
|
67
|
+
|
68
|
+
Display a list of all available tasks:
|
69
|
+
|
70
|
+
bundle exec cap -T
|
71
|
+
cap drupal:assets:download # Download assets from <remote>:shared_path to <local>:files/ and <local>:private/ for each site
|
72
|
+
cap drupal:assets:upload # Upload assets from <local>:files/ and <local>:private/ to <remote>:shared_path for each site
|
73
|
+
cap drupal:cache_clear # Clear all caches
|
74
|
+
cap drupal:db:download # Download database dumps from <remote>:release_path to <local>:db/
|
75
|
+
cap drupal:db:dump # Dump database for each site to <remote>:release_path
|
76
|
+
cap drupal:db:restore # Restore database for each site from dump in <remote>:release_path
|
77
|
+
cap drupal:db:upload # Upload database dumps from <local>:db/ to <remote>:release_path
|
78
|
+
cap drupal:feature_revert # Revert all features
|
79
|
+
cap drupal:symlink # Symlink shared directories
|
80
|
+
cap drupal:updatedb # Apply any database updates required
|
81
|
+
cap drupal:upload_settings # Upload settings
|
82
|
+
|
83
|
+
|
84
|
+
Bugs & Feedback
|
85
|
+
---------------
|
86
|
+
|
87
|
+
I'm not a Ruby developer so if you have any feedback or found a bug please contact me.
|
88
|
+
|
89
|
+
|
90
|
+
Credits
|
91
|
+
-------
|
92
|
+
|
93
|
+
Most of the code is inspired by other projects like:
|
94
|
+
|
95
|
+
* [antistatique/capdrupal](https://github.com/antistatique/capdrupal)
|
96
|
+
* [mathieue/cap-drupal](https://github.com/mathieue/cap-drupal)
|
97
|
+
* [sgruhier/capistrano-db-tasks](https://github.com/sgruhier/capistrano-db-tasks)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "cap-drupal-multisite"
|
6
|
+
spec.version = "0.3.2"
|
7
|
+
spec.authors = ["Insiders Online"]
|
8
|
+
spec.email = ["beheer@insiders.nl"]
|
9
|
+
spec.homepage = "https://github.com/insiders/cap-drupal-multisite"
|
10
|
+
spec.summary = "[OUTDATED] A collection of capistrano tasks for deploying drupal sites"
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split("\n")
|
15
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "capistrano", "~> 3.3.5"
|
20
|
+
spec.add_dependency "sshkit", ">= 1.4.0"
|
21
|
+
spec.add_dependency "colorize"
|
22
|
+
spec.add_dependency "highline"
|
23
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# Load default values
|
2
|
+
namespace :load do
|
3
|
+
task :defaults do
|
4
|
+
set :drush, "drush"
|
5
|
+
set :drupal_path, "public"
|
6
|
+
set :drupal_sites, %w{default}
|
7
|
+
set :drupal_group, "www-data"
|
8
|
+
set :drupal_rsync_exclude, "--exclude=/languages --exclude=/styles --exclude=/js --exclude=/css"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Specific Drupal tasks
|
13
|
+
namespace :drupal do
|
14
|
+
|
15
|
+
desc "Symlink shared directories"
|
16
|
+
task :symlink do
|
17
|
+
on roles(:all) do
|
18
|
+
fetch(:drupal_sites).each do |site|
|
19
|
+
execute "mkdir", "-p #{shared_path}/#{site}/files #{shared_path}/#{site}/private #{release_path}/#{fetch(:drupal_path)}/sites/#{site}"
|
20
|
+
execute "chmod", "2775 #{shared_path}/#{site}/files #{shared_path}/#{site}/private"
|
21
|
+
execute "chgrp", "#{fetch(:drupal_group)} #{shared_path}/#{site}/files #{shared_path}/#{site}/private"
|
22
|
+
execute "ln", "-nfs #{shared_path}/#{site}/files #{release_path}/#{fetch(:drupal_path)}/sites/#{site}/files"
|
23
|
+
execute "ln", "-nfs #{shared_path}/#{site}/private #{release_path}/#{fetch(:drupal_path)}/sites/#{site}/private"
|
24
|
+
#execute :drush, "-l #{site} -r #{release_path}/#{fetch(:drupal_path)} vset --yes file_directory_path sites/#{site}/files"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Upload settings"
|
30
|
+
task :upload_settings do
|
31
|
+
on roles(:all) do
|
32
|
+
fetch(:drupal_sites).each do |site|
|
33
|
+
upload! "config/#{fetch(:stage)}/settings.#{site}.php", "#{release_path}/#{fetch(:drupal_path)}/sites/#{site}/settings.php"
|
34
|
+
end
|
35
|
+
upload! "config/#{fetch(:stage)}/sites.php", "#{release_path}/#{fetch(:drupal_path)}/sites/sites.php"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Apply any database updates required"
|
40
|
+
task :updatedb do
|
41
|
+
on roles(:all) do
|
42
|
+
fetch(:drupal_sites).each do |site|
|
43
|
+
execute :drush, "-l #{site} -r #{release_path}/#{fetch(:drupal_path)} -y updatedb"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Revert all features"
|
49
|
+
task :feature_revert do
|
50
|
+
on roles(:all) do
|
51
|
+
fetch(:drupal_sites).each do |site|
|
52
|
+
execute :drush, "-l #{site} -r #{release_path}/#{fetch(:drupal_path)} -y features-revert-all"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'Clear all caches'
|
58
|
+
task :cache_clear do
|
59
|
+
on roles(:all) do
|
60
|
+
within "#{release_path}/#{fetch(:drupal_path)}" do
|
61
|
+
fetch(:drupal_sites).each do |site|
|
62
|
+
execute :drush, "-l #{site} -r #{release_path}/#{fetch(:drupal_path)} -y cache-clear all"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
namespace :db do
|
69
|
+
|
70
|
+
desc 'Dump database for each site to <remote>:release_path'
|
71
|
+
task :dump do
|
72
|
+
on roles(:all) do
|
73
|
+
fetch(:drupal_sites).each do |site|
|
74
|
+
execute :drush, "-l #{site} -r #{release_path}/#{fetch(:drupal_path)} sql-dump | gzip > #{release_path}/#{site}.sql.gz"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'Restore database for each site from dump in <remote>:release_path'
|
80
|
+
task :restore do
|
81
|
+
set :confirmed, proc {
|
82
|
+
puts <<-WARN
|
83
|
+
|
84
|
+
========================================================================
|
85
|
+
WARNING: You're about to overwrite production database
|
86
|
+
========================================================================
|
87
|
+
|
88
|
+
WARN
|
89
|
+
ask :answer, "Are you sure you want to continue? Type 'yes'"
|
90
|
+
if fetch(:answer)== 'yes' then true else false end
|
91
|
+
}.call
|
92
|
+
unless fetch(:confirmed)
|
93
|
+
puts "\nCancelled!"
|
94
|
+
exit
|
95
|
+
end
|
96
|
+
on roles(:all) do
|
97
|
+
fetch(:drupal_sites).each do |site|
|
98
|
+
if test("[ -f #{release_path}/#{site}.sql.gz ]")
|
99
|
+
execute "zcat #{release_path}/#{site}.sql.gz | `drush -l #{site} -r #{release_path}/#{fetch(:drupal_path)} sql-connect`"
|
100
|
+
else
|
101
|
+
raise "Database dump for #{site} is not available"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
desc 'Download database dumps from <remote>:release_path to <local>:db/'
|
108
|
+
task :download do
|
109
|
+
on roles(:all) do
|
110
|
+
fetch(:drupal_sites).each do |site|
|
111
|
+
download! "#{release_path}/#{site}.sql.gz", "db/"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
desc 'Upload database dumps from <local>:db/ to <remote>:release_path'
|
117
|
+
task :upload do
|
118
|
+
on roles(:all) do
|
119
|
+
fetch(:drupal_sites).each do |site|
|
120
|
+
upload! "db/#{site}.sql.gz", "#{release_path}/#{site}.sql.gz"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
namespace :assets do
|
127
|
+
|
128
|
+
desc 'Download assets from <remote>:shared_path to <local>:files/ and <local>:private/ for each site'
|
129
|
+
task :download do
|
130
|
+
on roles(:all) do |server|
|
131
|
+
fetch(:drupal_sites).each do |site|
|
132
|
+
puts "Downloading files of #{site} from #{server}"
|
133
|
+
system("sshpass -p#{server.password} rsync -rut --del -L -K #{fetch(:drupal_rsync_exclude)} --rsh='ssh -p #{server.port}' #{server.user}@#{server.hostname}:#{shared_path}/#{site}/files/ sites/#{site}/files")
|
134
|
+
system("sshpass -p#{server.password} rsync -rut --del -L -K #{fetch(:drupal_rsync_exclude)} --rsh='ssh -p #{server.port}' #{server.user}@#{server.hostname}:#{shared_path}/#{site}/private/ sites/#{site}/private")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
desc 'Upload assets from <local>:files/ and <local>:private/ to <remote>:shared_path for each site'
|
140
|
+
task :upload do
|
141
|
+
set :confirmed, proc {
|
142
|
+
puts <<-WARN
|
143
|
+
|
144
|
+
========================================================================
|
145
|
+
WARNING: You're about to overwrite production assets
|
146
|
+
========================================================================
|
147
|
+
|
148
|
+
WARN
|
149
|
+
ask :answer, "Are you sure you want to continue? Type 'yes'"
|
150
|
+
if fetch(:answer)== 'yes' then true else false end
|
151
|
+
}.call
|
152
|
+
unless fetch(:confirmed)
|
153
|
+
puts "\nCancelled!"
|
154
|
+
exit
|
155
|
+
end
|
156
|
+
on roles(:all) do |server|
|
157
|
+
fetch(:drupal_sites).each do |site|
|
158
|
+
puts "Uploading files of #{site} to #{server}"
|
159
|
+
system("sshpass -p#{server.password} rsync -rutv --del -L -K #{fetch(:drupal_rsync_exclude)} --rsh='ssh -p #{server.port}' sites/#{site}/files/ #{server.user}@#{server.hostname}:#{shared_path}/#{site}/files")
|
160
|
+
system("sshpass -p#{server.password} rsync -rutv --del -L -K #{fetch(:drupal_rsync_exclude)} --rsh='ssh -p #{server.port}' sites/#{site}/private/ #{server.user}@#{server.hostname}:#{shared_path}/#{site}/private")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
# Set deploy hooks
|
169
|
+
namespace :deploy do
|
170
|
+
after :updating, "drupal:symlink"
|
171
|
+
after :updating, "drupal:upload_settings"
|
172
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cap-drupal-multisite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Insiders Online
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sshkit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: '[OUTDATED] A collection of capistrano tasks for deploying drupal sites'
|
70
|
+
email:
|
71
|
+
- beheer@insiders.nl
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- README.md
|
77
|
+
- cap-drupal-multisite.gemspec
|
78
|
+
- lib/cap-drupal-multisite.rb
|
79
|
+
- lib/cap-drupal-multisite/drupal.rb
|
80
|
+
homepage: https://github.com/insiders/cap-drupal-multisite
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.0.14
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: '[OUTDATED] A collection of capistrano tasks for deploying drupal sites'
|
104
|
+
test_files: []
|