Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit f63c199056d8b4f2f8b160ee6a94057415303d69 Jake Bell committed Nov 30, 2010
Showing with 193 additions and 0 deletions.
  1. +5 −0 README.textile
  2. +13 −0 Rakefile
  3. +1 −0 VERSION
  4. +33 −0 capistrano-ash.gemspec
  5. +48 −0 lib/ash/base.rb
  6. +5 −0 lib/ash/common.rb
  7. +88 −0 lib/ash/drupal.rb
@@ -0,0 +1,5 @@
+The capistrano/ash/drupal library takes a hash of Drupal multisites in the following format.
+
+@set :multisites, {"default" => "mysite.com", "another" => "another.mysite.com"}@
+
+where each key is a folder in your @sites@ directory and each value is the URL of the multisite. If you are not using multisites, just exclude the @:multisites@ variable definition.
@@ -0,0 +1,13 @@
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "capistrano-ash"
+ gemspec.summary = "August Ash recipes for Capistrano"
+ gemspec.description = "August Ash recipes for Capistrano"
+ gemspec.email = "jake@augustash.com"
+ gemspec.homepage = "https://github.com/augustash/capistrano-ash"
+ gemspec.authors = ["August Ash"]
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
@@ -0,0 +1 @@
+0.0.1
@@ -0,0 +1,33 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{capistrano-ash}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["August Ash"]
+ s.date = %q{2010-11-30}
+ s.description = %q{August Ash recipes for Capistrano}
+ s.email = %q{jake@augustash.com}
+ s.extra_rdoc_files = [
+ "README.textile"
+ ]
+ s.homepage = %q{https://github.com/augustash/capistrano-ash}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{August Ash recipes for Capistrano}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
@@ -0,0 +1,48 @@
+# Required gems/libraries
+require 'rubygems'
+require 'railsless-deploy'
+require 'capistrano/ext/multistage'
+require 'capistrano/ash/common'
+
+configuration = Capistrano::Configuration.respond_to?(:instance) ?
+ Capistrano::Configuration.instance(:must_exist) :
+ Capistrano.configuration(:must_exist)
+
+configuration.load do
+
+# --------------------------------------------
+# Setting defaults
+# --------------------------------------------
+_cset :copy_exclude, [".svn", ".DS_Store", "*.sample", "LICENSE*", "Capfile", "config"]
+_cset :deploy_via, :remote_cache
+_cset :group_writable, false
+_cset :use_sudo, false
+
+# --------------------------------------------
+# Calling our Methods
+# --------------------------------------------
+after "deploy:finalize_update", "ash:fixperms"
+
+# --------------------------------------------
+# Ash methods
+# --------------------------------------------
+namespace :ash do
+ desc "Fix the permissions on Ash servers"
+ task :fixperms, :except => { :no_release => true } do
+ # chmod the files and directories.
+ run "find #{latest_release} -type d -exec chmod 755 {} \\;"
+ run "find #{latest_release} -type f -exec chmod 644 {} \\;"
+ end
+
+ desc "Task for to test that Capistrano is working"
+ task :uname do
+ run "uname -a"
+ end
+
+ desc "Print environment of Capistrano user"
+ task :getpath do
+ run "echo $PATH"
+ end
+end
+
+end
@@ -0,0 +1,5 @@
+def _cset(name, *args, &block)
+ unless exists?(name)
+ set(name, *args, &block)
+ end
+end
@@ -0,0 +1,88 @@
+# Require our base library.
+require 'capistrano/ash/base'
+
+configuration = Capistrano::Configuration.respond_to?(:instance) ?
+ Capistrano::Configuration.instance(:must_exist) :
+ Capistrano.configuration(:must_exist)
+
+configuration.load do
+
+# --------------------------------------------
+# Setting defaults
+# --------------------------------------------
+_cset :multisites, {"default" => "default"}
+
+# --------------------------------------------
+# Calling our Methods
+# --------------------------------------------
+after "deploy:finalize_update", "drupal:setup"
+after "deploy:symlink", "drupal:symlink"
+after "deploy", "drupal:clearcache"
+after "deploy", "deploy:cleanup"
+
+# --------------------------------------------
+# Overloaded Methods
+# --------------------------------------------
+namespace :deploy do
+ desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes."
+ task :finalize_update, :except => { :no_release => true } do
+ # remove shared directories
+ multisites.each_pair do |folder, url|
+ run "mv #{latest_release}/sites/#{folder} #{latest_release}/sites/#{url}"
+ run "rm -Rf #{latest_release}/sites/#{url}/files"
+ end
+ end
+ namespace :web do
+ desc "Disable the application and show a message screen"
+ task :disable do
+ multisites.each_pair do |folder, url|
+ run "/usr/local/bin/drush -l #{url} -r #{latest_release} vset --yes site_offline 1"
+ end
+ end
+
+ desc "Enable the application and remove the message screen"
+ task :enable do
+ multisites.each_pair do |folder, url|
+ run "/usr/local/bin/drush -l #{url} -r #{latest_release} vdel --yes site_offline"
+ end
+ end
+ end
+end
+
+# --------------------------------------------
+# Drupal-specific methods
+# --------------------------------------------
+namespace :drupal do
+ desc "Setup shared Drupal directories and permissions"
+ task :setup, :except => { :no_release => true } do
+ multisites.each_pair do |folder, url|
+ run "mkdir -p #{shared_path}/#{url}/files"
+ end
+ sudo "chmod -R 777 #{shared_path}/*"
+ end
+
+ desc "Symlink shared directories"
+ task :symlink, :except => { :no_release => true } do
+ multisites.each_pair do |folder, url|
+ run "ln -nfs #{shared_path}/#{url}/files #{current_release}/sites/#{url}/files"
+ run "ln -nfs #{latest_release}/sites/#{url}/settings.php.#{stage} #{latest_release}/sites/#{url}/settings.php"
+ run "/usr/local/bin/drush -l #{url} -r #{current_path} vset --yes file_directory_path sites/#{url}/files"
+ end
+ end
+
+ desc "Replace local database paths with remote paths"
+ task :updatedb, :except => { :no_release => true } do
+ multisites.each_pair do |folder, url|
+ run "/usr/local/bin/drush -l #{url} -r #{current_path} sqlq \"UPDATE {files} SET filepath = REPLACE(filepath,'sites/#{folder}/files','sites/#{url}/files');\""
+ end
+ end
+
+ desc "Clear all Drupal cache"
+ task :clearcache, :except => { :no_release => true } do
+ multisites.each_pair do |folder, url|
+ run "/usr/local/bin/drush -l #{url} -r #{current_path} cache-clear all"
+ end
+ end
+end
+
+end

0 comments on commit f63c199

Please sign in to comment.