require 'drupistrano/commands' Capistrano::Configuration.instance.load do # User configurable _cset(:site_uri) { "default" } _cset(:drush_path) { "drush" } _cset(:ispconfig) { false } # Change at your own risk _cset(:normalize_asset_timestamps) { false } _cset(:drush_cmd) { "#{drush_path} --uri=#{site_uri}" } _cset(:site_config_path) { "#{shared_path}/sites/#{site_uri}" } namespace :deploy do task :start do ; end task :stop do ; end task :restart do ; end desc "Backup the DB before this update" task :backup_db, :roles => :db do on_rollback { run "rm #{previous_release}/dump.sql" if previous_release } if previous_release run "cd #{previous_release} && #{drush_cmd} sql-dump > dump.sql" end end desc "Move default drupal files if they exist and symlink to shared path" task :move_default_files, :roles => :app do run <<-CMD if [ -d #{release_path}/sites/default/files ]; then \ cd #{release_path}/sites/default && \ rsync -avz files/ #{shared_path}/files && \ rm -rf files; \ fi; \ cd #{release_path}/sites/default && ln -nsf ../../../../shared/files/ . CMD end desc "Symlink site configuration into place" task :symlink_configuration, :roles => :app do run <<-CMD if [ -f #{site_config_path}/settings.php ]; then \ mkdir -p #{release_path}/sites/#{site_uri} && \ #{symlink_configuration_cmd}; \ fi CMD end desc "Revert all features" task :revert_features, :roles => :app do if previous_release run "cd #{current_release} && #{drush_cmd} -y features-revert-all" end end desc "Clear all cache" task :clear_cache, :roles => :app do if previous_release run "cd #{current_release} && #{drush_cmd} cache-clear all" end end desc "Execute database updates" task :migrate, :roles => :db do run "cd #{current_release} && #{drush_cmd} -y updatedb" end desc "Setup configuration" task :setup_configuration, :roles => :app do run "mkdir -p #{site_config_path}" top.upload File.join('sites', 'default', 'default.settings.php'), File.join(site_config_path, 'settings.php') end # Rewrite symlink task to add support for ISPConfig desc <<-DESC Updates the symlink to the most recently deployed version. Capistrano works \ by putting each new release of your application in its own directory. When \ you deploy a new version, this task's job is to update the `current' symlink \ to point at the new version. You will rarely need to call this task \ directly; instead, use the `deploy' task (which performs a complete \ deploy, including `restart') or the 'update' task (which does everything \ except `restart'). DESC task :symlink, :except => { :no_release => true } do on_rollback do if previous_release run symlink_rollback_cmd else logger.important "no previous release to rollback to, rollback of symlink skipped" end end run symlink_execute_cmd end end end