le1t0-deprec 2.1.6.001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/CHANGELOG +444 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +154 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +139 -0
  7. data/docs/EXAMPLE-installing_tracks.txt +41 -0
  8. data/docs/README.nagios +22 -0
  9. data/docs/README.rails +17 -0
  10. data/docs/config_gen_explained.txt +39 -0
  11. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  12. data/docs/deprec-1.x/notes.txt +12 -0
  13. data/docs/old/deprec_banner.gif +0 -0
  14. data/docs/windows_linux.txt +350 -0
  15. data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
  16. data/docs/xen/xen-tools-notes.txt +31 -0
  17. data/docs/xen/xen_on_hardy.txt +39 -0
  18. data/lib/deprec.rb +42 -0
  19. data/lib/deprec/capistrano_extensions.rb +446 -0
  20. data/lib/deprec/recipes.rb +7 -0
  21. data/lib/deprec/recipes/aoe.rb +79 -0
  22. data/lib/deprec/recipes/app/mongrel.rb +213 -0
  23. data/lib/deprec/recipes/app/passenger.rb +190 -0
  24. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  25. data/lib/deprec/recipes/aspell.rb +22 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/cap.rb +39 -0
  28. data/lib/deprec/recipes/chef.rb +68 -0
  29. data/lib/deprec/recipes/collectd.rb +112 -0
  30. data/lib/deprec/recipes/db/couchdb.rb +107 -0
  31. data/lib/deprec/recipes/db/mysql.rb +194 -0
  32. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  33. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  34. data/lib/deprec/recipes/ddclient.rb +51 -0
  35. data/lib/deprec/recipes/deprec.rb +167 -0
  36. data/lib/deprec/recipes/deprecated.rb +71 -0
  37. data/lib/deprec/recipes/drbd.rb +137 -0
  38. data/lib/deprec/recipes/dummy.rb +22 -0
  39. data/lib/deprec/recipes/example.rb +115 -0
  40. data/lib/deprec/recipes/git.rb +97 -0
  41. data/lib/deprec/recipes/gitosis.rb.disabled +55 -0
  42. data/lib/deprec/recipes/glusterfs.rb +176 -0
  43. data/lib/deprec/recipes/god.rb +70 -0
  44. data/lib/deprec/recipes/haproxy.rb +115 -0
  45. data/lib/deprec/recipes/heartbeat.rb +138 -0
  46. data/lib/deprec/recipes/imagemagick/imagemagick_bin.rb +24 -0
  47. data/lib/deprec/recipes/imagemagick/imagemagick_src.rb +39 -0
  48. data/lib/deprec/recipes/integrity.rb +108 -0
  49. data/lib/deprec/recipes/iptables.rb +94 -0
  50. data/lib/deprec/recipes/java.rb +23 -0
  51. data/lib/deprec/recipes/keepalived.rb +78 -0
  52. data/lib/deprec/recipes/ldap.rb +52 -0
  53. data/lib/deprec/recipes/logrotate.rb +56 -0
  54. data/lib/deprec/recipes/lvm.rb +20 -0
  55. data/lib/deprec/recipes/memcache.rb +49 -0
  56. data/lib/deprec/recipes/mongodb.rb +94 -0
  57. data/lib/deprec/recipes/monit.rb +135 -0
  58. data/lib/deprec/recipes/mysql_proxy.rb +67 -0
  59. data/lib/deprec/recipes/nagios.rb +361 -0
  60. data/lib/deprec/recipes/network.rb +116 -0
  61. data/lib/deprec/recipes/ntp.rb +103 -0
  62. data/lib/deprec/recipes/php.rb +58 -0
  63. data/lib/deprec/recipes/postfix.rb +115 -0
  64. data/lib/deprec/recipes/profiles.rb +125 -0
  65. data/lib/deprec/recipes/raid/amcc_3ware.rb +21 -0
  66. data/lib/deprec/recipes/rails.rb +330 -0
  67. data/lib/deprec/recipes/redhat_cluster.rb +228 -0
  68. data/lib/deprec/recipes/redis.rb +90 -0
  69. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  70. data/lib/deprec/recipes/ruby/ree.rb +40 -0
  71. data/lib/deprec/recipes/rvm.rb +32 -0
  72. data/lib/deprec/recipes/s3utils.rb +63 -0
  73. data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +105 -0
  74. data/lib/deprec/recipes/sphinx/ultrasphinx.rb +86 -0
  75. data/lib/deprec/recipes/ssh.rb +147 -0
  76. data/lib/deprec/recipes/ssl.rb +56 -0
  77. data/lib/deprec/recipes/starling.rb +119 -0
  78. data/lib/deprec/recipes/svn.rb +171 -0
  79. data/lib/deprec/recipes/syslog.rb +63 -0
  80. data/lib/deprec/recipes/trac.rb.disabled +277 -0
  81. data/lib/deprec/recipes/tsung.rb +74 -0
  82. data/lib/deprec/recipes/ubuntu.rb +90 -0
  83. data/lib/deprec/recipes/users.rb +90 -0
  84. data/lib/deprec/recipes/utils.rb +58 -0
  85. data/lib/deprec/recipes/vnstat.rb +85 -0
  86. data/lib/deprec/recipes/web/apache.rb +143 -0
  87. data/lib/deprec/recipes/web/nginx.rb +172 -0
  88. data/lib/deprec/recipes/wordpress.rb.notworking +96 -0
  89. data/lib/deprec/recipes/wpmu.rb +103 -0
  90. data/lib/deprec/recipes/xen.rb +364 -0
  91. data/lib/deprec/recipes/xentools.rb +101 -0
  92. data/lib/deprec/recipes_minus_rails.rb +125 -0
  93. data/lib/deprec/templates/aoe/aoe-init +55 -0
  94. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  95. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  96. data/lib/deprec/templates/apache/ports.conf.erb +5 -0
  97. data/lib/deprec/templates/apache/status.conf.erb +17 -0
  98. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  99. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  100. data/lib/deprec/templates/chef/chef.json.erb +1 -0
  101. data/lib/deprec/templates/chef/solo.rb +2 -0
  102. data/lib/deprec/templates/collectd/collectd-init.d +153 -0
  103. data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
  104. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  105. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  106. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  107. data/lib/deprec/templates/drbd/drbd.conf.erb +531 -0
  108. data/lib/deprec/templates/glusterfs/glusterfsd-init.erb +95 -0
  109. data/lib/deprec/templates/gnbd_client/cluster.conf.erb +21 -0
  110. data/lib/deprec/templates/gnbd_client/clvm-default.erb +3 -0
  111. data/lib/deprec/templates/gnbd_client/cman-default.erb +6 -0
  112. data/lib/deprec/templates/gnbd_client/gnbdimports.conf.erb +1 -0
  113. data/lib/deprec/templates/gnbd_server/cluster.conf.erb +20 -0
  114. data/lib/deprec/templates/gnbd_server/clvm-default.erb +3 -0
  115. data/lib/deprec/templates/gnbd_server/cman-default.erb +6 -0
  116. data/lib/deprec/templates/gnbd_server/gnbd-server-default.erb +1 -0
  117. data/lib/deprec/templates/gnbd_server/gnbdexports.conf.erb +1 -0
  118. data/lib/deprec/templates/god/god-conf.erb +2 -0
  119. data/lib/deprec/templates/god/god-init.erb +47 -0
  120. data/lib/deprec/templates/haproxy/haproxy-init.d +120 -0
  121. data/lib/deprec/templates/haproxy/haproxy.cfg.erb +31 -0
  122. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  123. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  124. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  125. data/lib/deprec/templates/integrity/apache_vhost.erb +4 -0
  126. data/lib/deprec/templates/integrity/config.ru.erb +21 -0
  127. data/lib/deprec/templates/integrity/config.yml.erb +43 -0
  128. data/lib/deprec/templates/iptables/firewall-default.erb +13 -0
  129. data/lib/deprec/templates/iptables/firewall-init.erb +171 -0
  130. data/lib/deprec/templates/keepalived/keepalived.conf.erb +18 -0
  131. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  132. data/lib/deprec/templates/mongodb/mongodb-init.d +88 -0
  133. data/lib/deprec/templates/mongrel/apache_vhost.conf.erb +148 -0
  134. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  135. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  136. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  137. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  138. data/lib/deprec/templates/mongrel/nginx_vhost.conf.erb +41 -0
  139. data/lib/deprec/templates/monit/monit-init-script +104 -0
  140. data/lib/deprec/templates/monit/monitrc.erb +250 -0
  141. data/lib/deprec/templates/monit/nothing.monitrc +0 -0
  142. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  143. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  144. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  145. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  146. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  147. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  148. data/lib/deprec/templates/mysql_proxy/mysql-proxy-default.erb +4 -0
  149. data/lib/deprec/templates/nagios/README +32 -0
  150. data/lib/deprec/templates/nagios/cgi.cfg.erb +357 -0
  151. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  152. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  153. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  154. data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
  155. data/lib/deprec/templates/nagios/nagios.cfg.erb +1325 -0
  156. data/lib/deprec/templates/nagios/nrpe.cfg.erb +222 -0
  157. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  158. data/lib/deprec/templates/nagios/objects/commands.cfg.erb +265 -0
  159. data/lib/deprec/templates/nagios/objects/contacts.cfg.erb +89 -0
  160. data/lib/deprec/templates/nagios/objects/hosts.cfg.erb +114 -0
  161. data/lib/deprec/templates/nagios/objects/localhost.cfg.erb +116 -0
  162. data/lib/deprec/templates/nagios/objects/services.cfg.erb +165 -0
  163. data/lib/deprec/templates/nagios/objects/timeperiods.cfg.erb +94 -0
  164. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  165. data/lib/deprec/templates/network/hostname.erb +1 -0
  166. data/lib/deprec/templates/network/hosts.erb +2 -0
  167. data/lib/deprec/templates/network/interfaces.erb +18 -0
  168. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  169. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  170. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  171. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  172. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  173. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  174. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  175. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  176. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  177. data/lib/deprec/templates/passenger/apache_vhost.erb +29 -0
  178. data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
  179. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  180. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  181. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  182. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  183. data/lib/deprec/templates/postfix/main.cf.erb +36 -0
  184. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  185. data/lib/deprec/templates/redis/redis-conf.erb +132 -0
  186. data/lib/deprec/templates/redis/redis-init.erb +50 -0
  187. data/lib/deprec/templates/s3utils/s3cfg +35 -0
  188. data/lib/deprec/templates/s3utils/s3config.yml +3 -0
  189. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  190. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  191. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  192. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  193. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  194. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  195. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  196. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  197. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  198. data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
  199. data/lib/deprec/templates/syslog/syslogd.erb +13 -0
  200. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  201. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  202. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  203. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  204. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  205. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  206. data/lib/deprec/templates/tsung/tsung.xml.erb +47 -0
  207. data/lib/deprec/templates/vnstat/config.php +57 -0
  208. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  209. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  210. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  211. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  212. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  213. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  214. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  215. data/lib/deprec/templates/xentools/100-ubuntu-setup +26 -0
  216. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  217. data/lib/deprec/templates/xentools/30-disable-gettys +57 -0
  218. data/lib/deprec/templates/xentools/31-ubuntu-setup +32 -0
  219. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  220. data/lib/deprec/templates/xentools/98-custom +17 -0
  221. data/lib/deprec/templates/xentools/xen-tools.conf.erb +278 -0
  222. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  223. data/lib/deprec_cmd_completion.sh +26 -0
  224. data/lib/deprec_minus_rails.rb +12 -0
  225. data/lib/vmbuilder_plugins/all.rb +20 -0
  226. data/lib/vmbuilder_plugins/apt.rb +93 -0
  227. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  228. data/lib/vmbuilder_plugins/gem.rb +100 -0
  229. data/lib/vmbuilder_plugins/std.rb +203 -0
  230. metadata +304 -0
@@ -0,0 +1,147 @@
1
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :ssh do
5
+
6
+ # hash of :user => :ssh_key combinations
7
+ # :ssh_*_keys can be:
8
+ # - one key (a string)
9
+ # - an array of keys
10
+ set :ssh_user_keys, { }
11
+ set :ssh_host_keys, { }
12
+ # an array of symbols or strings containing user_names/host_names as defined in :ssh_*_keys
13
+ set :ssh_users, [ ]
14
+ set :ssh_hosts, [ ]
15
+
16
+ SYSTEM_CONFIG_FILES[:ssh] = [
17
+
18
+ {:template => "sshd_config.erb",
19
+ :path => '/etc/ssh/sshd_config',
20
+ :mode => 0644,
21
+ :owner => 'root:root'},
22
+
23
+ {:template => "ssh_config.erb",
24
+ :path => '/etc/ssh/ssh_config',
25
+ :mode => 0644,
26
+ :owner => 'root:root'}
27
+ ]
28
+
29
+ task :config_gen do
30
+ SYSTEM_CONFIG_FILES[:ssh].each do |file|
31
+ deprec2.render_template(:ssh, file)
32
+ end
33
+ auth_keys_dir = 'config/ssh/authorized_keys'
34
+ if ! File.directory?(auth_keys_dir)
35
+ puts "Creating #{auth_keys_dir}"
36
+ Dir.mkdir(auth_keys_dir)
37
+ end
38
+ end
39
+
40
+ desc "Push ssh config files to server"
41
+ task :config do
42
+ deprec2.push_configs(:ssh, SYSTEM_CONFIG_FILES[:ssh])
43
+ restart
44
+ end
45
+
46
+ task :set_access do
47
+ if ssh_users.size > 0
48
+ run "rm -f ~/.ssh/authorized_keys.new"
49
+ ssh_users.each do |ssh_user|
50
+ keys = [ssh_user_keys[ssh_user]].flatten
51
+ keys.each do |ssh_key|
52
+ deprec2.append_to_file_if_missing('~/.ssh/authorized_keys.new', ssh_key)
53
+ end
54
+ end
55
+ run "cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys.bak"
56
+ run "mv ~/.ssh/authorized_keys.new ~/.ssh/authorized_keys"
57
+ end
58
+
59
+ if ssh_hosts.size > 0
60
+ run "rm -f ~/.ssh/known_hosts.new"
61
+ ssh_hosts.each do |ssh_user|
62
+ keys = [ssh_host_keys[ssh_user]].flatten
63
+ keys.each do |ssh_key|
64
+ deprec2.append_to_file_if_missing('~/.ssh/known_hosts.new', ssh_key)
65
+ end
66
+ end
67
+ run "cp ~/.ssh/known_hosts ~/.ssh/known_hosts.bak"
68
+ run "mv ~/.ssh/known_hosts.new ~/.ssh/known_hosts"
69
+ end
70
+ end
71
+
72
+ desc "Start ssh"
73
+ task :start do
74
+ send(run_method, "/etc/init.d/ssh reload")
75
+ end
76
+
77
+ desc "Stop ssh"
78
+ task :stop do
79
+ send(run_method, "/etc/init.d/ssh reload")
80
+ end
81
+
82
+ desc "Restart ssh"
83
+ task :restart do
84
+ send(run_method, "/etc/init.d/ssh restart")
85
+ end
86
+
87
+ desc "Reload ssh"
88
+ task :reload do
89
+ send(run_method, "/etc/init.d/ssh reload")
90
+ end
91
+
92
+ desc "Sets up authorized_keys file on remote server"
93
+ task :setup_keys do
94
+
95
+ default(:target_user) {
96
+ Capistrano::CLI.ui.ask "Setup keys for which user?" do |q|
97
+ q.default = user
98
+ end
99
+ }
100
+
101
+ # If we have an authorized keys file for this user
102
+ # then copy that out
103
+ if File.exists?("config/ssh/authorized_keys/#{target_user}")
104
+ deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
105
+ std.su_put File.read("config/ssh/authorized_keys/#{target_user}"), "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
106
+ sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
107
+
108
+ elsif target_user == user
109
+
110
+ # If the user has specified a key Capistrano should use
111
+ if ssh_options[:keys]
112
+ deprec2.mkdir '.ssh', :mode => 0700
113
+ put(ssh_options[:keys].collect{|key| File.read("#{key}.pub")}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
114
+
115
+ # Try to find the current users public key
116
+ elsif keys = %w[id_rsa id_dsa identity].collect { |f| "#{ENV['HOME']}/.ssh/#{f}.pub" if File.exists?("#{ENV['HOME']}/.ssh/#{f}.pub") }.compact
117
+ deprec2.mkdir '.ssh', :mode => 0700
118
+ put(keys.collect{|key| File.read(key)}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
119
+
120
+ else
121
+ puts <<-ERROR
122
+
123
+ You need to define the name of your SSH key(s)
124
+ e.g. ssh_options[:keys] = %w(/Users/your_username/.ssh/id_rsa)
125
+
126
+ You can put this in your .caprc file in your home directory.
127
+
128
+ ERROR
129
+ exit
130
+ end
131
+ else
132
+ puts <<-ERROR
133
+
134
+ Could not find ssh public key(s) for user #{user}
135
+
136
+ Please create file containing ssh public keys in:
137
+
138
+ config/ssh/authorized_keys/#{target_user}
139
+
140
+ ERROR
141
+ end
142
+
143
+ end
144
+
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :ssl do
5
+
6
+ # Install Openssl
7
+ task :install, :roles => :web do
8
+ install_deps
9
+ end
10
+
11
+ # Install dependencies for ssl
12
+ task :install_deps, :roles => :web do
13
+ apt.install( {:base => %w(openssl)}, :stable )
14
+ end
15
+
16
+ PROJECT_CONFIG_FILES[:ssl] = [
17
+
18
+ {:template => 'ssl-cert-snakeoil.pem',
19
+ :path => '/etc/ssl/certs/ssl-cert-snakeoil.pem',
20
+ :mode => 0644,
21
+ :owner => 'root:root'},
22
+
23
+ {:template => 'ssl-cert-snakeoil.key',
24
+ :path => "/etc/ssl/private/ssl-cert-snakeoil.key",
25
+ :mode => 0640,
26
+ :owner => 'root:ssl-cert'},
27
+
28
+ { :template => 'make-ssl-cert',
29
+ :path => "/usr/sbin/make-ssl-cert",
30
+ :mode => 0755,
31
+ :owner => 'root:root'}
32
+
33
+ ]
34
+
35
+ # Generate ssl certs
36
+ task :config_gen do
37
+ PROJECT_CONFIG_FILES[:ssl].each do |file|
38
+ deprec2.render_template(:ssl, file)
39
+ end
40
+ end
41
+
42
+ # Copy out ssl certs
43
+ task :config, :roles => :web do
44
+ deprec2.push_configs(:ssl, PROJECT_CONFIG_FILES[:ssl])
45
+ end
46
+
47
+ # WOn't run without controlling terminal! :-(
48
+ # task :generate_snakeoil_cert, :roles => :web do
49
+ # sudo "/usr/sbin/make-ssl-cert generate-default-snakeoil"
50
+ # end
51
+
52
+ end
53
+
54
+ end
55
+ end
56
+
@@ -0,0 +1,119 @@
1
+ # Deprec script to install the Starling Messaging Server
2
+ # This uses the forked copy located at http://github.com/starling/starling instead of the original gem
3
+ # The start/stop/restart tasks are based on code used in the 'starling.ubuntu' script which is contained in the Starling repository.
4
+ Capistrano::Configuration.instance(:must_exist).load do
5
+ namespace :deprec do
6
+ namespace :starling do
7
+ set :starling_port, 15151
8
+ set :starling_address, "127.0.0.1"
9
+ set :starling_user, "starling"
10
+ set :starling_group, "starling"
11
+ set :starling_spool_dir, "/var/spool/starling"
12
+ set :starling_run_dir, "/var/run/starling"
13
+ set :starling_log_dir, "/var/log/starling"
14
+ set :starling_runtime_options, "-h #{starling_address} -p #{starling_port} -d -q #{starling_spool_dir} -P #{starling_spool_dir}/starling.pid -L #{starling_log_dir}/starling.log"
15
+
16
+ # Installation
17
+ desc "Installs the Starling gem"
18
+ task :install, :roles => :app do
19
+ sudo("gem install eventmachine --no-rdoc --no-ri")
20
+ sudo("gem install starling-starling --source http://gems.github.com -v 0.9.9 --no-rdoc --no-ri")
21
+
22
+ deprec2.mkdir(starling_spool_dir, :via => :sudo)
23
+ deprec2.mkdir(starling_run_dir, :via => :sudo)
24
+ deprec2.mkdir(starling_log_dir, :via => :sudo)
25
+
26
+ create_starling_user_and_group
27
+ set_perms_for_starling_dirs
28
+ symlink_starling_for_rubyee if ruby_vm_type == :ree
29
+
30
+ SYSTEM_CONFIG_FILES[:starling].each do |file|
31
+ deprec2.render_template(:starling, file.merge(:remote=>true))
32
+ end
33
+
34
+ activate
35
+ end
36
+
37
+ # Configure
38
+
39
+ SYSTEM_CONFIG_FILES[:starling] = [
40
+ {:template => 'starling-init-script.erb',
41
+ :path => '/etc/init.d/starling',
42
+ :mode => 0755,
43
+ :owner => 'root:root'},
44
+
45
+ {:template => 'monit.conf.erb',
46
+ :path => "/etc/monit.d/monit_starling.conf",
47
+ :mode => 0600,
48
+ :owner => 'root:root'}
49
+ ]
50
+
51
+ # Generating Configuration Files
52
+ desc "Generate configuration file(s) for Starling from template(s)"
53
+ task :config_gen do
54
+ SYSTEM_CONFIG_FILES[:starling].each do |file|
55
+ deprec2.render_template(:starling, file)
56
+ end
57
+ end
58
+
59
+ desc 'Deploy configuration files(s) for Starling'
60
+ task :config, :roles => :app do
61
+ deprec2.push_configs(:starling, SYSTEM_CONFIG_FILES[:starling])
62
+ end
63
+
64
+ # Control
65
+
66
+ desc "Starts the Starling server"
67
+ task :start, :roles => :app do
68
+ send(run_method, "start-stop-daemon -c #{starling_user}:#{starling_group} --start --quiet --pidfile #{starling_run_dir}/starling.pid --exec /usr/local/bin/starling -- #{starling_runtime_options}")
69
+ end
70
+
71
+ desc "Stops the Starling server"
72
+ task :stop, :roles => :app do
73
+ send(run_method, "start-stop-daemon -c #{starling_user}:#{starling_group} --stop --quiet --pidfile #{starling_run_dir}/starling.pid --exec /usr/local/bin/starling -- #{starling_runtime_options}")
74
+ end
75
+
76
+ desc "Restarts the Starling server"
77
+ task :restart, :roles => :app do
78
+ send(run_method, "start-stop-daemon -c #{starling_user}:#{starling_group} --stop --quiet --pidfile #{starling_run_dir}/starling.pid --exec /usr/local/bin/starling -- #{starling_runtime_options}")
79
+ sleep(2)
80
+ send(run_method, "start-stop-daemon -c #{starling_user}:#{starling_group} --start --quiet --pidfile #{starling_run_dir}/starling.pid --exec /usr/local/bin/starling -- #{starling_runtime_options}")
81
+ end
82
+
83
+ task :activate, :roles => :app do
84
+ send(run_method, "update-rc.d starling defaults")
85
+ end
86
+
87
+ task :deactivate, :roles => :app do
88
+ send(run_method, "update-rc.d -f starling remove")
89
+ end
90
+
91
+ # User/Group creation & permission assignment
92
+ # These were based off the tasks used in the mongrel recipe -
93
+ # as this was probably the nicest way to ensure these tasks
94
+ # were doing the right thing.
95
+ desc "create user and group for starling to run as"
96
+ task :create_starling_user_and_group, :roles => :app do
97
+ deprec2.groupadd(starling_group)
98
+ deprec2.useradd(starling_user, :group => starling_group, :homedir => false)
99
+ # Set the primary group for the starling user (in case user already existed
100
+ # when previous command was run)
101
+ sudo "usermod --gid #{starling_group} #{starling_user}"
102
+ end
103
+
104
+ desc "set group ownership and permissions on dirs starling needs to write to"
105
+ task :set_perms_for_starling_dirs, :roles => :app do
106
+ sudo "chgrp -R #{starling_group} #{starling_spool_dir} #{starling_run_dir} #{starling_log_dir}"
107
+ sudo "chmod -R g+w #{starling_spool_dir} #{starling_run_dir} #{starling_log_dir}"
108
+ end
109
+
110
+ task :symlink_starling_for_rubyee, :roles => :app do
111
+ # This ensures we symlink from the REE common directory, NOT the
112
+ # actual REE install directory (so when we change the REE version,
113
+ # we don't have to fuddle around again).
114
+ sudo "ln -s #{ree_short_path}/bin/starling /usr/local/bin/starling"
115
+ end
116
+
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,171 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ require 'fileutils'
3
+ require 'uri'
4
+
5
+ # http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.serverconfig.choosing.apache
6
+
7
+ Capistrano::Configuration.instance(:must_exist).load do
8
+ namespace :deprec do
9
+ namespace :svn do
10
+
11
+ set :scm_group, 'scm'
12
+
13
+ # Extract svn attributes from :repository URL
14
+ #
15
+ # Two examples of :repository entries are:
16
+ #
17
+ # set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk'
18
+ # set :repository, 'file:///tmp/svn/deprec/trunk'
19
+ #
20
+ # This has only been tested with svn+ssh but file: should work.
21
+ #
22
+ set (:svn_scheme) { URI.parse(repository).scheme }
23
+ set (:svn_host) { URI.parse(repository).host }
24
+ set (:repos_path) { URI.parse(repository).path }
25
+ set (:repos_root) {
26
+ URI.parse(repository).path.sub(/\/(trunk|tags|branches)$/, '')
27
+ }
28
+
29
+ # account name to perform actions on (such as granting access to an account)
30
+ # this is a hack to allow us to optionally pass a variable to tasks
31
+ set (:svn_account) do
32
+ Capistrano::CLI.ui.ask 'account name'
33
+ end
34
+
35
+ set(:svn_backup_dir) { File.join(backup_dir, 'svn') }
36
+
37
+ desc "Install Subversion"
38
+ task :install do
39
+ install_deps
40
+ # XXX should really check if apache has already been installed
41
+ # XXX can do that when we move to rake
42
+ # deprec2.download_src(src_package, src_dir)
43
+ # deprec2.install_from_src(src_package, src_dir)
44
+ end
45
+
46
+ desc "install dependencies for Subversion"
47
+ task :install_deps do
48
+ apt.install( {:base => %w(subversion)}, :stable )
49
+ # XXX deprec1 - was building from source to get subversion-1.4.5 onto dapper. Compiled swig bindings for trac
50
+ # apt.install( {:base => %w(build-essential wget libneon25 libneon25-dev swig python-dev libexpat1-dev)}, :stable )
51
+ end
52
+
53
+ desc "grant a user access to svn repos"
54
+ task :grant_user_access, :roles => :scm do
55
+ # creates account, scm_group and adds account to group
56
+ deprec2.useradd(svn_account)
57
+ deprec2.groupadd(scm_group)
58
+ deprec2.add_user_to_group(svn_account, scm_group)
59
+ end
60
+
61
+ desc "Create subversion repository and import project into it"
62
+ task :setup, :roles => :scm do
63
+ create_repos
64
+ import
65
+ end
66
+
67
+ desc "Create a subversion repository"
68
+ task :create_repos, :roles => :scm do
69
+ set :svn_account, top.user
70
+ grant_user_access
71
+ deprec2.mkdir(repos_root, :mode => 02775, :group => scm_group, :via => :sudo)
72
+ sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
73
+ sudo "chmod -R g+w #{repos_root}"
74
+ end
75
+
76
+ # Adapted from code in Bradley Taylors RailsMachine gem
77
+ desc "Import project into subversion repository."
78
+ task :import, :roles => :scm do
79
+ new_path = "../#{application}"
80
+ tags = repository.sub("trunk", "tags")
81
+ branches = repository.sub("trunk", "branches")
82
+ puts "Adding branches and tags"
83
+ system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
84
+ puts "Importing application."
85
+ system "svn import #{repository} -m 'Import'"
86
+ cwd = Dir.getwd
87
+ puts "Moving application to new directory"
88
+ Dir.chdir '../'
89
+ system "mv #{cwd} #{cwd}.imported"
90
+ puts "Checking out application."
91
+ system "svn co #{repository} #{application}"
92
+ Dir.chdir application
93
+ remove_log_and_tmp
94
+ puts "Your repository is: #{repository}"
95
+ end
96
+
97
+ # Lifted from Bradley Taylors RailsMachine gem
98
+ desc "remove and ignore log files and tmp from subversion"
99
+ task :remove_log_and_tmp, :roles => :scm do
100
+ puts "removing log directory contents from svn"
101
+ system "svn remove log/*"
102
+ puts "ignoring log directory"
103
+ system "svn propset svn:ignore '*.log' log/"
104
+ system "svn update log/"
105
+ puts "removing contents of tmp sub-directorys from svn"
106
+ system "svn remove tmp/cache/*"
107
+ system "svn remove tmp/pids/*"
108
+ system "svn remove tmp/sessions/*"
109
+ system "svn remove tmp/sockets/*"
110
+ puts "ignoring tmp directory"
111
+ system "svn propset svn:ignore '*' tmp/cache"
112
+ system "svn propset svn:ignore '*' tmp/pids"
113
+ system "svn propset svn:ignore '*' tmp/sessions"
114
+ system "svn propset svn:ignore '*' tmp/sockets"
115
+ system "svn update tmp/"
116
+ puts "committing changes"
117
+ system "svn commit -m 'Removed and ignored log files and tmp'"
118
+ end
119
+
120
+ # desc "Cache svn name and password on the server. Useful for http-based repositories."
121
+ task :cache_credentials do
122
+ run_with_input "svn list #{repository}"
123
+ end
124
+
125
+ desc "create backup of trac repository"
126
+ task :backup, :roles => :scm do
127
+ # http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.backup
128
+ # XXX do we need this? insane!
129
+ # echo "REPOS_BASE=/var/svn" > ~/.svntoolsrc
130
+ DATE=`date +%Y%m%d-%a`
131
+
132
+ timestamp = Time.now.strftime("%Y%m%d-%a")
133
+ deprec2.mkdir(svn_backup_dir, :owner => :root, :group => :deploy, :mode => 0775, :via => :sudo)
134
+ dest_dir = File.join(svn_backup_dir, "#{application}_#{timestamp}")
135
+ sudo "svnadmin hotcopy #{repos_root} #{dest_dir}"
136
+ end
137
+
138
+ task :restore, :roles => :scm do
139
+ # prompt user to select from list of locally stored backups
140
+ # tracd_stop
141
+ # copy out backup
142
+ end
143
+
144
+
145
+ # XXX TODO
146
+ # desc "backup repository"
147
+ # task :svn_backup_respository, :roles => :scm do
148
+ # puts "read http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.maint.backup"
149
+ # end
150
+
151
+ end
152
+ end
153
+ end
154
+
155
+ # svnserve setup
156
+ # I've previously used ssh exclusively I've decided svnserve is a reasonable choice for collaboration on open source projects.
157
+ # It's easier to setup than apache/ssl webdav access.
158
+ #
159
+ # sudo useradd svn
160
+ # sudo mkdir -p /var/svn/deprec_svnserve_root
161
+ # sudo ln -sf /var/www/apps/deprec/repos /var/svn/deprec_svnserve_root/deprec
162
+ # sudo chown -R svn /var/svn/deprec_svnserve_root/deprec
163
+
164
+ #
165
+ # XXX put password file into svn and command to push it
166
+ #
167
+ # # run svnserve
168
+ # sudo -u svn svnserve --daemon --root /var/svn/deprec_svnserve_root
169
+ #
170
+ # # check it out now
171
+ # svn co svn://scm.deprecated.org/deprec/trunk deprec