drush-deploy 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE.txt +1 -0
- data/LICENSE_GPL.txt +339 -0
- data/LICENSE_MPL.txt +373 -0
- data/README.md +15 -0
- data/bin/drush-deploy +16 -0
- data/drush-deploy.gemspec +19 -0
- data/lib/drush_deploy/capistrano.rb +93 -0
- data/lib/drush_deploy/configuration.rb +122 -0
- data/lib/drush_deploy/database.rb +260 -0
- data/lib/drush_deploy/error.rb +3 -0
- data/lib/drush_deploy/paths.rb +19 -0
- data/lib/drush_deploy/recipes/all.rb +8 -0
- data/lib/drush_deploy/recipes/bootstrap.rb +2 -0
- data/lib/drush_deploy/recipes/db.rb +106 -0
- data/lib/drush_deploy/recipes/deploy.rb +28 -0
- data/lib/drush_deploy/recipes/drupal.rb +89 -0
- data/lib/drush_deploy/recipes/general.rb +5 -0
- data/lib/drush_deploy/recipes/setup.rb +31 -0
- data/lib/drush_deploy.rb +4 -0
- metadata +100 -0
@@ -0,0 +1,260 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'drush_deploy/error'
|
3
|
+
require 'drush_deploy/configuration'
|
4
|
+
require 'yaml'
|
5
|
+
require 'php_serialize'
|
6
|
+
|
7
|
+
module DrushDeploy
|
8
|
+
class Database
|
9
|
+
class Error < DrushDeploy::Error; end
|
10
|
+
|
11
|
+
|
12
|
+
STANDARD_KEYS = %w(driver database username password host port prefix collation).map &:to_sym
|
13
|
+
MANAGE_KEYS = %w(driver database username password host port prefix
|
14
|
+
admin_username admin_password).map &:to_sym
|
15
|
+
|
16
|
+
def initialize(config)
|
17
|
+
@config = config
|
18
|
+
@seen_paths = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(sym, *args, &block)
|
22
|
+
if @config.respond_to?(sym)
|
23
|
+
@config.send(sym, *args, &block)
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def configure
|
30
|
+
databases_path.find do |val|
|
31
|
+
set :databases, load_path( val, databases )
|
32
|
+
MANAGE_KEYS.all? {|k| databases.key? k}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_path(path,databases = {})
|
37
|
+
unless @seen_paths[path]
|
38
|
+
logger.info "Trying to load database setting from #{path.inspect}"
|
39
|
+
if path !~ /^[\/~]/
|
40
|
+
path = latest_release+"/"+path
|
41
|
+
end
|
42
|
+
if path =~ /.php$/
|
43
|
+
@seen_paths[path] = load_php_path path
|
44
|
+
elsif path =~ /.yml$/
|
45
|
+
@seen_paths[path] = load_yml_path path
|
46
|
+
else
|
47
|
+
throw Error.new "Unknown file type: #{path}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
DrushDeploy::Database.deep_merge(@seen_paths[path],databases)
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_php_path(path)
|
54
|
+
prefix = ''
|
55
|
+
if path.sub!(/^~/,'')
|
56
|
+
prefix = "getenv('HOME')."
|
57
|
+
end
|
58
|
+
|
59
|
+
script = <<-END.gsub(/^ */,'')
|
60
|
+
<?php
|
61
|
+
$filename = #{prefix}'#{path}';
|
62
|
+
if( file_exists($filename) ) {
|
63
|
+
require_once($filename);
|
64
|
+
if( isset($databases) ) {
|
65
|
+
print serialize($databases);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
END
|
69
|
+
put script, '/tmp/load_db_credentials.php', :once => true
|
70
|
+
resp = capture "#{drush_bin} php-script /tmp/load_db_credentials.php"
|
71
|
+
|
72
|
+
settings = {}
|
73
|
+
unless resp.empty?
|
74
|
+
resp = DrushDeploy::Configuration.unserialize_php(resp)
|
75
|
+
if resp != []
|
76
|
+
settings = resp
|
77
|
+
end
|
78
|
+
end
|
79
|
+
settings
|
80
|
+
end
|
81
|
+
|
82
|
+
def load_yml_path(path)
|
83
|
+
prefix = ''
|
84
|
+
if path.sub!(/^~/,'')
|
85
|
+
prefix = '"$HOME"'
|
86
|
+
end
|
87
|
+
|
88
|
+
yaml = capture("[ ! -e #{prefix}'#{path}' ] || cat #{prefix}'#{path}'")
|
89
|
+
if yaml.empty?
|
90
|
+
{}
|
91
|
+
else
|
92
|
+
credentials = YAML.load yaml
|
93
|
+
DrushDeploy::Configuration.normalize_value(credentials)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def update_settings(settings,template = 'sites/default/default.settings.php')
|
98
|
+
if template !~ /^[\/~]/
|
99
|
+
template = latest_release+"/"+template
|
100
|
+
end
|
101
|
+
prefix = ''
|
102
|
+
if template.sub!(/^~/,'')
|
103
|
+
prefix = "getenv('HOME')."
|
104
|
+
end
|
105
|
+
script = <<-END.gsub(/^ */,'')
|
106
|
+
<?php
|
107
|
+
define('DRUPAL_ROOT', '#{latest_release}');
|
108
|
+
define('MAINTENANCE_MODE', 'install');
|
109
|
+
|
110
|
+
$template = #{prefix}'#{template}';
|
111
|
+
$default = DRUPAL_ROOT.'/sites/default/default.settings.php';
|
112
|
+
$backup = '/tmp/default_settings_backup.php';
|
113
|
+
|
114
|
+
$databases = unserialize('#{PHP.serialize(settings)}');
|
115
|
+
$settings["databases"] = array( 'comment' => 'Generated by drush-deploy',
|
116
|
+
'value' => $databases );
|
117
|
+
|
118
|
+
require_once(DRUPAL_ROOT.'/includes/bootstrap.inc');
|
119
|
+
require_once(DRUPAL_ROOT.'/includes/install.inc');
|
120
|
+
|
121
|
+
$backed_up = false;
|
122
|
+
if ($template != $default && file_exists($default)) {
|
123
|
+
rename($default,$backup);
|
124
|
+
$backed_up = true;
|
125
|
+
}
|
126
|
+
rename($template,$default);
|
127
|
+
drupal_rewrite_settings($settings);
|
128
|
+
if ($backed_up) {
|
129
|
+
rename($backup,$default);
|
130
|
+
}
|
131
|
+
END
|
132
|
+
put script, '/tmp/update_settings.php'
|
133
|
+
run "cd '#{latest_release}' && #{drush_bin} php-script /tmp/update_settings.php"
|
134
|
+
end
|
135
|
+
|
136
|
+
def updatedb
|
137
|
+
run "cd '#{latest_release}' && #{drush_bin} updatedb", :once => true
|
138
|
+
end
|
139
|
+
|
140
|
+
def config(*args)
|
141
|
+
options = (args.size>0 && args.last.is_a?(Hash)) ? args.pop : {}
|
142
|
+
site_name = args[0] || :default
|
143
|
+
db_name = args[1] || :default
|
144
|
+
conf = databases[site_name][db_name].dup
|
145
|
+
if options[:admin] && conf[:admin_username]
|
146
|
+
conf[:username] = conf[:admin_username]
|
147
|
+
conf[:password] = conf[:admin_password]
|
148
|
+
end
|
149
|
+
conf.merge options
|
150
|
+
end
|
151
|
+
|
152
|
+
def remote_sql(sql,options={})
|
153
|
+
url = options[:config] ? DrushDeploy::Database.url(options[:config]) : nil
|
154
|
+
tmp = capture('mktemp').strip
|
155
|
+
put(sql,tmp)
|
156
|
+
cmd = %Q{cd '#{current_path}' && #{drush_bin} sql-cli #{url ? "--db-url='#{url}'" : ''} < '#{tmp}'}
|
157
|
+
if options[:capture]
|
158
|
+
capture(cmd)
|
159
|
+
else
|
160
|
+
run cmd, :once => true
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def db_versions
|
165
|
+
conf = config(:admin => true)
|
166
|
+
logger.info "Getting list of databases versions"
|
167
|
+
sql = %q{SELECT SCHEMA_NAME FROM information_schema.SCHEMATA
|
168
|
+
WHERE SCHEMA_NAME REGEXP '%{database}_[0-9]+';} % conf
|
169
|
+
remote_sql(sql, :config => conf, :capture => true).split(/\n/)[1..-1].sort.reverse
|
170
|
+
end
|
171
|
+
|
172
|
+
def db_exists?(db = nil)
|
173
|
+
conf = config(:admin => true)
|
174
|
+
conf[:database] = db if db
|
175
|
+
logger.info "Checking existence of #{conf[:database]}"
|
176
|
+
sql = %q{SELECT COUNT(*) FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '%{database}';} % conf
|
177
|
+
conf[:database] = 'information_schema'
|
178
|
+
remote_sql(sql, :config => conf, :capture => true).split(/\n/)[1].to_i != 0
|
179
|
+
end
|
180
|
+
|
181
|
+
def db_tables(db = nil)
|
182
|
+
conf = config(:admin => true)
|
183
|
+
conf[:database] = db if db
|
184
|
+
logger.info "Fetching table list of #{conf[:database]}"
|
185
|
+
db_tables_query = %q{SELECT table_name FROM information_schema.tables
|
186
|
+
WHERE table_schema = '%{database}'
|
187
|
+
AND table_type = 'BASE TABLE'};
|
188
|
+
sql = db_tables_query % conf
|
189
|
+
conf[:database] = 'information_schema'
|
190
|
+
remote_sql(sql, :config => conf, :capture => true).split(/\n/)[1..-1] || []
|
191
|
+
end
|
192
|
+
|
193
|
+
def copy_database(from,to)
|
194
|
+
logger.info "Copying database #{from} to #{to}"
|
195
|
+
tables = db_tables
|
196
|
+
conf = config(:database => from, :admin => true)
|
197
|
+
|
198
|
+
remote_sql("CREATE DATABASE #{to};", :config => conf)
|
199
|
+
sql = ''
|
200
|
+
tables.each do |table|
|
201
|
+
sql += <<-END
|
202
|
+
CREATE TABLE #{to}.#{table} LIKE #{from}.#{table};
|
203
|
+
INSERT INTO #{to}.#{table} SELECT * FROM #{from}.#{table};
|
204
|
+
END
|
205
|
+
end
|
206
|
+
remote_sql(sql, :config => conf)
|
207
|
+
end
|
208
|
+
|
209
|
+
def rename_database(from,to)
|
210
|
+
logger.info "Renaming database #{from} to #{to}"
|
211
|
+
conf = config(:database => from, :admin => true)
|
212
|
+
sql = ''
|
213
|
+
if conf[:driver] == :mysql
|
214
|
+
sql += "CREATE DATABASE `#{to}`;"
|
215
|
+
db_tables(from).each do |table|
|
216
|
+
sql += "RENAME TABLE `#{from}`.`#{table}` TO `#{to}`.`#{table}`;"
|
217
|
+
end
|
218
|
+
sql += "DROP DATABASE `#{from}`;"
|
219
|
+
else
|
220
|
+
sql += "ALTER TABLE #{from} RENAME TO #{to};"
|
221
|
+
end
|
222
|
+
remote_sql(sql, :config => conf)
|
223
|
+
end
|
224
|
+
|
225
|
+
def drop_database(db)
|
226
|
+
logger.info "Dropping database #{db}"
|
227
|
+
conf = config(:database => db, :admin => true)
|
228
|
+
remote_sql("DROP DATABASE #{db};", :config => conf)
|
229
|
+
end
|
230
|
+
|
231
|
+
# Should split these out
|
232
|
+
def self.deep_update(h1,h2)
|
233
|
+
h1.inject({}) do |h,(k,v)|
|
234
|
+
if Hash === v && Hash === h2[k]
|
235
|
+
h[k] = deep_update(v,h2[k])
|
236
|
+
else
|
237
|
+
h[k] = h2.key?(k) ? h2[k] : v
|
238
|
+
end
|
239
|
+
h
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.deep_merge(h1,h2)
|
244
|
+
merger = proc { |key,v1,v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
245
|
+
h1.merge(h2, &merger)
|
246
|
+
end
|
247
|
+
|
248
|
+
def self.each_db(databases)
|
249
|
+
databases.each do |site_name,site|
|
250
|
+
site.each do |db_name,db|
|
251
|
+
yield db,site_name,db_name
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.url(db)
|
257
|
+
"#{db[:driver]}://#{db[:username]}:#{db[:password]}@#{db[:host]}:#{db[:port]}/#{db[:database]}"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DrushDeploy
|
2
|
+
module Paths
|
3
|
+
def self.root(path = '')
|
4
|
+
File.expand_path('../../../' + path,__FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.bin(path = '')
|
8
|
+
root('bin/' + path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.lib(path = '')
|
12
|
+
root('lib/' + path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.recipe(path)
|
16
|
+
root('lib/drush_deploy/recipes/' + path + '.rb')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'drush_deploy/database'
|
2
|
+
|
3
|
+
drupal_db = DrushDeploy::Database.new(self)
|
4
|
+
|
5
|
+
after "deploy", "db:drupal:update_settings"
|
6
|
+
after "deploy", "db:version:create"
|
7
|
+
before "deploy:rollback", "db:version:rollback"
|
8
|
+
|
9
|
+
before "db:version:create", "db:drupal:configure"
|
10
|
+
before "db:version:rollback", "db:drupal:configure"
|
11
|
+
before "db:version:cleanup", "db:drupal:configure"
|
12
|
+
|
13
|
+
if update_modules
|
14
|
+
after "deploy", "db:drupal:update"
|
15
|
+
end
|
16
|
+
after "deploy:cleanup", "db:version:cleanup"
|
17
|
+
|
18
|
+
namespace :db do
|
19
|
+
namespace :drupal do
|
20
|
+
desc "Run update scripts for Drupal"
|
21
|
+
task :update, :roles => :web do
|
22
|
+
drupal_db.updatedb
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Determine database settings"
|
26
|
+
task :configure do
|
27
|
+
unless configured
|
28
|
+
drupal_db.configure
|
29
|
+
|
30
|
+
unless databases.nil? || databases.is_a?(Hash)
|
31
|
+
throw DrushDeploy::Error.new "Invalid value for databases: #{databases.inspect}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Set some defaults
|
35
|
+
DrushDeploy::Database.each_db(databases) do |db|
|
36
|
+
if db[:driver]
|
37
|
+
db[:driver] = db[:driver].to_sym
|
38
|
+
else
|
39
|
+
db[:driver] = db[:port] == database_ports[:pgsql] ? :pgsql : :mysql
|
40
|
+
end
|
41
|
+
db[:host] ||= 'localhost'
|
42
|
+
db[:port] ||= database_ports[db[:driver]]
|
43
|
+
db[:prefix] ||= ''
|
44
|
+
db[:collation] ||= 'utf8_general_ci'
|
45
|
+
end
|
46
|
+
set :configured, true
|
47
|
+
|
48
|
+
logger.important "Using database settings #{databases.inspect}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Update settings.php with database settings"
|
53
|
+
task :update_settings do
|
54
|
+
configure unless configured
|
55
|
+
settings = databases.inject({}) do |h,(k,site)|
|
56
|
+
h[k] = site.inject({}) do |h,(k,db)|
|
57
|
+
h[k] = db.keep_if { |k,v| DrushDeploy::Database::STANDARD_KEYS.include? k }
|
58
|
+
h
|
59
|
+
end
|
60
|
+
h
|
61
|
+
end
|
62
|
+
drupal_db.update_settings(settings)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
namespace :version do
|
67
|
+
desc "Create a versioned backup of the database"
|
68
|
+
task :create, :roles => :web do
|
69
|
+
if releases.size > 1
|
70
|
+
current = drupal_db.config[:database]
|
71
|
+
backup = "#{current}_#{releases[-2]}"
|
72
|
+
unless drupal_db.db_exists? backup
|
73
|
+
on_rollback do
|
74
|
+
drupal_db.drop_database backup
|
75
|
+
end
|
76
|
+
drupal_db.copy_database(current,backup)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Rollback to a previous version of the database"
|
82
|
+
task :rollback, :roles => :web do
|
83
|
+
unless releases.size > 1
|
84
|
+
throw DrushDeploy::Error.new "No previous versions to rollback to"
|
85
|
+
end
|
86
|
+
current = drupal_db.config[:database]
|
87
|
+
release = releases.last
|
88
|
+
source = "#{current}_#{releases[-2]}"
|
89
|
+
backup = "#{current}_backup"
|
90
|
+
if drupal_db.db_exists? source
|
91
|
+
drupal_db.rename_database(current,backup)
|
92
|
+
drupal_db.rename_database(source,current)
|
93
|
+
drupal_db.drop_database(backup)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Cleanup old versions of the database"
|
98
|
+
task :cleanup, :roles => :web do
|
99
|
+
# Subtract one because the latest release won't be counted
|
100
|
+
count = fetch(:keep_releases, 5).to_i - 1
|
101
|
+
drupal_db.db_versions.drop(count).each do |db|
|
102
|
+
drupal_db.drop_database(db)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
after "deploy", "deploy:cleanup"
|
2
|
+
|
3
|
+
# --------------------------------------------
|
4
|
+
# Overloaded Methods
|
5
|
+
# --------------------------------------------
|
6
|
+
namespace :deploy do
|
7
|
+
desc "Setup shared application directories and permissions after initial setup"
|
8
|
+
task :setup_shared do
|
9
|
+
# remove Capistrano specific directories
|
10
|
+
run "rm -Rf #{shared_path}/log"
|
11
|
+
run "rm -Rf #{shared_path}/pids"
|
12
|
+
run "rm -Rf #{shared_path}/system"
|
13
|
+
|
14
|
+
run "[[ -e '#{shared_path}/default/files' ]] || mkdir -p #{shared_path}/default/files"
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :web do
|
18
|
+
desc "Disable the application and show a message screen"
|
19
|
+
task :disable, :roles => :web do
|
20
|
+
run "#{drush_bin} -r #{latest_release} vset --yes site_offline 1"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Enable the application and remove the message screen"
|
24
|
+
task :enable, :roles => :web do
|
25
|
+
run "#{drush_bin} -r #{latest_release} vdel --yes site_offline"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'drush_deploy/database'
|
2
|
+
|
3
|
+
before "deploy", "drupal:setup_build"
|
4
|
+
before "deploy", "drupal:check_permissions"
|
5
|
+
after "deploy:symlink", "drupal:symlink"
|
6
|
+
after "deploy", "drupal:clearcache"
|
7
|
+
before "drupal:install_profile", "db:drupal:configure"
|
8
|
+
|
9
|
+
namespace :drupal do
|
10
|
+
desc "Symlink shared directories"
|
11
|
+
task :symlink, :roles => :web do
|
12
|
+
run "ln -nfs #{shared_path}/default/files #{latest_release}/sites/default/files"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Clear all Drupal cache"
|
16
|
+
task :clearcache, :roles => :web do
|
17
|
+
run "#{drush_bin} -r #{current_path} cache-clear all"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Protect system files"
|
21
|
+
task :protect, :roles => :web do
|
22
|
+
run "chmod 644 #{latest_release}/sites/default/settings.php"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Install profile from command line"
|
26
|
+
task :install_profile, :roles => :web do
|
27
|
+
script= <<-END
|
28
|
+
cd '#{latest_release}'
|
29
|
+
for p in `ls profiles`
|
30
|
+
do
|
31
|
+
echo "$(sed -n 's/name[ \t]*=[ \t]*//p' profiles/$p/$p.info) ($p)"
|
32
|
+
done
|
33
|
+
END
|
34
|
+
put script, '/tmp/select_profile.sh'
|
35
|
+
profiles = capture('bash /tmp/select_profile.sh').split(/\n/)
|
36
|
+
|
37
|
+
profile = Capistrano::CLI.ui.choose(*profiles) {|m| m.header = "Choose installation profile"}
|
38
|
+
machine_name = profile.match(/.*\((.*)\)$/)[1]
|
39
|
+
site_name = Capistrano::CLI.ui.ask("Site name?")
|
40
|
+
site_email = Capistrano::CLI.ui.ask("Site email?")
|
41
|
+
admin_email = Capistrano::CLI.ui.ask("Admin email?")
|
42
|
+
admin_user = Capistrano::CLI.ui.ask("Admin username?")
|
43
|
+
admin_password = Capistrano::CLI.password_prompt("Admin password?")
|
44
|
+
arguments = Capistrano::CLI.password_prompt("Additional profile settings (key=value)?")
|
45
|
+
dbconf = databases[:default][:default]
|
46
|
+
db_url = DrushDeploy::Database.url(dbconf)
|
47
|
+
|
48
|
+
run "cd '#{latest_release}' && #{drush_bin} site-install --yes --db-url='#{db_url}'"\
|
49
|
+
" --account-mail='#{admin_email}' --account-name='#{admin_user}' --account-pass='#{admin_password}'"\
|
50
|
+
" --site-name='#{site_name}' --site-mail='#{site_email}' "\
|
51
|
+
"#{dbconf[:admin_username] ? "--db-su='#{dbconf[:admin_username]}'" : ''} #{dbconf[:admin_password] ? "--db-su-pw='#{dbconf[:admin_password]}'" : ''}"\
|
52
|
+
"#{machine_name} #{arguments}", :once => true
|
53
|
+
end
|
54
|
+
|
55
|
+
task :setup_build, :roles => :web do
|
56
|
+
if ENV['MAKE']
|
57
|
+
set :make, ENV['MAKE'] =~ /^(0|no?)$/i
|
58
|
+
end
|
59
|
+
if ENV['MAKEFILE']
|
60
|
+
set :makefile, ENV['MAKEFILE']
|
61
|
+
end
|
62
|
+
|
63
|
+
build_cmd = "drush make '#{makefile}' ."
|
64
|
+
|
65
|
+
if make.nil?
|
66
|
+
build_cmd = "[ -f index.php ] || { [ -f '#{makefile}' ] && #{build_cmd}; }"
|
67
|
+
end
|
68
|
+
if make != false
|
69
|
+
set :build_script, build_cmd
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Check and fix if any permissions are set incorrectly."
|
74
|
+
task :check_permissions, :roles => :web do
|
75
|
+
if ! defined? www_user or www_user.nil?
|
76
|
+
user = capture(%q{ps -eo user,comm,pid,ppid | awk '$2 ~ /^apache.*|^httpd$/ && $1 != U && $3 != P {P=$4; U=$1} END { print U }'}).strip
|
77
|
+
if user
|
78
|
+
set :www_user, user
|
79
|
+
logger.important "Guessing that #{user} is the www_user, if this is wrong please set www_user manually in config"
|
80
|
+
else
|
81
|
+
logger.important "Not setting permissions: Unable to determine www_user, please set manually in config"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
if ! defined? www_user or www_user.nil?
|
85
|
+
run "setfacl -Rdm u:#{www_user}:rwx #{shared_path}/default/files && setfacl -Rm u:#{www_user}:rwx #{shared_path}/default/files"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'drush_deploy/capistrano'
|
2
|
+
|
3
|
+
set :deploy_via, :copy
|
4
|
+
set :scm, :none
|
5
|
+
set :repository, "."
|
6
|
+
set :drush_bin, "drush"
|
7
|
+
set :make, nil
|
8
|
+
set :makefile, 'distro.make'
|
9
|
+
|
10
|
+
set :drush, ENV['DRUSH'] if ENV['DRUSH']
|
11
|
+
set :scm, ENV['SCM'] if ENV['SCM']
|
12
|
+
set :repository, ENV['REPO'] if ENV['REPO']
|
13
|
+
set :target, ENV['TARGET'] if ENV['TARGET']
|
14
|
+
set :source, ENV['SOURCE'] if ENV['SOURCE']
|
15
|
+
|
16
|
+
set :databases_path, [ '~/.drush/database.php', '~/.drush/database.yml',
|
17
|
+
'/etc/drush/database.php','/etc/drush/database.yml',
|
18
|
+
'sites/default/default.settings.php', 'sites/default/settings.php']
|
19
|
+
set :databases, {}
|
20
|
+
|
21
|
+
set :database_ports, { :pgsql => 5432, :mysql => 3306 }
|
22
|
+
|
23
|
+
set :configured, false
|
24
|
+
|
25
|
+
set :update_modules, true
|
26
|
+
|
27
|
+
set :drush_cap, DrushDeploy::Capistrano.new
|
28
|
+
|
29
|
+
if exists? :target
|
30
|
+
target.split(/ *, */).each {|t| drush_cap.load_target t }
|
31
|
+
end
|
data/lib/drush_deploy.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drush-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matt Edlefsen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &24649140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *24649140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: railsless-deploy
|
27
|
+
requirement: &24648400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.2
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *24648400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: php_serialize
|
38
|
+
requirement: &24647760 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.2'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *24647760
|
47
|
+
description: Utilizes capistrano to allow for doing intellegent deployments of drupal
|
48
|
+
projects.
|
49
|
+
email: matt@xforty.com
|
50
|
+
executables:
|
51
|
+
- drush-deploy
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files:
|
54
|
+
- README.md
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE.txt
|
58
|
+
- LICENSE_GPL.txt
|
59
|
+
- LICENSE_MPL.txt
|
60
|
+
- README.md
|
61
|
+
- bin/drush-deploy
|
62
|
+
- drush-deploy.gemspec
|
63
|
+
- lib/drush_deploy.rb
|
64
|
+
- lib/drush_deploy/capistrano.rb
|
65
|
+
- lib/drush_deploy/configuration.rb
|
66
|
+
- lib/drush_deploy/database.rb
|
67
|
+
- lib/drush_deploy/error.rb
|
68
|
+
- lib/drush_deploy/paths.rb
|
69
|
+
- lib/drush_deploy/recipes/all.rb
|
70
|
+
- lib/drush_deploy/recipes/bootstrap.rb
|
71
|
+
- lib/drush_deploy/recipes/db.rb
|
72
|
+
- lib/drush_deploy/recipes/deploy.rb
|
73
|
+
- lib/drush_deploy/recipes/drupal.rb
|
74
|
+
- lib/drush_deploy/recipes/general.rb
|
75
|
+
- lib/drush_deploy/recipes/setup.rb
|
76
|
+
homepage: https://github.com/xforty/drush-deploy
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>'
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.1
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.10
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Deployment strategy for Drupal using Drush
|
100
|
+
test_files: []
|