Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a common method and test tasks to check if a file exists on the…

… remote server; modified the Drupal recipe to use the new file checking to determine which settings file should be symlinked
  • Loading branch information...
commit 2df5fc350adc461fcf9990170f52b8dfd6baf503 1 parent b52e0b4
@jjohnson-xx jjohnson-xx authored
Showing with 48 additions and 15 deletions.
  1. +1 −1  Rakefile
  2. +26 −1 lib/ash/base.rb
  3. +6 −0 lib/ash/common.rb
  4. +15 −13 lib/ash/drupal.rb
View
2  Rakefile
@@ -7,7 +7,7 @@ begin
gemspec.name = "capistrano-ash"
gemspec.summary = "Useful task libraries for August Ash recipes for Capistrano"
gemspec.description = "August Ash recipes for Capistrano"
- gemspec.email = "jake@augustash.com"
+ gemspec.email = "code@augustash.com"
gemspec.homepage = "https://github.com/augustash/capistrano-ash"
gemspec.authors = ["August Ash"]
end
View
27 lib/ash/base.rb
@@ -105,7 +105,7 @@
run "echo $PATH"
end
end
-
+
# --------------------------------------------
# PHP tasks
# --------------------------------------------
@@ -235,4 +235,29 @@
end
end
+ # --------------------------------------------
+ # Remote File/Directory test tasks
+ # --------------------------------------------
+ namespace :remote do
+ namespace :file do
+ desc "Test: Task to test existence of missing file"
+ task :missing do
+ if remote_file_exists?('/dev/mull')
+ logger.info "FAIL - Why does the '/dev/mull' path exist???"
+ else
+ logger.info "GOOD - Verified the '/dev/mull' path does not exist!"
+ end
+ end
+
+ desc "Test: Task used to test existence of a present file"
+ task :exists do
+ if remote_file_exists?('/dev/null')
+ logger.info "GOOD - Verified the '/dev/null' path exists!"
+ else
+ logger.info "FAIL - WHAT happened to the '/dev/null' path???"
+ end
+ end
+ end
+ end
+
end
View
6 lib/ash/common.rb
@@ -14,4 +14,10 @@ def _cset(name, *args, &block)
# +prompt+
def text_prompt(prompt="Value: ")
Capistrano::CLI.ui.ask(prompt) { |q| q.echo = true }
+end
+
+# Test to see if a file exists by providing
+# the full path to the expected file location
+def remote_file_exists?(full_path)
+ 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
end
View
28 lib/ash/drupal.rb
@@ -11,7 +11,7 @@
# --------------------------------------------
# Setting defaults
# --------------------------------------------
- proc{_cset( :multisites, {"default" => "#{application}"} )}
+ proc{_cset( :multisites, {"#{application}" => "#{application}"} )}
set :drush_bin, "drush"
# --------------------------------------------
@@ -94,11 +94,11 @@
desc "Symlink shared directories"
task :symlink, :except => { :no_release => true } do
multisites.each_pair do |folder, url|
- run "ln -nfs #{shared_path}/#{url}/files #{latest_release}/sites/#{url}/files"
- run "#{drush_bin} -l #{url} -r #{current_path} vset --yes file_directory_path sites/#{url}/files"
-
# symlinks the appropriate environment's settings.php file
symlink_config_file
+
+ run "ln -nfs #{shared_path}/#{url}/files #{latest_release}/sites/#{url}/files"
+ run "#{drush_bin} -l #{url} -r #{current_path} vset --yes file_directory_path sites/#{url}/files"
end
end
@@ -110,15 +110,17 @@
settings.php.<environment> => deprecated
DESC
task :symlink_config_file, :except => { :no_release => true} do
- drupal_app_site_dir = " #{latest_release}/sites/#{url}"
-
- case true
- when !Dir.entries(drupal_app_site_dir).glob('settings.*.php').empty?
- run "ln -nfs #{drupal_app_site_dir}/settings.#{stage}.php #{drupal_app_site_dir}/settings.php"
- when !Dir.entries(drupal_app_site_dir).glob('settings.php.*').empty?
- run "ln -nfs #{drupal_app_site_dir}/settings.php.#{stage} #{drupal_app_site_dir}/settings.php"
- else
- logger.important "Failed to symlink the settings.php file because an unknown pattern was used"
+ multisites.each_pair do |folder, url|
+ drupal_app_site_dir = " #{latest_release}/sites/#{url}"
+
+ case true
+ when remote_file_exists?("#{drupal_app_site_dir}/settings.#{stage}.php")
+ run "ln -nfs #{drupal_app_site_dir}/settings.#{stage}.php #{drupal_app_site_dir}/settings.php"
+ when remote_file_exists?("#{drupal_app_site_dir}/settings.php.#{stage}")
+ run "ln -nfs #{drupal_app_site_dir}/settings.php.#{stage} #{drupal_app_site_dir}/settings.php"
+ else
+ logger.important "Failed to symlink the settings.php file in #{drupal_app_site_dir} because an unknown pattern was used"
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.