public
Description: Automate your wordpress deploys with capistrano and git
Homepage: http://www.jestro.com
Clone URL: git://github.com/jestro/wordpress-capistrano.git
apache, ssh keys, etc
jnewland (author)
Mon Nov 24 09:14:28 -0800 2008
commit  772791986c703d0d251bee659f47f877aec0a88d
tree    7b240ffd72cab9f3e088b1df5316e7b5589362bc
parent  e9d8e98cf724e9ff536c38fb1ba0d32c6c2b120d
...
1
2
3
 
 
 
4
5
6
...
1
2
3
4
5
6
7
8
9
0
@@ -1,6 +1,9 @@
0
 #the domain name for the server you'll be running wordpress on
0
 set :domain, "localhost"
0
 
0
+#other domain names your app will respond to (dev.blog.com, etc)
0
+#set :server_aliases, []
0
+
0
 #the name of this wordpress project
0
 set :application, "wordpress-capistrano-test"
0
 
...
 
1
2
3
...
36
37
38
 
 
 
 
 
39
40
41
42
43
 
44
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
47
48
49
50
51
 
52
53
54
55
56
 
57
58
59
...
64
65
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
68
69
...
72
73
74
 
75
76
77
...
1
2
3
4
...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
70
71
72
73
74
 
75
76
77
78
...
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
108
109
110
111
112
113
114
0
@@ -1,3 +1,4 @@
0
+require 'erb'
0
 Capistrano::Configuration.instance.load do
0
   default_run_options[:pty] = true
0
   set :deploy_to, "/var/www/apps/#{application}"
0
@@ -36,24 +37,42 @@ Capistrano::Configuration.instance.load do
0
         ln -s #{latest_release}/config/wp-config.php #{latest_release}/wordpress/wp-config.php
0
       CMD
0
     end
0
+
0
+    task :cold do
0
+      update
0
+      apache.configure
0
+    end
0
   end
0
 
0
   namespace :setup do
0
 
0
     task :users do
0
+      set :user, 'root'
0
       reset_password
0
-      set :user, 'wordpress'
0
+      set :password_user, 'wordpress'
0
       reset_password
0
+      set :user, 'wordpress'
0
+      generate_ssh_keys
0
+    end
0
+
0
+    task :generate_ssh_keys do
0
+      run "ssh-keygen -q -f /home/wordpress/.ssh/id_rsa -N ''"
0
+      pubkey = capture("cat /home/wordpress/.ssh/id_rsa.pub")
0
+      puts "Below is a freshly generated SSH public key for your server."
0
+      puts "Please add this as a 'deploy key' to your github project."
0
+      puts ""
0
+      puts pubkey
0
+      puts ""
0
     end
0
 
0
     task :reset_password do
0
       user = fetch(:user, 'root')
0
-      puts "Changing password for user #{user}"
0
+      puts "Changing password for user #{password_user}"
0
       root_password = Capistrano::CLI.password_prompt "New UNIX password:"
0
       root_password_confirmation = Capistrano::CLI.password_prompt "Retype new UNIX password:"
0
       if root_password != ''
0
         if root_password == root_password_confirmation
0
-          run "echo \"#{ root_password }\" | sudo passwd --stdin #{user}"
0
+          run "echo \"#{ root_password }\" | sudo passwd --stdin #{password_user}"
0
         else
0
           puts "Passwords did not match"
0
           exit
0
@@ -64,6 +83,23 @@ Capistrano::Configuration.instance.load do
0
     end
0
   end
0
 
0
+  namespace :apache do
0
+    task :configure do
0
+      aliases = []
0
+      aliases << "www.#{domain}"
0
+      aliases.concat fetch(:server_aliases, [])
0
+      set :server_aliases_array, aliases
0
+
0
+      file = File.join(File.dirname(__FILE__), "..", "vhost.conf.erb")
0
+      template = File.read(file)
0
+      buffer = ERB.new(template).result(binding)
0
+
0
+      put buffer, "#{shared_path}/#{application}.conf", :mode => 0444
0
+      sudo "mv #{shared_path}/#{application}.conf /etc/httpd/conf.d/"
0
+      sudo "/etc/init.d/httpd restart"
0
+    end
0
+  end
0
+
0
   namespace :puppet do
0
 
0
     task :initial_setup do
0
@@ -72,6 +108,7 @@ Capistrano::Configuration.instance.load do
0
       download
0
       manually_update_node_definition
0
       update
0
+      set :user, 'wordpress'
0
     end
0
 
0
     task :install_dependencies do

Comments