wp-capistrano 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -18,11 +18,15 @@ Capistrano::Configuration.instance.load do
18
18
  set :user, t.ssh_user
19
19
  set :deploy_to, t.path
20
20
  set :wordpress_domain, t.vhost
21
+ set :wordpress_domain, 'localhost' if wordpress_domain.nil?
21
22
  set :wordpress_db_name, t.database.name
22
23
  set :wordpress_db_user, t.database.user
24
+ set :wordpress_db_user, 'root' if wordpress_db_user.nil?
23
25
  set :wordpress_db_password, t.database.password
24
26
  set :wordpress_db_host, t.database.host
27
+ set :wordpress_db_host, 'localhost' if wordpress_db_host.nil?
25
28
  set :use_sudo, t.use_sudo
29
+ set :deploy_profile, t
26
30
 
27
31
  @roles = {}
28
32
  role :app, domain
@@ -31,6 +31,38 @@ Capistrano::Configuration.instance.load do
31
31
  chmod -R 777 #{latest_release}/finalized/wp-content/cache/ ;
32
32
  true
33
33
  CMD
34
+
35
+ ## WP Super Cache
36
+
37
+ if deploy_profile.modules and deploy_profile.modules.include? 'wp-super-cache'
38
+
39
+ if File.exist? 'plugins/wp-super-cache/advanced-cache.php'
40
+ top.upload("plugins/wp-super-cache/advanced-cache.php", "#{latest_release}/finalized/wp-content/" , :via => :scp)
41
+ sedable_path = "#{latest_release}/finalized/wp-content/plugins/wp-super-cache/".gsub(/\//,'\/')
42
+ run("sed -i 's/CACHEHOME/#{sedable_path}/g' #{latest_release}/finalized/wp-content/advanced-cache.php")
43
+ else
44
+ raise IOError, 'Are you sure you have the WP Super Cache plugin?'
45
+ end
46
+
47
+ if File.exist? 'wp-cache-config.php'
48
+ top.upload("wp-cache-config.php", "#{latest_release}/finalized/wp-content/" , :via => :scp)
49
+ elsif File.exist? 'plugins/wp-super-cache/wp-cache-config-sample.php'
50
+ top.upload("plugins/wp-super-cache/wp-cache-config-sample.php", "#{latest_release}/finalized/wp-content/wp-cache-config.php" , :via => :scp)
51
+ else
52
+ raise IOError, 'Are you sure you have the WP Super Cache plugin?'
53
+ end
54
+
55
+ #TODO
56
+ if File.exist? 'htaccess'
57
+ top.upload("htaccess", "#{latest_release}/finalized/.htaccess" , :via => :scp)
58
+ end
59
+
60
+ run("mkdir -p #{latest_release}/finalized/wp-content/cache/blogs &&
61
+ mkdir -p #{latest_release}/finalized/wp-content/cache/meta &&
62
+ chmod -R 777 #{latest_release}/finalized/wp-content/cache &&
63
+ chmod -R 777 #{latest_release}/finalized/wp-content/wp-cache-config.php")
64
+
65
+ end
34
66
  end
35
67
 
36
68
  desc "Compile SASS locally and upload it"
@@ -1,6 +1,11 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
  namespace :setup do
3
3
 
4
+ desc "Alias for wordpress"
5
+ task :default do
6
+ setup.wordpress
7
+ end
8
+
4
9
  desc "Setup this server for a new wordpress site."
5
10
  task :wordpress do
6
11
  "mkdir -p #{deploy_to}"
@@ -14,28 +19,47 @@ Capistrano::Configuration.instance.load do
14
19
 
15
20
  desc "Creates uploads dir"
16
21
  task :uploads do
17
- chmod = true
18
- if File.exist? 'uploads'
19
- begin
20
- upload("uploads", shared_path, :recursive => true, :via => :scp)
21
- rescue
22
- STDERR.puts '*** uploads dir already exists and does not belong to us. Not re-uploading.'
23
- chmod = false
22
+
23
+ stop = false
24
+
25
+ # If it already exists, stop
26
+ run("ls -d #{shared_path}/uploads") do |channel,stream,data|
27
+ if data.strip=="#{shared_path}/uploads"
28
+ STDERR.puts '*** uploads dir already exists. Not re-uploading.'
29
+ stop = true
30
+ end
31
+ end
32
+
33
+ unless stop
34
+ # If we have it, upload it
35
+ if File.exist?('uploads')
36
+ begin
37
+ upload("uploads", shared_path, :recursive => true, :via => :scp)
38
+ rescue
39
+ STDERR.puts '*** uploads dir already exists and does not belong to us. Can\'t re-upload.'
40
+ stop = true
41
+ end
42
+ else
43
+ run "mkdir -p #{shared_path}/uploads"
44
+ end
45
+
46
+ unless stop
47
+ # Let our Web server write to it
48
+ run "chmod -R 777 #{shared_path}/uploads"
24
49
  end
25
- else
26
- run "mkdir -p #{shared_path}/uploads"
27
50
  end
28
- run "chmod -R 777 #{shared_path}/uploads" if chmod
29
51
  end
30
52
 
31
53
  desc "Creates the DB, and loads the dump"
32
54
  task :mysql do
33
- upload("data/dump.sql.gz", shared_path, :via => :scp)
34
- run <<-CMD
35
- test #{wordpress_db_name}X != `echo 'show databases' | mysql -u root | grep '^#{wordpress_db_name}$'`X &&
36
- echo 'create database if not exists `#{wordpress_db_name}`' | mysql -u root &&
37
- zcat #{shared_path}/dump.sql.gz | sed 's/localhost/#{wordpress_domain}/g' | mysql -u root #{wordpress_db_name} || true
38
- CMD
55
+ if File.exist? 'data/dump.sql.gz'
56
+ upload("data/dump.sql.gz", shared_path, :via => :scp)
57
+ run <<-CMD
58
+ test #{wordpress_db_name}X != `echo 'show databases' | mysql | grep '^#{wordpress_db_name}$'`X &&
59
+ echo 'create database if not exists `#{wordpress_db_name}`' | mysql &&
60
+ zcat #{shared_path}/dump.sql.gz | sed 's/localhost/#{wordpress_domain}/g' | mysql #{wordpress_db_name} || true
61
+ CMD
62
+ end
39
63
  end
40
64
 
41
65
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - The Dextrous Web
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-25 00:00:00 +01:00
17
+ date: 2010-08-10 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20