capistrano-drupal 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ DS_Store
data/README.markdown ADDED
@@ -0,0 +1,22 @@
1
+ # Capistrano Drupal
2
+
3
+ This gem provides a number of tasks which are useful for deploying Drupal projects.
4
+
5
+ Credit goes to railsless-deploy for many ideas here.
6
+
7
+ ## Installation
8
+
9
+ # gem install capistrano-drupal
10
+
11
+ ## Usage
12
+
13
+ Open your application's `Capfile` and make it begin like this:
14
+
15
+ require 'rubygems'
16
+ require 'railsless-deploy'
17
+ require 'capistrano-drupal
18
+ load 'config/deploy'
19
+
20
+ You should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:
21
+
22
+ $ cap -T
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "capistrano-drupal"
5
+ gemspec.summary = "A set of tasks for deploying Drupal projects with Capistrano"
6
+ gemspec.description = "A set of tasks for deploying Drupal projects with Capistrano. Includes tasks for configuring apache and mysql"
7
+ gemspec.email = "kim@previousnext.com.au"
8
+ gemspec.homepage = "http://github.com/previousnext/capistrano-drupal/"
9
+ gemspec.authors = ["Kim Pepper"]
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.9
@@ -0,0 +1,42 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{capistrano-drupal}
8
+ s.version = "0.0.9"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kim Pepper"]
12
+ s.date = %q{2010-06-17}
13
+ s.description = %q{A set of tasks for deploying Drupal projects with Capistrano. Includes tasks for configuring apache and mysql}
14
+ s.email = %q{kim@previousnext.com.au}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README.markdown",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "capistrano-drupal.gemspec",
24
+ "lib/capistrano-drupal.rb"
25
+ ]
26
+ s.homepage = %q{http://github.com/previousnext/capistrano-drupal/}
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubygems_version = %q{1.3.7}
30
+ s.summary = %q{A set of tasks for deploying Drupal projects with Capistrano}
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ else
38
+ end
39
+ else
40
+ end
41
+ end
42
+
@@ -0,0 +1,132 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ require 'capistrano/recipes/deploy/scm'
4
+ require 'capistrano/recipes/deploy/strategy'
5
+
6
+ # =========================================================================
7
+ # These variables may be set in the client capfile if their default values
8
+ # are not sufficient.
9
+ # =========================================================================
10
+
11
+ set :scm, :git
12
+ set :deploy_via, :remote_cache
13
+ _cset :branch, "master"
14
+ set :git_enable_submodules, true
15
+ set :runner_group, "www-data"
16
+
17
+ set(:deploy_to) { "/var/www/#{application}" }
18
+ set :shared_children, ['files']
19
+
20
+ set(:db_root_password) {
21
+ Capistrano::CLI.ui.ask("MySQL root password:")
22
+ }
23
+
24
+ set(:db_username) {
25
+ Capistrano::CLI.ui.ask("MySQL username:")
26
+ }
27
+
28
+ set(:db_password) {
29
+ Capistrano::CLI.ui.ask("MySQL password:")
30
+ }
31
+
32
+ after "deploy:symlink", "drupal:symlink_shared"
33
+ after "deploy:setup", "drush:createdb"
34
+ after "deploy:setup", "drush:init_settings"
35
+ before "drush:updatedb", "drush:backupdb"
36
+ after "deploy:update_code", "drush:updatedb"
37
+ after "deploy:finalize_update", "drush:cache_clear"
38
+ after "deploy:finalize_update", "git:push_deploy_tag"
39
+ after "deploy:cleanup", "git:cleanup_deploy_tag"
40
+
41
+ namespace :deploy do
42
+ desc <<-DESC
43
+ Prepares one or more servers for deployment. Before you can use any \
44
+ of the Capistrano deployment tasks with your project, you will need to \
45
+ make sure all of your servers have been prepared with `cap deploy:setup'. When \
46
+ you add a new server to your cluster, you can easily run the setup task \
47
+ on just that server by specifying the HOSTS environment variable:
48
+
49
+ $ cap HOSTS=new.server.com deploy:setup
50
+
51
+ It is safe to run this task on servers that have already been set up; it \
52
+ will not destroy any deployed revisions or data.
53
+ DESC
54
+ task :setup, :except => { :no_release => true } do
55
+ dirs = [deploy_to, releases_path, shared_path]
56
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
57
+ run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chown #{runner}:#{runner_group} #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
58
+ end
59
+ end
60
+
61
+ namespace :drupal do
62
+ desc "Symlink settings and files to shared directory. This allows the settings.php and \
63
+ and sites/default/files directory to be correctly linked to the shared directory on a new deployment."
64
+ task :symlink_shared do
65
+ ["files", "settings.php"].each do |asset|
66
+ run "rm -rf #{app_path}/#{asset} && ln -nfs #{shared_path}/#{asset} #{app_path}/sites/default/#{asset}"
67
+ end
68
+ end
69
+ end
70
+
71
+ namespace :git do
72
+
73
+ desc "Place release tag into Git and push it to origin server."
74
+ task :push_deploy_tag do
75
+ user = `git config --get user.name`
76
+ email = `git config --get user.email`
77
+
78
+ puts `git tag release_#{release_name} #{revision} -m "Deployed by #{user} <#{email}>"`
79
+ puts `git push --tags`
80
+ end
81
+
82
+ desc "Place release tag into Git and push it to server."
83
+ task :cleanup_deploy_tag do
84
+ count = fetch(:keep_releases, 5).to_i
85
+ if count >= releases.length
86
+ logger.important "no old release tags to clean up"
87
+ else
88
+ logger.info "keeping #{count} of #{releases.length} release tags"
89
+
90
+ tags = (releases - releases.last(count)).map { |release| "release_#{release}" }
91
+
92
+ tags.each do |tag|
93
+ `git tag -d #{tag}`
94
+ `git push origin :refs/tags/#{tag}`
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ namespace :drush do
101
+
102
+ desc "Backup the database"
103
+ task :backupdb, :on_error => :continue do
104
+ t = Time.now.utc.strftime("%Y-%m-%dT%H-%M-%S")
105
+ run "drush -r #{current_path}/pressflow sql-dump --result-file=/tmp/#{application}-#{t}.sql"
106
+ end
107
+
108
+ desc "Run Drupal database migrations if required"
109
+ task :updatedb, :on_error => :continue do
110
+ run "drush -r #{app_path} updatedb -y"
111
+ end
112
+
113
+ desc "Clear the drupal cache"
114
+ task :cache_clear, :on_error => :continue do
115
+ run "drush -r #{app_path} cc all"
116
+ end
117
+
118
+ desc "Create the database"
119
+ task :createdb, :on_error => :continue do
120
+ run "mysqladmin -uroot -p#{db_root_password} create #{app_name}"
121
+ run "mysql -uroot -p#{db_root_password} #{app_name} -e \"grant all on #{app_name}.* to '#{db_username}'@'localhost' identified by '#{db_password}'\""
122
+ end
123
+
124
+ desc "Initialise settings.php"
125
+ task :init_settings do
126
+ upload "pressflow/sites/default/default.settings.php", "#{shared_path}/settings.php"
127
+ run "chmod 664 #{shared_path}/settings.php"
128
+ end
129
+
130
+ end
131
+
132
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-drupal
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 9
10
+ version: 0.0.9
11
+ platform: ruby
12
+ authors:
13
+ - Kim Pepper
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-17 00:00:00 +10:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A set of tasks for deploying Drupal projects with Capistrano. Includes tasks for configuring apache and mysql
23
+ email: kim@previousnext.com.au
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ files:
31
+ - .gitignore
32
+ - README.markdown
33
+ - Rakefile
34
+ - VERSION
35
+ - capistrano-drupal.gemspec
36
+ - lib/capistrano-drupal.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/previousnext/capistrano-drupal/
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: A set of tasks for deploying Drupal projects with Capistrano
71
+ test_files: []
72
+