erCapistranoDrupal 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -174,5 +174,9 @@ System will be auto set the maintainance key to "site_readonly" when "Read Only
174
174
 
175
175
  ## Changelog:
176
176
 
177
+ ### Version 0.1.1 - June 19 2013
178
+ * Fix muiltiple servers deploy bug
179
+ * Fix rollback permissions bug
180
+
177
181
  ### Version 0.1.0 - June 17 2013
178
182
  * First release
@@ -1,3 +1,3 @@
1
1
  module ErCapistranoDrupal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -210,18 +210,6 @@ Capistrano::Configuration.instance(:must_exist).load do
210
210
  try_sudo(*args)
211
211
  end
212
212
 
213
- # =========================================================================
214
- # Check the remote file or directory exist
215
- # =========================================================================
216
- def remote_file_exists?(path)
217
- results = []
218
- invoke_command("if [ -e '#{path}' ]; then echo -n 'true'; fi") do |ch, stream, out|
219
- results << (out == 'true')
220
- end
221
-
222
- results == [true]
223
- end
224
-
225
213
  # =========================================================================
226
214
  # These are the tasks that are available to help with deploying web apps,
227
215
  # and specifically, Rails applications. You can have cap give you a summary
@@ -313,7 +301,7 @@ Capistrano::Configuration.instance(:must_exist).load do
313
301
  defaults to :checkout).
314
302
  DESC
315
303
  task :update_code, :except => { :no_release => true } do
316
- on_rollback { run "rm -rf #{release_path}; true" }
304
+ on_rollback { run "chmod -R ug+w #{release_path}/sites && rm -rf #{release_path}; true" }
317
305
  strategy.deploy!
318
306
  finalize_update
319
307
  maintainance_keys
@@ -480,7 +468,7 @@ Capistrano::Configuration.instance(:must_exist).load do
480
468
  count = fetch(:keep_releases, 5).to_i
481
469
  if count < releases.length
482
470
  deploy.web.cleanup
483
- run "#{try_sudo} ls -1dt #{releases_path}/* | tail -n +#{count + 1} | #{try_sudo} xargs rm -rf"
471
+ run "ls -1dt #{releases_path}/* | tail -n +#{count + 1} | #{try_sudo} xargs rm -rf"
484
472
  end
485
473
  end
486
474
 
@@ -581,32 +569,20 @@ Capistrano::Configuration.instance(:must_exist).load do
581
569
  dp_domains.each do |domain|
582
570
  domain_path = "#{release_path}/#{dp_sites}/#{domain}"
583
571
 
584
- if remote_file_exists?("#{domain_path}/settings.#{stage}.php")
585
- commands << "#{try_sudo} ln -nfs #{domain_path}/settings.#{stage}.php #{domain_path}/settings.php"
586
- elsif remote_file_exists?("#{shared_path}/#{dp_sites}/#{domain}/settings.php")
587
- commands << "#{try_sudo} ln -nfs #{shared_path}/#{dp_sites}/#{domain}/settings.php #{domain_path}/settings.php"
588
- end
572
+ commands << "if [ -e '#{domain_path}/settings.#{stage}.php' ]; then #{try_sudo} ln -nfs #{domain_path}/settings.#{stage}.php #{domain_path}/settings.php; elif [ -e '#{shared_path}/#{dp_sites}/#{domain}/settings.php' ]; then #{try_sudo} ln -nfs #{shared_path}/#{dp_sites}/#{domain}/settings.php #{domain_path}/settings.php; fi"
573
+ commands << "if [ -e '#{domain_path}' ]; then #{try_sudo} ln -nfs #{shared_path}/#{dp_sites}/#{domain}/files #{domain_path}/files; fi"
589
574
 
590
- if remote_file_exists?(domain_path)
591
- commands << "#{try_sudo} ln -nfs #{shared_path}/#{dp_sites}/#{domain}/files #{domain_path}/files"
592
- end
593
575
  end
594
576
 
595
577
  run commands.join('; ') if commands.any?
596
578
  end
597
579
 
598
580
  task :htaccess, :except => { :no_release => true } do
599
- if remote_file_exists?("#{current_path}/htaccess-#{stage}")
600
- run "#{try_sudo} mv #{current_path}/htaccess-#{stage} #{current_path}/.htaccess && #{try_sudo} rm -rf #{current_path}/htaccess-*"
601
- elsif remote_file_exists?("#{current_path}/htaccess")
602
- run "#{try_sudo} mv #{current_path}/htaccess #{current_path}/.htaccess"
603
- end
581
+ run "if [ -e '#{current_path}/htaccess-#{stage}' ]; then #{try_sudo} mv #{current_path}/htaccess-#{stage} #{current_path}/.htaccess && #{try_sudo} rm -rf #{current_path}/htaccess-*; elif [ -e '#{current_path}/htaccess' ]; then #{try_sudo} mv #{current_path}/htaccess #{current_path}/.htaccess; fi"
604
582
  end
605
583
 
606
584
  task :robots, :except => { :no_release => true } do
607
- if remote_file_exists?("#{current_path}/robots-#{stage}.txt")
608
- run "#{try_sudo} mv #{current_path}/robots-#{stage}.txt #{current_path}/robots.txt; #{try_sudo} rm -rf #{current_path}/robots-*.txt"
609
- end
585
+ run "if [ -e '#{current_path}/robots-#{stage}.txt' ]; then #{try_sudo} mv #{current_path}/robots-#{stage}.txt #{current_path}/robots.txt && #{try_sudo} rm -rf #{current_path}/robots-*.txt; fi"
610
586
  end
611
587
 
612
588
  task :virtualhost, :except => { :no_release => true } do
@@ -628,7 +604,7 @@ Capistrano::Configuration.instance(:must_exist).load do
628
604
 
629
605
  default_shared_path = "#{shared_path}/#{dp_sites}/#{dp_default_domain}"
630
606
  default_current_path = "#{current_path}/#{dp_sites}/#{dp_default_domain}"
631
- run "#{drush} si #{dp_site_profile} --root=#{current_path} --db-url=#{dp_site_db_url} --site-name=\"#{dp_site_name}\" --account-name=\"#{dp_site_admin_user}\" --account-pass=\"#{dp_site_admin_pass}\" -y && #{try_sudo} cp #{default_current_path}/settings.php #{default_shared_path}/settings.php && chmod 444 #{default_shared_path}/settings.php && #{try_sudo} chmod -R ug+w #{default_current_path}; #{try_sudo} rm -rf #{default_current_path}/settings.php #{default_current_path}/files"
607
+ run "if [ -e '#{default_shared_path}/settings.php' ]; then chmod ug+w #{default_shared_path}/settings.php && rm -rf #{default_shared_path}/settings.php; fi; #{drush} si #{dp_site_profile} --root=#{current_path} --db-url=#{dp_site_db_url} --site-name=\"#{dp_site_name}\" --account-name=\"#{dp_site_admin_user}\" --account-pass=\"#{dp_site_admin_pass}\" -y && #{try_sudo} cp #{default_current_path}/settings.php #{default_shared_path}/settings.php && #{try_sudo} chmod -R ug+w #{default_current_path}; #{try_sudo} rm -rf #{default_current_path}/settings.php #{default_current_path}/files"
632
608
  end
633
609
  end
634
610
 
@@ -754,23 +730,12 @@ Capistrano::Configuration.instance(:must_exist).load do
754
730
  dp_domains.each do |domain|
755
731
  latest_release_name = latest_release.split('/').last
756
732
 
757
- files = "#{shared_path}/#{dp_released_files}/#{domain}/#{domain}_files_#{latest_release_name}.tar.bz2"
758
- if remote_file_exists?(files)
759
- domain_shared_path = "#{shared_path}/#{dp_sites}/#{domain}"
760
-
761
- commands << "#{try_sudo} rm -rf #{domain_shared_path}/files"
762
- commands << "#{try_sudo} tar xjf #{files} -C #{domain_shared_path}"
763
- commands << "#{try_sudo} chmod -R g+w #{domain_shared_path}/files"
764
- commands << "#{try_sudo} rm -rf #{files}"
765
- end
766
-
767
- db = "#{shared_path}/#{dp_released_db}/#{domain}/#{domain}_db_#{latest_release_name}.sql"
768
- if remote_file_exists?("#{db}.gz")
769
- commands << "#{try_sudo} gzip -d #{db}.gz"
770
- commands << "#{drush} sql-drop --root=#{current_path} --uri=#{domain} -y"
771
- commands << "#{drush} sqlq --file=#{db} --root=#{current_path} --uri=#{domain} -y"
772
- commands << "#{try_sudo} rm -rf #{db}"
773
- end
733
+ files_dump = "#{shared_path}/#{dp_released_files}/#{domain}/#{domain}_files_#{latest_release_name}.tar.bz2"
734
+ domain_shared_path = "#{shared_path}/#{dp_sites}/#{domain}"
735
+ commands << "if [ -e '#{files_dump}' ]; then rm -rf #{domain_shared_path}/files && tar xjf #{files_dump} -C #{domain_shared_path} && chmod -R g+w #{domain_shared_path}/files && rm -rf #{files_dump}; fi"
736
+
737
+ db_dump = "#{shared_path}/#{dp_released_db}/#{domain}/#{domain}_db_#{latest_release_name}.sql"
738
+ commands << "if [ -e '#{db_dump}.gz' ]; then gzip -d #{db_dump}.gz && #{drush} sql-drop --root=#{current_path} --uri=#{domain} -y && #{drush} sqlq --file=#{db_dump} --root=#{current_path} --uri=#{domain} -y && rm -rf #{db_dump}; fi"
774
739
  end
775
740
 
776
741
  run commands.join('; ') if commands.any?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erCapistranoDrupal
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - everright.chen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-17 00:00:00 Z
18
+ date: 2013-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: capistrano