deprec 2.2.3 → 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/CHANGELOG +1 -1
  2. data/bin/depify +3 -8
  3. data/{lib → docs}/deprec_cmd_completion.sh +0 -0
  4. data/lib/deprec.rb +5 -7
  5. data/lib/deprec/cap.rb +51 -0
  6. data/lib/deprec/{callbacks → cap/callbacks}/asset_pipeline.rb +0 -0
  7. data/lib/deprec/{recipes → cap/recipes}/aoe.rb +0 -0
  8. data/lib/deprec/{recipes → cap/recipes}/apache.rb +0 -0
  9. data/lib/deprec/{recipes → cap/recipes}/bash.rb +0 -0
  10. data/lib/deprec/{recipes → cap/recipes}/canonical.rb +0 -0
  11. data/lib/deprec/{recipes → cap/recipes}/collectd.rb +0 -0
  12. data/lib/deprec/{recipes → cap/recipes}/deprec.rb +1 -2
  13. data/lib/deprec/{recipes → cap/recipes}/deprecated.rb +0 -0
  14. data/lib/deprec/{recipes → cap/recipes}/ec2.rb +0 -0
  15. data/lib/deprec/{recipes → cap/recipes}/example.rb +0 -0
  16. data/lib/deprec/{recipes → cap/recipes}/git.rb +0 -0
  17. data/lib/deprec/{recipes → cap/recipes}/haproxy.rb +0 -0
  18. data/lib/deprec/{recipes → cap/recipes}/heartbeat.rb +0 -0
  19. data/lib/deprec/{recipes → cap/recipes}/logrotate.rb +0 -0
  20. data/lib/deprec/{recipes → cap/recipes}/lvm.rb +0 -0
  21. data/lib/deprec/{recipes → cap/recipes}/mongrel.rb +0 -0
  22. data/lib/deprec/{recipes → cap/recipes}/monit.rb +0 -0
  23. data/lib/deprec/{recipes → cap/recipes}/mri.rb +0 -0
  24. data/lib/deprec/{recipes → cap/recipes}/mysql.rb +0 -0
  25. data/lib/deprec/{recipes → cap/recipes}/nagios.rb +0 -0
  26. data/lib/deprec/{recipes → cap/recipes}/nagios3.rb +0 -0
  27. data/lib/deprec/{recipes → cap/recipes}/network.rb +0 -0
  28. data/lib/deprec/{recipes → cap/recipes}/nginx.rb +0 -0
  29. data/lib/deprec/{recipes → cap/recipes}/nrpe.rb +0 -0
  30. data/lib/deprec/{recipes → cap/recipes}/ntp.rb +0 -0
  31. data/lib/deprec/{recipes → cap/recipes}/passenger.rb +0 -0
  32. data/lib/deprec/{recipes → cap/recipes}/php.rb +0 -0
  33. data/lib/deprec/{recipes → cap/recipes}/postfix.rb +0 -0
  34. data/lib/deprec/{recipes → cap/recipes}/postgresql.rb +0 -0
  35. data/lib/deprec/{recipes → cap/recipes}/rack.rb +0 -0
  36. data/lib/deprec/{recipes → cap/recipes}/rails.rb +4 -4
  37. data/lib/deprec/{recipes → cap/recipes}/ree.rb +0 -0
  38. data/lib/deprec/{recipes → cap/recipes}/rubygems.rb +0 -0
  39. data/lib/deprec/{recipes → cap/recipes}/sqlite.rb +0 -0
  40. data/lib/deprec/{recipes → cap/recipes}/ssh.rb +0 -0
  41. data/lib/deprec/{recipes → cap/recipes}/ssl.rb +0 -0
  42. data/lib/deprec/{recipes → cap/recipes}/stunnel.rb +0 -0
  43. data/lib/deprec/{recipes → cap/recipes}/syslog.rb +0 -0
  44. data/lib/deprec/{recipes → cap/recipes}/syslog_ng.rb +0 -0
  45. data/lib/deprec/{recipes → cap/recipes}/ubuntu.rb +0 -0
  46. data/lib/deprec/{recipes → cap/recipes}/users.rb +0 -0
  47. data/lib/deprec/{recipes → cap/recipes}/utils.rb +0 -0
  48. data/lib/deprec/{recipes → cap/recipes}/xen.rb +0 -0
  49. data/lib/deprec/{recipes → cap/recipes}/xentools.rb +0 -0
  50. data/lib/deprec/{templates → cap/templates}/aoe/aoe-init +0 -0
  51. data/lib/deprec/{templates → cap/templates}/aoe/fence_aoemask +0 -0
  52. data/lib/deprec/{templates → cap/templates}/apache/CHANGES.txt +0 -0
  53. data/lib/deprec/{templates → cap/templates}/apache/apache2.conf.erb +0 -0
  54. data/lib/deprec/{templates → cap/templates}/apache/default.erb +0 -0
  55. data/lib/deprec/{templates → cap/templates}/apache/namevirtualhosts.conf +0 -0
  56. data/lib/deprec/{templates → cap/templates}/apache/ports.conf.erb +0 -0
  57. data/lib/deprec/{templates → cap/templates}/apache/status.conf.erb +0 -0
  58. data/lib/deprec/{templates → cap/templates}/apache/vhost.erb +0 -0
  59. data/lib/deprec/{templates → cap/templates}/bash/bash_global +0 -0
  60. data/lib/deprec/{templates → cap/templates}/collectd/collectd-init.d +0 -0
  61. data/lib/deprec/{templates → cap/templates}/collectd/collectd.conf.erb +0 -0
  62. data/lib/deprec/{templates → cap/templates}/deprec/caprc.erb +0 -0
  63. data/lib/deprec/{templates → cap/templates}/haproxy/haproxy-init.d +0 -0
  64. data/lib/deprec/{templates → cap/templates}/haproxy/haproxy.cfg.erb +0 -0
  65. data/lib/deprec/{templates → cap/templates}/heartbeat/authkeys.erb +0 -0
  66. data/lib/deprec/{templates → cap/templates}/heartbeat/ha.cf.erb +0 -0
  67. data/lib/deprec/{templates → cap/templates}/heartbeat/haresources.erb +0 -0
  68. data/lib/deprec/{templates → cap/templates}/logrotate/logrotate.conf.erb +0 -0
  69. data/lib/deprec/{templates → cap/templates}/mongrel/apache_vhost.conf.erb +0 -0
  70. data/lib/deprec/{templates → cap/templates}/mongrel/logrotate.conf.erb +0 -0
  71. data/lib/deprec/{templates → cap/templates}/mongrel/mongrel_cluster-init-script +0 -0
  72. data/lib/deprec/{templates → cap/templates}/mongrel/mongrel_cluster.yml.erb +0 -0
  73. data/lib/deprec/{templates → cap/templates}/mongrel/monit.conf.erb +0 -0
  74. data/lib/deprec/{templates → cap/templates}/mongrel/nginx_vhost.conf.erb +0 -0
  75. data/lib/deprec/{templates → cap/templates}/monit/monit-init-script +0 -0
  76. data/lib/deprec/{templates → cap/templates}/monit/monitrc.erb +0 -0
  77. data/lib/deprec/{templates → cap/templates}/monit/nothing.monitrc +0 -0
  78. data/lib/deprec/{templates → cap/templates}/mysql/create_databases.sql +0 -0
  79. data/lib/deprec/{templates → cap/templates}/mysql/database.yml.prod +0 -0
  80. data/lib/deprec/{templates → cap/templates}/mysql/database.yml.stage +0 -0
  81. data/lib/deprec/{templates → cap/templates}/mysql/my.cnf.erb +0 -0
  82. data/lib/deprec/{templates → cap/templates}/mysql/sphinx.conf.prod +0 -0
  83. data/lib/deprec/{templates → cap/templates}/mysql/sphinx.conf.stage +0 -0
  84. data/lib/deprec/{templates → cap/templates}/nagios.old/README +0 -0
  85. data/lib/deprec/{templates → cap/templates}/nagios.old/apache_vhost.erb +0 -0
  86. data/lib/deprec/{templates → cap/templates}/nagios.old/cgi.cfg.erb +0 -0
  87. data/lib/deprec/{templates → cap/templates}/nagios.old/check_linux_free_memory.pl +0 -0
  88. data/lib/deprec/{templates → cap/templates}/nagios.old/check_mongrel_cluster.rb +0 -0
  89. data/lib/deprec/{templates → cap/templates}/nagios.old/htpasswd.users +0 -0
  90. data/lib/deprec/{templates → cap/templates}/nagios.old/mrtg.cfg +0 -0
  91. data/lib/deprec/{templates → cap/templates}/nagios.old/nagios.cfg.erb +0 -0
  92. data/lib/deprec/{templates → cap/templates}/nagios.old/nrpe.cfg.erb +0 -0
  93. data/lib/deprec/{templates → cap/templates}/nagios.old/nrpe.xinetd.erb +0 -0
  94. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/commands.cfg.erb +0 -0
  95. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/contacts.cfg.erb +0 -0
  96. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/hosts.cfg.erb +0 -0
  97. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/localhost.cfg.erb +0 -0
  98. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/services.cfg.erb +0 -0
  99. data/lib/deprec/{templates → cap/templates}/nagios.old/objects/timeperiods.cfg.erb +0 -0
  100. data/lib/deprec/{templates → cap/templates}/nagios.old/resource.cfg.erb +0 -0
  101. data/lib/deprec/{templates → cap/templates}/nagios/apache2.conf +0 -0
  102. data/lib/deprec/{templates → cap/templates}/nagios/cgi.cfg +0 -0
  103. data/lib/deprec/{templates → cap/templates}/nagios/check_linux_free_memory.pl +0 -0
  104. data/lib/deprec/{templates → cap/templates}/nagios/commands.cfg +0 -0
  105. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/contacts_nagios2.cfg +0 -0
  106. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/extinfo_nagios2.cfg +0 -0
  107. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/generic-host_nagios2.cfg +0 -0
  108. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/generic-service_nagios2.cfg +0 -0
  109. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/hostgroups_nagios2.cfg +0 -0
  110. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/hosts/localhost_nagios2.cfg +0 -0
  111. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/services_nagios2.cfg +0 -0
  112. data/lib/deprec/{templates → cap/templates}/nagios/conf.d/timeperiods_nagios2.cfg +0 -0
  113. data/lib/deprec/{templates → cap/templates}/nagios/host_template.erb +0 -0
  114. data/lib/deprec/{templates → cap/templates}/nagios/htpasswd.users +0 -0
  115. data/lib/deprec/{templates → cap/templates}/nagios/nagios.cfg +0 -0
  116. data/lib/deprec/{templates → cap/templates}/nagios/nrpe.cfg +0 -0
  117. data/lib/deprec/{templates → cap/templates}/nagios/resource.cfg +0 -0
  118. data/lib/deprec/{templates → cap/templates}/network/hostname.erb +0 -0
  119. data/lib/deprec/{templates → cap/templates}/network/hosts.erb +0 -0
  120. data/lib/deprec/{templates → cap/templates}/network/interfaces.erb +0 -0
  121. data/lib/deprec/{templates → cap/templates}/network/resolv.conf.erb +0 -0
  122. data/lib/deprec/{templates → cap/templates}/nginx/logrotate.conf.erb +0 -0
  123. data/lib/deprec/{templates → cap/templates}/nginx/mime.types.erb +0 -0
  124. data/lib/deprec/{templates → cap/templates}/nginx/nginx-init-script +0 -0
  125. data/lib/deprec/{templates → cap/templates}/nginx/nginx.conf.erb +0 -0
  126. data/lib/deprec/{templates → cap/templates}/nginx/nginx.logrotate.d +0 -0
  127. data/lib/deprec/{templates → cap/templates}/nginx/nothing.conf +0 -0
  128. data/lib/deprec/{templates → cap/templates}/nginx/rails_nginx_vhost.conf.erb +0 -0
  129. data/lib/deprec/{templates → cap/templates}/ntp/ntp.conf.erb +0 -0
  130. data/lib/deprec/{templates → cap/templates}/passenger/apache_vhost.erb +0 -0
  131. data/lib/deprec/{templates → cap/templates}/passenger/logrotate.conf.erb +0 -0
  132. data/lib/deprec/{templates → cap/templates}/passenger/passenger.conf.erb +0 -0
  133. data/lib/deprec/{templates → cap/templates}/passenger/passenger.load.erb +0 -0
  134. data/lib/deprec/{templates → cap/templates}/postfix/aliases.erb +0 -0
  135. data/lib/deprec/{templates → cap/templates}/postfix/dynamicmaps.cf.erb +0 -0
  136. data/lib/deprec/{templates → cap/templates}/postfix/main.cf.erb +0 -0
  137. data/lib/deprec/{templates → cap/templates}/postfix/master.cf.erb +0 -0
  138. data/lib/deprec/{templates → cap/templates}/ssh/ssh_config.erb +0 -0
  139. data/lib/deprec/{templates → cap/templates}/ssh/sshd_config.erb +0 -0
  140. data/lib/deprec/{templates → cap/templates}/ssl/make-ssl-cert +0 -0
  141. data/lib/deprec/{templates → cap/templates}/ssl/ssl-cert-snakeoil.key +0 -0
  142. data/lib/deprec/{templates → cap/templates}/ssl/ssl-cert-snakeoil.pem +0 -0
  143. data/lib/deprec/{templates → cap/templates}/stunnel/stunnel.conf-client +0 -0
  144. data/lib/deprec/{templates → cap/templates}/stunnel/stunnel.conf-orig +0 -0
  145. data/lib/deprec/{templates → cap/templates}/stunnel/stunnel.conf-server +0 -0
  146. data/lib/deprec/{templates → cap/templates}/stunnel/stunnel4 +0 -0
  147. data/lib/deprec/{templates → cap/templates}/stunnel/syslog-server.pem +0 -0
  148. data/lib/deprec/{templates → cap/templates}/syslog/syslog.conf.erb +0 -0
  149. data/lib/deprec/{templates → cap/templates}/syslog/syslogd.erb +0 -0
  150. data/lib/deprec/{templates → cap/templates}/syslog_ng/apache_syslog +0 -0
  151. data/lib/deprec/{templates → cap/templates}/syslog_ng/syslog-ng.conf-client +0 -0
  152. data/lib/deprec/{templates → cap/templates}/syslog_ng/syslog-ng.conf-orig +0 -0
  153. data/lib/deprec/{templates → cap/templates}/syslog_ng/syslog-ng.conf-server +0 -0
  154. data/lib/deprec/{templates → cap/templates}/xen/network-bridge-wrapper +0 -0
  155. data/lib/deprec/{templates → cap/templates}/xen/xend-config.sxp.erb +0 -0
  156. data/lib/deprec/{templates → cap/templates}/xen/xend-init.erb +0 -0
  157. data/lib/deprec/{templates → cap/templates}/xen/xendomains.erb +0 -0
  158. data/lib/deprec/{templates → cap/templates}/xentools/15-disable-hwclock +0 -0
  159. data/lib/deprec/{templates → cap/templates}/xentools/40-setup-networking +0 -0
  160. data/lib/deprec/{templates → cap/templates}/xentools/xen-tools.conf.erb +0 -0
  161. data/lib/deprec/{templates → cap/templates}/xentools/xm.tmpl.erb +0 -0
  162. data/lib/deprec_minus_rails.rb +22 -12
  163. metadata +178 -212
  164. data/lib/deprec/TODO.txt +0 -6
  165. data/lib/deprec/capistrano_extensions.rb +0 -418
  166. data/lib/deprec/recipes.rb +0 -7
  167. data/lib/deprec/recipes/ar_sendmail.rb +0 -67
  168. data/lib/deprec/recipes/chef.rb +0 -68
  169. data/lib/deprec/recipes/couchdb.rb +0 -107
  170. data/lib/deprec/recipes/ddclient.rb +0 -51
  171. data/lib/deprec/recipes/gitosis.rb +0 -55
  172. data/lib/deprec/recipes/integrity.rb +0 -108
  173. data/lib/deprec/recipes/memcache.rb +0 -49
  174. data/lib/deprec/recipes/sphinx.rb +0 -86
  175. data/lib/deprec/recipes/starling.rb +0 -119
  176. data/lib/deprec/recipes/svn.rb +0 -12
  177. data/lib/deprec/recipes/trac.rb +0 -277
  178. data/lib/deprec/recipes/vmware_tools.rb +0 -15
  179. data/lib/deprec/recipes/vnstat.rb +0 -85
  180. data/lib/deprec/recipes/wpmu.rb +0 -103
  181. data/lib/deprec/recipes_minus_rails.rb +0 -69
  182. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +0 -9
  183. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +0 -5
  184. data/lib/deprec/templates/chef/chef.json.erb +0 -1
  185. data/lib/deprec/templates/chef/solo.rb +0 -2
  186. data/lib/deprec/templates/ddclient/ddclient.conf.erb +0 -11
  187. data/lib/deprec/templates/ddclient/ddclient.erb +0 -15
  188. data/lib/deprec/templates/integrity/apache_vhost.erb +0 -4
  189. data/lib/deprec/templates/integrity/config.ru.erb +0 -21
  190. data/lib/deprec/templates/integrity/config.yml.erb +0 -43
  191. data/lib/deprec/templates/sphinx/monit.conf.erb +0 -5
  192. data/lib/deprec/templates/starling/monit.conf.erb +0 -14
  193. data/lib/deprec/templates/starling/starling-init-script.erb +0 -71
  194. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +0 -43
  195. data/lib/deprec/templates/trac/apache_vhost.conf.erb +0 -24
  196. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +0 -26
  197. data/lib/deprec/templates/trac/trac.ini.erb +0 -169
  198. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  199. data/lib/deprec/templates/trac/tracd-init.erb +0 -43
  200. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  201. data/lib/deprec/templates/vnstat/config.php +0 -57
  202. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +0 -31
  203. data/lib/deprec/templates/wordpress/wp-config.php.erb +0 -31
  204. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +0 -13
  205. data/lib/vmbuilder_plugins/all.rb +0 -20
  206. data/lib/vmbuilder_plugins/apt.rb +0 -93
  207. data/lib/vmbuilder_plugins/emerge.rb +0 -76
  208. data/lib/vmbuilder_plugins/gem.rb +0 -90
  209. data/lib/vmbuilder_plugins/std.rb +0 -203
@@ -1,76 +0,0 @@
1
- # =emerge.rb: Gentoo 'emerge' Installer library
2
- # Capistrano task library to install and manage portage packages
3
- #
4
- # Copyright (c) 2007 monki(Wesley Beary)
5
- #
6
- # inspiration: vmbuilder by Neil Wilson, Aldur Systems Ltd
7
- #
8
- # Licenced under the GNU Public License v2. No warranty is provided.
9
-
10
- require 'capistrano'
11
-
12
- # =Purpose
13
- # emerge is a Capistrano plugin module providing a set of methods
14
- # that invoke the portage package manage (as used in Gentoo)
15
- #
16
- # Installs within Capistrano as the plugin _emerge_.
17
- #
18
- # =Usage
19
- #
20
- # require 'marshall/plugins/emerge'
21
- #
22
- # Prefix all calls to the library with <tt>emerge.</tt>
23
- #
24
- module Emerge
25
- # Default emerge command - reduce interactivity to the minimum
26
- EMERGE="emerge -q"
27
-
28
- # Emerge a new package or packages
29
- def install(packages, options={})
30
- cmd = <<-CMD
31
- sh -c "#{EMERGE} #{packages.join(" ")}"
32
- CMD
33
- sudo(cmd, options)
34
- end
35
-
36
- # Run clean old/unused packages
37
- def clean(options={})
38
- cmd = <<-CMD
39
- sh -c "#{EMERGE} -clean"
40
- CMD
41
- sudo(cmd, options)
42
- end
43
-
44
- # Upgrade installed package list
45
- def upgrade(options={})
46
- cmd = <<-CMD
47
- sh -c "#{EMERGE} --sync"
48
- CMD
49
- sudo(cmd, options)
50
- end
51
-
52
- # Update portage
53
- def update_system(options={})
54
- cmd = <<-CMD
55
- sh -c "#{EMERGE} portage"
56
- CMD
57
- sudo(cmd, options)
58
- end
59
-
60
- # Update all installed packages
61
- def update(options={})
62
- cmd = <<-CMD
63
- sh -c "#{EMERGE} --update --deep --newuse world"
64
- CMD
65
- sudo(cmd, options)
66
- end
67
-
68
- # Boot script manipulation command
69
- def rc_update(packages, setting)
70
- packages.each do |service|
71
- sudo "rc_update add #{service} #{setting}"
72
- end
73
- end
74
- end
75
-
76
- Capistrano.plugin :emerge, Emerge
@@ -1,90 +0,0 @@
1
- # =gem.rb: Gem Installer library
2
- # Capistrano library to install and manage Ruby Gems.
3
- #
4
- # ----
5
- # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
6
- #
7
- # Licensed under the GNU Public License v2. No warranty is provided.
8
-
9
- require 'capistrano'
10
-
11
- # = Purpose
12
- # Gem is a Capistrano plugin module providing a set of methods
13
- # that invoke the *gem* package manager.
14
- #
15
- # Installs within Capistrano as the plugin _gem_.
16
- #
17
- # =Usage
18
- #
19
- # require 'vmbuilder_plugins/gem'
20
- #
21
- # Prefix all calls to the library with <tt>gem.</tt>
22
- #
23
- module Gem
24
-
25
- # Default install command
26
- #
27
- # * doesn't install documentation
28
- # * installs all required dependencies automatically.
29
- #
30
- GEM_INSTALL="gem install --no-rdoc --no-ri"
31
- GEM_UPDATE=GEM_INSTALL.sub("install", "update")
32
-
33
- # Upgrade the *gem* system to the latest version. Runs via *sudo*
34
- def update_system
35
- send(run_method, "#{GEM_UPDATE} --system")
36
- end
37
-
38
- # Updates all the installed gems to the latest version. Runs via *sudo*.
39
- # Don't use this command if any of the gems require a version selection.
40
- def upgrade
41
- send(run_method, GEM_UPDATE)
42
- end
43
-
44
- # Removes old versions of gems from installation area.
45
- def cleanup
46
- send(run_method, "gem cleanup")
47
- end
48
-
49
- # Installs the gems detailed in +packages+, selecting version +version+ if
50
- # specified.
51
- #
52
- # +packages+ can be a single string or an array of strings.
53
- #
54
- def install(packages, version=nil)
55
- send(run_method,"#{GEM_INSTALL} #{if version then '-v '+version.to_s end} #{Array(packages).join(' ')}")
56
- end
57
-
58
- # Auto selects a gem from a list and installs it.
59
- #
60
- # *gem* has no mechanism on the command line of disambiguating builds for
61
- # different platforms, and instead asks the user. This method has the necessary
62
- # conversation to select the +version+ relevant to +platform+ (or the one nearest
63
- # the top of the list if you don't specify +version+).
64
- def select(package, version=nil, platform='ruby')
65
- selections={}
66
- cmd="#{GEM_INSTALL} #{if version then '-v '+version.to_s end} #{package}"
67
- send run_method, cmd do |channel, stream, data|
68
- data.each_line do | line |
69
- case line
70
- when /\s(\d+).*\(#{platform}\)/
71
- if selections[channel[:host]].nil?
72
- selections[channel[:host]]=$1.dup+"\n"
73
- logger.info "Selecting #$&", "#{stream} :: #{channel[:host]}"
74
- end
75
- when /\s\d+\./
76
- # Discard other selections from data stream
77
- when /^>/
78
- channel.send_data selections[channel[:host]]
79
- logger.debug line, "#{stream} :: #{channel[:host]}"
80
- else
81
- logger.info line, "#{stream} :: #{channel[:host]}"
82
- end
83
- end
84
- end
85
- end
86
-
87
- end
88
-
89
- Capistrano.plugin :gem2, Gem
90
- # vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
@@ -1,203 +0,0 @@
1
- # =std.rb: Capistrano Standard Methods
2
- # Standard library of procedures and functions that you can use with Capistrano.
3
- #
4
- # ----
5
- # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
6
- #
7
- # Licensed under the GNU Public License v2. No warranty is provided.
8
-
9
- require 'capistrano'
10
-
11
- # = Purpose
12
- # Std is a Capistrano plugin that provides a set of standard methods refactored
13
- # out of several Capistrano task libraries.
14
- #
15
- # Installs within Capistrano as the plugin _std_
16
- #
17
- # = Usage
18
- #
19
- # require 'vmbuilder_plugins/std'
20
- #
21
- # Prefix all calls to the library with <tt>std.</tt>
22
- module Std
23
-
24
- begin
25
- # Use the Mmap class if it is available
26
- # http://moulon.inra.fr/ruby/mmap.html
27
- require 'mmap'
28
- MMAP=true #:nodoc:
29
- rescue LoadError
30
- # no MMAP class, use normal reads instead
31
- MMAP=false #:nodoc:
32
- end
33
-
34
- # Copies the files specified by +file_pattern+ to +destination+
35
- #
36
- # Error checking is minimal - a pattern onto a single file will result in +destination+
37
- # containing the data from the last file only.
38
- #
39
- # Installs via *sudo*, +options+ are as for *put*.
40
- def fput(file_pattern, destination, options={})
41
- logger.info file_pattern
42
- Dir.glob(file_pattern) do |fname|
43
- if File.readable?(fname) then
44
- if MMAP
45
- logger.debug "Using Memory Mapped File Upload"
46
- fdata=Mmap.new(fname,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
47
- else
48
- fdata=File.open(fname).read
49
- end
50
- su_put(fdata, destination, File.join('/tmp',File.basename(fname)), options)
51
- else
52
- logger.error "Unable to read file #{fname}"
53
- end
54
- end
55
- end
56
-
57
- # Upload +data+ to +temporary_area+ before installing it in
58
- # +destination+ using sudo.
59
- #
60
- # +options+ are as for *put*
61
- #
62
- def su_put(data, destination, temporary_area='/tmp', options={})
63
- temporary_area = File.join(temporary_area,"#{File.basename(destination)}-$CAPISTRANO:HOST$")
64
- put(data, temporary_area, options)
65
- send run_method, <<-CMD
66
- sh -c "install -m#{sprintf("%3o",options[:mode]||0755)} #{temporary_area} #{destination} &&
67
- rm -f #{temporary_area}"
68
- CMD
69
- end
70
-
71
- # Copies the +file_pattern+, which is assumed to be a tar
72
- # file of some description (gzipped or plain), and unpacks it into
73
- # +destination+.
74
- def unzip(file_pattern, destination, options={})
75
- Dir.glob(file_pattern) do |fname|
76
- if File.readable?(fname) then
77
- target="/tmp/#{File.basename(fname)}"
78
- if MMAP
79
- logger.debug "Using Memory Mapped File Upload"
80
- fdata=Mmap.new(fname,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
81
- else
82
- fdata=File.open(fname).read
83
- end
84
- put(fdata, target, options)
85
- send run_method, <<-CMD
86
- sh -c "cd #{destination} &&
87
- zcat -f #{target} | tar xvf - &&
88
- rm -f #{target}"
89
- CMD
90
- end
91
- end
92
- end
93
-
94
- # Wrap this around your task calls to catch the no servers error and
95
- # ignore it
96
- #
97
- # std.ignore_no_servers_error do
98
- # activate_mysql
99
- # end
100
- #
101
- def ignore_no_servers_error (&block)
102
- begin
103
- yield
104
- rescue RuntimeError => failure
105
- if failure.message =~ /no servers matched/
106
- logger.debug "Ignoring 'no servers matched' error in task #{current_task.name}"
107
- else
108
- raise
109
- end
110
- end
111
- end
112
-
113
- # Wrap this around your task to force a connection as root.
114
- # Flushes the session cache before and after the connection.
115
- #
116
- # std.connect_as_root do
117
- # install_sudo
118
- # end
119
- #
120
- def connect_as_root (&block)
121
- begin
122
- tempuser = user
123
- set :user, "root"
124
- actor.sessions.delete_if { true }
125
- yield tempuser
126
- ensure
127
- set :user, tempuser if tempuser
128
- actor.sessions.delete_if { true }
129
- end
130
- end
131
-
132
- #Returns a random string of alphanumeric characters of size +size+
133
- #Useful for passwords, usernames and the like.
134
- def random_string(size=10)
135
- s = ""
136
- size.times { s << (i = rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
137
- s
138
- end
139
-
140
-
141
- # Return a relative path from the destination directory +from_str+
142
- # to the target file/directory +to_str+. Used to create relative
143
- # symbolic link paths.
144
- def relative_path (from_str, to_str)
145
- require 'pathname'
146
- Pathname.new(to_str).relative_path_from(Pathname.new(from_str)).to_s
147
- end
148
-
149
- # Run a ruby command file on the servers
150
- #
151
- def ruby(cmd, options={}, &block)
152
- temp_name = random_string + ".rb"
153
- begin
154
- put(cmd, temp_name, :mode => 0700)
155
- send(run_method, "ruby #{temp_name}", options, &block)
156
- ensure
157
- delete temp_name
158
- end
159
- end
160
-
161
- # Run a patchfile on the servers
162
- # Ignores reverses and rejects.
163
- #
164
- def patch(patchfile, level = '0', where = '/')
165
- temp_name = random_string
166
- begin
167
- fput(patchfile, temp_name, :mode => 0600)
168
- send(run_method, %{
169
- patch -p#{level} -tNd #{where} -r /dev/null < #{temp_name} || true
170
- })
171
- ensure
172
- delete temp_name
173
- end
174
- end
175
-
176
- # Deletes the given file(s) from all servers targetted by the current
177
- # task, but runs the +delete+ command according to the current setting
178
- # of <tt>:use_sudo</tt>.
179
- #
180
- # If <tt>:recursive => true</tt> is specified, it may be used to remove
181
- # directories.
182
- def su_delete(path, options={})
183
- cmd = "rm -%sf #{path}" % (options[:recursive] ? "r" : "")
184
- send(run_method, cmd, options)
185
- end
186
-
187
- # Render a template file and upload it to the servers
188
- #
189
- def put_template(template, destination, options={})
190
- if MMAP
191
- logger.debug "Using Memory Mapped File Upload"
192
- fdata=Mmap.new(template,"r", Mmap::MAP_SHARED, :advice => Mmap::MADV_SEQUENTIAL)
193
- else
194
- fdata=File.read(template)
195
- end
196
- put(render(:template => fdata), destination, options)
197
- end
198
-
199
- end
200
-
201
- Capistrano.plugin :std, Std
202
- #
203
- # vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby: