Empact-deprec 1.99.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. data/CHANGELOG +170 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +136 -0
  5. data/THANKS +5 -0
  6. data/bin/depify +133 -0
  7. data/docs/ANNOUNCE.deprec2 +47 -0
  8. data/docs/README.install +88 -0
  9. data/docs/README.nagios +28 -0
  10. data/docs/README.rails +20 -0
  11. data/docs/README.svn +31 -0
  12. data/docs/ROADMAP.txt +74 -0
  13. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  14. data/docs/deprec-1.x/notes.txt +12 -0
  15. data/docs/deprec_banner.gif +0 -0
  16. data/lib/deprec.rb +8 -0
  17. data/lib/deprec/capistrano_extensions.rb +378 -0
  18. data/lib/deprec/recipes.rb +40 -0
  19. data/lib/deprec/recipes/aoe.rb +117 -0
  20. data/lib/deprec/recipes/apache.rb +179 -0
  21. data/lib/deprec/recipes/ar_sendmail.rb +65 -0
  22. data/lib/deprec/recipes/canonical.rb +57 -0
  23. data/lib/deprec/recipes/deprec.rb +155 -0
  24. data/lib/deprec/recipes/deprecated.rb +71 -0
  25. data/lib/deprec/recipes/example.rb +115 -0
  26. data/lib/deprec/recipes/git.rb +168 -0
  27. data/lib/deprec/recipes/gitosis.rb +47 -0
  28. data/lib/deprec/recipes/god.rb +107 -0
  29. data/lib/deprec/recipes/heartbeat.rb +138 -0
  30. data/lib/deprec/recipes/iptables.rb +53 -0
  31. data/lib/deprec/recipes/logrotate.rb +51 -0
  32. data/lib/deprec/recipes/lvm.rb +20 -0
  33. data/lib/deprec/recipes/memcached.rb +102 -0
  34. data/lib/deprec/recipes/mongrel.rb +209 -0
  35. data/lib/deprec/recipes/monit.rb +130 -0
  36. data/lib/deprec/recipes/mysql.rb +115 -0
  37. data/lib/deprec/recipes/nagios.rb +302 -0
  38. data/lib/deprec/recipes/network.rb +84 -0
  39. data/lib/deprec/recipes/nginx.rb +154 -0
  40. data/lib/deprec/recipes/ntp.rb +96 -0
  41. data/lib/deprec/recipes/php.rb +99 -0
  42. data/lib/deprec/recipes/postfix.rb +105 -0
  43. data/lib/deprec/recipes/rails.rb +302 -0
  44. data/lib/deprec/recipes/ruby.rb +66 -0
  45. data/lib/deprec/recipes/sphinx.rb +83 -0
  46. data/lib/deprec/recipes/ssh.rb +93 -0
  47. data/lib/deprec/recipes/svn.rb +169 -0
  48. data/lib/deprec/recipes/swiftiply.rb +108 -0
  49. data/lib/deprec/recipes/thin.rb +201 -0
  50. data/lib/deprec/recipes/trac.rb +277 -0
  51. data/lib/deprec/recipes/ubuntu.rb +20 -0
  52. data/lib/deprec/recipes/users.rb +90 -0
  53. data/lib/deprec/recipes/utils.rb +39 -0
  54. data/lib/deprec/recipes/xen.rb +259 -0
  55. data/lib/deprec/templates/aoe/aoe-init +55 -0
  56. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  57. data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
  58. data/lib/deprec/templates/apache/httpd.conf +465 -0
  59. data/lib/deprec/templates/apache/index.html.erb +37 -0
  60. data/lib/deprec/templates/apache/master.css +72 -0
  61. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  62. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  63. data/lib/deprec/templates/coraid/aoe-init +55 -0
  64. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  65. data/lib/deprec/templates/god/god-init-script +71 -0
  66. data/lib/deprec/templates/god/god-notifications +0 -0
  67. data/lib/deprec/templates/god/god_mongrel.erb +81 -0
  68. data/lib/deprec/templates/god/god_mysql.erb +50 -0
  69. data/lib/deprec/templates/god/god_nginx.erb +61 -0
  70. data/lib/deprec/templates/god/god_thin.erb +80 -0
  71. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  72. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  73. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  74. data/lib/deprec/templates/iptables/iptables.up.erb +41 -0
  75. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  76. data/lib/deprec/templates/memcached/memcached-init-script +65 -0
  77. data/lib/deprec/templates/memcached/memcached.conf.erb +46 -0
  78. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  79. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  80. data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
  81. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  82. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  83. data/lib/deprec/templates/monit/monit-init-script +104 -0
  84. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  85. data/lib/deprec/templates/monit/nothing +0 -0
  86. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  87. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  88. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  89. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  90. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  91. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  92. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  93. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  94. data/lib/deprec/templates/nagios/contacts.cfg.erb +75 -0
  95. data/lib/deprec/templates/nagios/hosts.cfg.erb +70 -0
  96. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  97. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  98. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  99. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  100. data/lib/deprec/templates/nagios/nrpe.cfg.erb +208 -0
  101. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  102. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  103. data/lib/deprec/templates/nagios/services.cfg.erb +7 -0
  104. data/lib/deprec/templates/nagios/templates.cfg.erb +190 -0
  105. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  106. data/lib/deprec/templates/network/hostname.erb +1 -0
  107. data/lib/deprec/templates/network/hosts.erb +2 -0
  108. data/lib/deprec/templates/network/interfaces.erb +18 -0
  109. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  110. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  111. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  112. data/lib/deprec/templates/nginx/nginx.conf.erb +53 -0
  113. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  114. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  115. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +45 -0
  116. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  117. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  118. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  119. data/lib/deprec/templates/postfix/main.cf.erb +41 -0
  120. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  121. data/lib/deprec/templates/rails/database.yml.erb +6 -0
  122. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  123. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  124. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  125. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  126. data/lib/deprec/templates/swiftiply/swiftiply-init-script +61 -0
  127. data/lib/deprec/templates/swiftiply/swiftiply.yml.erb +11 -0
  128. data/lib/deprec/templates/thin/thin-init-script +51 -0
  129. data/lib/deprec/templates/thin/thin.yml.erb +11 -0
  130. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  131. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  132. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  133. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  134. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  135. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  136. data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
  137. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  138. data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
  139. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  140. data/lib/deprec/templates/xen/xend-init.erb +69 -0
  141. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  142. data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
  143. data/lib/vmbuilder_plugins/all.rb +20 -0
  144. data/lib/vmbuilder_plugins/apt.rb +93 -0
  145. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  146. data/lib/vmbuilder_plugins/gem.rb +90 -0
  147. data/lib/vmbuilder_plugins/std.rb +203 -0
  148. metadata +207 -0
@@ -0,0 +1,66 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ namespace :deprec do
5
+ namespace :ruby do
6
+
7
+ SRC_PACKAGES[:ruby] = {
8
+ :filename => 'ruby-1.8.6-p114.tar.gz',
9
+ :md5sum => "500a9f11613d6c8ab6dcf12bec1b3ed3 ruby-1.8.6-p114.tar.gz",
10
+ :dir => 'ruby-1.8.6-p114',
11
+ :url => "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p114.tar.gz",
12
+ :unpack => "tar zxf ruby-1.8.6-p114.tar.gz;",
13
+ :configure => %w(
14
+ ./configure
15
+ --with-readline-dir=/usr/local
16
+ ;
17
+ ).reject{|arg| arg.match '#'}.join(' '),
18
+ :make => 'make;',
19
+ :install => 'make install;'
20
+ }
21
+
22
+ task :install do
23
+ install_deps
24
+ deprec2.download_src(SRC_PACKAGES[:ruby], src_dir)
25
+ deprec2.install_from_src(SRC_PACKAGES[:ruby], src_dir)
26
+ end
27
+
28
+ task :install_deps do
29
+ apt.install( {:base => %w(zlib1g-dev libssl-dev libncurses5-dev libreadline5-dev)}, :stable )
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+
36
+ namespace :deprec do
37
+ namespace :rubygems do
38
+
39
+ SRC_PACKAGES[:rubygems] = {
40
+ :filename => 'rubygems-1.0.1.tgz',
41
+ :md5sum => "0d5851084955c327ee1dc9cbd631aa5f rubygems-1.0.1.tgz",
42
+ :dir => 'rubygems-1.0.1',
43
+ :url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz",
44
+ :unpack => "tar zxf rubygems-1.0.1.tgz;",
45
+ :install => 'ruby setup.rb;'
46
+ }
47
+
48
+ task :install do
49
+ install_deps
50
+ deprec2.download_src(SRC_PACKAGES[:rubygems], src_dir)
51
+ deprec2.install_from_src(SRC_PACKAGES[:rubygems], src_dir)
52
+ # gem2.upgrade # you may not want to upgrade your gems right now
53
+ # If we want to selfupdate then we need to
54
+ # create symlink as latest gems version is broken
55
+ # gem2.update_system
56
+ # sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
57
+ end
58
+
59
+ # install dependencies for rubygems
60
+ task :install_deps do
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,83 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :sphinx do
5
+
6
+ SRC_PACKAGES[:sphinx] = {
7
+ :filename => 'sphinx-0.9.8-rc2.tar.gz',
8
+ :dir => 'sphinx-0.9.8-rc2',
9
+ :url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz",
10
+ :unpack => "tar zxf sphinx-0.9.8-rc2.tar.gz;",
11
+ :configure => %w(
12
+ ./configure
13
+ ;
14
+ ).reject{|arg| arg.match '#'}.join(' '),
15
+ :make => 'make;',
16
+ :install => 'make install;'
17
+ }
18
+
19
+ desc "install Sphinx Search Engine"
20
+ task :install do
21
+ deprec2.download_src(SRC_PACKAGES[:sphinx], src_dir)
22
+ deprec2.install_from_src(SRC_PACKAGES[:sphinx], src_dir)
23
+ end
24
+
25
+ # install dependencies for sphinx
26
+ task :install_deps do
27
+ # apt.install( {:base => %w(blah)}, :stable )
28
+ end
29
+
30
+ SYSTEM_CONFIG_FILES[:sphinx] = []
31
+
32
+ PROJECT_CONFIG_FILES[:sphinx] = [
33
+
34
+ {:template => 'monit.conf.erb',
35
+ :path => 'monit.conf',
36
+ :mode => 0644,
37
+ :owner => 'root:root'}
38
+
39
+ ]
40
+
41
+ desc <<-DESC
42
+ Generate sphinx config from template. Note that this does not
43
+ push the config to the server, it merely generates required
44
+ configuration files. These should be kept under source control.
45
+ The can be pushed to the server with the :config task.
46
+ DESC
47
+ task :config_gen do
48
+ PROJECT_CONFIG_FILES[:sphinx].each do |file|
49
+ deprec2.render_template(:sphinx, file)
50
+ end
51
+ end
52
+
53
+ desc "Push sphinx config files to server"
54
+ task :config, :roles => :sphinx do
55
+ config_project
56
+ end
57
+
58
+ desc "Push sphinx config files to server"
59
+ task :config_project, :roles => :sphinx do
60
+ deprec2.push_configs(:sphinx, PROJECT_CONFIG_FILES[:sphinx])
61
+ symlink_monit_config
62
+ end
63
+
64
+ task :symlink_monit_config, :roles => :sphinx do
65
+ sudo "ln -sf #{deploy_to}/sphinx/monit.conf #{monit_confd_dir}/sphinx_#{application}.conf"
66
+ end
67
+
68
+
69
+ # Control
70
+
71
+ desc "Restart the sphinx searchd daemon"
72
+ task :restart, :roles => :app do
73
+ run("cd #{deploy_to}/current; /usr/bin/rake us:start") ### start or restart? SUDO ? ###
74
+ end
75
+
76
+ desc "Regenerate / Rotate the search index."
77
+ task :reindex, :roles => :app do
78
+ run("cd #{deploy_to}/current; /usr/bin/rake us:in") ### SUDO ? ###
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,93 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :ssh do
5
+
6
+ SYSTEM_CONFIG_FILES[:ssh] = [
7
+
8
+ {:template => "sshd_config.erb",
9
+ :path => '/etc/ssh/sshd_config',
10
+ :mode => 0644,
11
+ :owner => 'root:root'},
12
+
13
+ {:template => "ssh_config.erb",
14
+ :path => '/etc/ssh/ssh_config',
15
+ :mode => 0644,
16
+ :owner => 'root:root'}
17
+ ]
18
+
19
+ task :config_gen do
20
+ SYSTEM_CONFIG_FILES[:ssh].each do |file|
21
+ deprec2.render_template(:ssh, file)
22
+ end
23
+ auth_keys_dir = 'config/ssh/authorized_keys'
24
+ if ! File.directory?(auth_keys_dir)
25
+ puts "Creating #{auth_keys_dir}"
26
+ Dir.mkdir(auth_keys_dir)
27
+ end
28
+ end
29
+
30
+ desc "Push ssh config files to server"
31
+ task :config do
32
+ deprec2.push_configs(:ssh, SYSTEM_CONFIG_FILES[:ssh])
33
+ restart
34
+ end
35
+
36
+ desc "Start ssh"
37
+ task :start do
38
+ send(run_method, "/etc/init.d/ssh reload")
39
+ end
40
+
41
+ desc "Stop ssh"
42
+ task :stop do
43
+ send(run_method, "/etc/init.d/ssh reload")
44
+ end
45
+
46
+ desc "Restart ssh"
47
+ task :restart do
48
+ send(run_method, "/etc/init.d/ssh restart")
49
+ end
50
+
51
+ desc "Reload ssh"
52
+ task :reload do
53
+ send(run_method, "/etc/init.d/ssh reload")
54
+ end
55
+
56
+ desc "Sets up authorized_keys file on remote server"
57
+ task :setup_keys do
58
+
59
+ default(:target_user) {
60
+ Capistrano::CLI.ui.ask "Setup keys for which user?" do |q|
61
+ q.default = user
62
+ end
63
+ }
64
+
65
+ if target_user == user
66
+
67
+ unless ssh_options[:keys]
68
+ puts <<-ERROR
69
+
70
+ You need to define the name of your SSH key(s)
71
+ e.g. ssh_options[:keys] = %w(/Users/your_username/.ssh/id_rsa)
72
+
73
+ You can put this in your .caprc file in your home directory.
74
+
75
+ ERROR
76
+ exit
77
+ end
78
+
79
+ deprec2.mkdir '.ssh', :mode => 0700
80
+ put(ssh_options[:keys].collect{|key| File.read(key+'.pub')}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
81
+
82
+ else
83
+
84
+ deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
85
+ std.su_put File.read("config/ssh/authorized_keys/#{target_user}"), "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
86
+ sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
87
+
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,169 @@
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 namespace :svn do
9
+
10
+ set :scm_group, 'scm'
11
+
12
+ # Extract svn attributes from :repository URL
13
+ #
14
+ # Two examples of :repository entries are:
15
+ #
16
+ # set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk'
17
+ # set :repository, 'file:///tmp/svn/deprec/trunk'
18
+ #
19
+ # This has only been tested with svn+ssh but file: should work.
20
+ #
21
+ set (:svn_scheme) { URI.parse(repository).scheme }
22
+ set (:svn_host) { URI.parse(repository).host }
23
+ set (:repos_path) { URI.parse(repository).path }
24
+ set (:repos_root) {
25
+ URI.parse(repository).path.sub(/\/(trunk|tags|branches)$/, '')
26
+ }
27
+
28
+ # account name to perform actions on (such as granting access to an account)
29
+ # this is a hack to allow us to optionally pass a variable to tasks
30
+ set (:svn_account) do
31
+ Capistrano::CLI.ui.ask 'account name'
32
+ end
33
+
34
+ set(:svn_backup_dir) { File.join(backup_dir, 'svn') }
35
+
36
+ desc "Install Subversion"
37
+ task :install, :roles => :scm do
38
+ install_deps
39
+ # XXX should really check if apache has already been installed
40
+ # XXX can do that when we move to rake
41
+ # deprec2.download_src(src_package, src_dir)
42
+ # deprec2.install_from_src(src_package, src_dir)
43
+ end
44
+
45
+ desc "install dependencies for Subversion"
46
+ task :install_deps do
47
+ apt.install( {:base => %w(subversion)}, :stable )
48
+ # XXX deprec1 - was building from source to get subversion-1.4.5 onto dapper. Compiled swig bindings for trac
49
+ # apt.install( {:base => %w(build-essential wget libneon25 libneon25-dev swig python-dev libexpat1-dev)}, :stable )
50
+ end
51
+
52
+ desc "grant a user access to svn repos"
53
+ task :grant_user_access, :roles => :scm do
54
+ # creates account, scm_group and adds account to group
55
+ deprec2.useradd(svn_account)
56
+ deprec2.groupadd(scm_group)
57
+ deprec2.add_user_to_group(svn_account, scm_group)
58
+ end
59
+
60
+ desc "Create subversion repository and import project into it"
61
+ task :setup, :roles => :scm do
62
+ create_repos
63
+ import
64
+ end
65
+
66
+ desc "Create a subversion repository"
67
+ task :create_repos, :roles => :scm do
68
+ set :svn_account, top.user
69
+ grant_user_access
70
+ deprec2.mkdir(repos_root, :mode => 02775, :group => scm_group, :via => :sudo)
71
+ sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
72
+ sudo "chmod -R g+w #{repos_root}"
73
+ end
74
+
75
+ # Adapted from code in Bradley Taylors RailsMachine gem
76
+ desc "Import project into subversion repository."
77
+ task :import, :roles => :scm do
78
+ new_path = "../#{application}"
79
+ tags = repository.sub("trunk", "tags")
80
+ branches = repository.sub("trunk", "branches")
81
+ puts "Adding branches and tags"
82
+ system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
83
+ puts "Importing application."
84
+ system "svn import #{repository} -m 'Import'"
85
+ cwd = Dir.getwd
86
+ puts "Moving application to new directory"
87
+ Dir.chdir '../'
88
+ system "mv #{cwd} #{cwd}.imported"
89
+ puts "Checking out application."
90
+ system "svn co #{repository} #{application}"
91
+ Dir.chdir application
92
+ remove_log_and_tmp
93
+ puts "Your repository is: #{repository}"
94
+ end
95
+
96
+ # Lifted from Bradley Taylors RailsMachine gem
97
+ desc "remove and ignore log files and tmp from subversion"
98
+ task :remove_log_and_tmp, :roles => :scm do
99
+ puts "removing log directory contents from svn"
100
+ system "svn remove log/*"
101
+ puts "ignoring log directory"
102
+ system "svn propset svn:ignore '*.log' log/"
103
+ system "svn update log/"
104
+ puts "removing contents of tmp sub-directorys from svn"
105
+ system "svn remove tmp/cache/*"
106
+ system "svn remove tmp/pids/*"
107
+ system "svn remove tmp/sessions/*"
108
+ system "svn remove tmp/sockets/*"
109
+ puts "ignoring tmp directory"
110
+ system "svn propset svn:ignore '*' tmp/cache"
111
+ system "svn propset svn:ignore '*' tmp/pids"
112
+ system "svn propset svn:ignore '*' tmp/sessions"
113
+ system "svn propset svn:ignore '*' tmp/sockets"
114
+ system "svn update tmp/"
115
+ puts "committing changes"
116
+ system "svn commit -m 'Removed and ignored log files and tmp'"
117
+ end
118
+
119
+ # desc "Cache svn name and password on the server. Useful for http-based repositories."
120
+ task :cache_credentials do
121
+ run_with_input "svn list #{repository}"
122
+ end
123
+
124
+ desc "create backup of trac repository"
125
+ task :backup, :roles => :scm do
126
+ # http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.backup
127
+ # XXX do we need this? insane!
128
+ # echo "REPOS_BASE=/var/svn" > ~/.svntoolsrc
129
+ DATE=`date +%Y%m%d-%a`
130
+
131
+ timestamp = Time.now.strftime("%Y%m%d-%a")
132
+ deprec2.mkdir(svn_backup_dir, :owner => :root, :group => :deploy, :mode => 0775, :via => :sudo)
133
+ dest_dir = File.join(svn_backup_dir, "#{application}_#{timestamp}")
134
+ sudo "svnadmin hotcopy #{repos_root} #{dest_dir}"
135
+ end
136
+
137
+ task :restore, :roles => :scm do
138
+ # prompt user to select from list of locally stored backups
139
+ # tracd_stop
140
+ # copy out backup
141
+ end
142
+
143
+
144
+ # XXX TODO
145
+ # desc "backup repository"
146
+ # task :svn_backup_respository, :roles => :scm do
147
+ # puts "read http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.maint.backup"
148
+ # end
149
+
150
+ end end
151
+ end
152
+
153
+ # svnserve setup
154
+ # I've previously used ssh exclusively I've decided svnserve is a reasonable choice for collaboration on open source projects.
155
+ # It's easier to setup than apache/ssl webdav access.
156
+ #
157
+ # sudo useradd svn
158
+ # sudo mkdir -p /var/svn/deprec_svnserve_root
159
+ # sudo ln -sf /var/www/apps/deprec/repos /var/svn/deprec_svnserve_root/deprec
160
+ # sudo chown -R svn /var/svn/deprec_svnserve_root/deprec
161
+
162
+ #
163
+ # XXX put password file into svn and command to push it
164
+ #
165
+ # # run svnserve
166
+ # sudo -u svn svnserve --daemon --root /var/svn/deprec_svnserve_root
167
+ #
168
+ # # check it out now
169
+ # svn co svn://scm.deprecated.org/deprec/trunk deprec
@@ -0,0 +1,108 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :swiftiply do
5
+
6
+ set(:swiftiply_conf_dir) { "/etc/swiftiply/" }
7
+ set(:swiftiply_conf) { "/etc/swiftiply/swiftiply.conf" }
8
+ set(:swiftiply_pid_file) { "/var/run/swiftiply/swiftiply.pid" }
9
+ set :swiftiply_port, 9000
10
+
11
+ # No Rubygems loading (citing reasons of speed)
12
+ SRC_PACKAGES[:swiftiply] = {
13
+ :filename => 'swiftiply-0.6.1.1.tar.bz2',
14
+ :md5sum => "c2ff6de68701f778fd7d3d40b907e562 swiftiply-0.6.1.1.tar.bz2",
15
+ :dir => 'swiftiply-0.6.1.1',
16
+ :url => "http://swiftiply.swiftcore.org/files/swiftiply-0.6.1.1.tar.bz2",
17
+ :unpack => "tar jxf swiftiply-0.6.1.1.tar.bz2;",
18
+ :install => 'ruby setup.rb;'
19
+ }
20
+
21
+ # No Rubygems loading (citing reasons of speed)
22
+ SRC_PACKAGES[:event_machine] = {
23
+ :filename => 'eventmachine-0.10.0.tar.gz',
24
+ :md5sum => "5f9dd6419c7ae0e3af569d315d8ee4f2 eventmachine-0.10.0.tar.gz",
25
+ :dir => 'eventmachine-0.10.0',
26
+ :url => "http://files.rubyforge.vm.bytemark.co.uk/eventmachine/eventmachine-0.10.0.tar.gz",
27
+ :unpack => "tar zxf eventmachine-0.10.0.tar.gz;",
28
+ :install => 'ruby setup.rb;'
29
+ }
30
+
31
+
32
+ desc "Install swiftiply"
33
+ task :install, :roles => :web do
34
+ install_deps
35
+ deprec2.download_src(SRC_PACKAGES[:swiftiply], src_dir)
36
+ deprec2.install_from_src(SRC_PACKAGES[:swiftiply], src_dir)
37
+ end
38
+
39
+ task :install_deps do
40
+ deprec2.download_src(SRC_PACKAGES[:event_machine], src_dir)
41
+ deprec2.install_from_src(SRC_PACKAGES[:event_machine], src_dir)
42
+ end
43
+
44
+ SYSTEM_CONFIG_FILES[:swiftiply] = [
45
+
46
+ {:template => "swiftiply-init-script",
47
+ :path => '/etc/init.d/swiftiply',
48
+ :mode => 0755,
49
+ :owner => 'root:root'},
50
+
51
+ ]
52
+
53
+ desc "Generate configuration file(s) for swiftiply"
54
+ task :config_gen do
55
+ SYSTEM_CONFIG_FILES[:swiftiply].each do |file|
56
+ deprec2.render_template(:swiftiply, file)
57
+ end
58
+ end
59
+
60
+ desc 'Deploy configuration files(s) for swiftiply'
61
+ task :config, :roles => :web do
62
+ deprec2.push_configs(:swiftiply, SYSTEM_CONFIG_FILES[:swiftiply])
63
+ deprec2.mkdir(swiftiply_conf_dir, :via => :sudo)
64
+ end
65
+
66
+ task :start, :roles => :web do
67
+ send(run_method, "/etc/init.d/swiftiply start")
68
+ end
69
+
70
+ task :stop, :roles => :web do
71
+ send(run_method, "/etc/init.d/swiftiply stop")
72
+ end
73
+
74
+ task :restart, :roles => :web do
75
+ send(run_method, "/etc/init.d/swiftiply restart")
76
+ end
77
+
78
+ task :reload, :roles => :web do
79
+ send(run_method, "/etc/init.d/swiftiply reload")
80
+ end
81
+
82
+ # This task will be called from a handler's config_project
83
+ # merges a yml file into the swiftiply conf
84
+ task :config_merge, :roles => :web do
85
+ end
86
+
87
+ # This task will be called from a handler's config_project
88
+ # unmerges a yml file into the swiftiply conf
89
+ task :config_unmerge, :roles => :web do
90
+ end
91
+
92
+ task :activate, :roles => :web do
93
+ send(run_method, "update-rc.d swiftiply defaults")
94
+ end
95
+
96
+ task :deactivate, :roles => :web do
97
+ send(run_method, "update-rc.d swiftiply defaults")
98
+ end
99
+
100
+ task :backup, :roles => :web do
101
+ end
102
+
103
+ task :restore, :roles => :web do
104
+ end
105
+
106
+ end
107
+ end
108
+ end