deprec 1.9.3 → 2.0.0

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 (188) hide show
  1. data/CHANGELOG +280 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +152 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +128 -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/{README.quickstart → deprec-1.x/deprec-1.x.quickstart} +4 -1
  12. data/docs/{building_edge_capistrano.txt → deprec-1.x/notes.txt} +6 -3
  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 +8 -1
  19. data/lib/deprec/capistrano_extensions.rb +442 -0
  20. data/lib/deprec/recipes.rb +50 -233
  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 +197 -0
  24. data/lib/deprec/recipes/apt_mirror.rb +99 -0
  25. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/db/mysql.rb +144 -0
  28. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  29. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  30. data/lib/deprec/recipes/ddclient.rb +51 -0
  31. data/lib/deprec/recipes/deprec.rb +199 -0
  32. data/lib/deprec/recipes/deprecated.rb +71 -0
  33. data/lib/deprec/recipes/example.rb +115 -0
  34. data/lib/deprec/recipes/git.rb +97 -0
  35. data/lib/deprec/recipes/gitosis.rb +48 -0
  36. data/lib/deprec/recipes/heartbeat.rb +138 -0
  37. data/lib/deprec/recipes/logrotate.rb +54 -0
  38. data/lib/deprec/recipes/lvm.rb +20 -0
  39. data/lib/deprec/recipes/memcache.rb +6 -2
  40. data/lib/deprec/recipes/monit.rb +143 -0
  41. data/lib/deprec/recipes/nagios.rb +305 -0
  42. data/lib/deprec/recipes/network.rb +93 -0
  43. data/lib/deprec/recipes/ntp.rb +103 -0
  44. data/lib/deprec/recipes/php.rb +58 -0
  45. data/lib/deprec/recipes/postfix.rb +115 -0
  46. data/lib/deprec/recipes/rails.rb +300 -55
  47. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  48. data/lib/deprec/recipes/ruby/ree.rb +41 -0
  49. data/lib/deprec/recipes/sphinx.rb +86 -0
  50. data/lib/deprec/recipes/ssh.rb +85 -18
  51. data/lib/deprec/recipes/ssl.rb +55 -0
  52. data/lib/deprec/recipes/starling.rb +119 -0
  53. data/lib/deprec/recipes/svn.rb +163 -183
  54. data/lib/deprec/recipes/trac.rb +239 -62
  55. data/lib/deprec/recipes/ubuntu.rb +18 -100
  56. data/lib/deprec/recipes/users.rb +90 -0
  57. data/lib/deprec/recipes/utils.rb +58 -0
  58. data/lib/deprec/recipes/vnstat.rb +85 -0
  59. data/lib/deprec/recipes/web/apache.rb +119 -0
  60. data/lib/deprec/recipes/web/nginx.rb +172 -0
  61. data/lib/deprec/recipes/wordpress.rb +96 -0
  62. data/lib/deprec/recipes/wpmu.rb +103 -0
  63. data/lib/deprec/recipes/xen.rb +267 -0
  64. data/lib/deprec/recipes/xentools.rb +75 -0
  65. data/lib/deprec/templates/aoe/aoe-init +55 -0
  66. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  67. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  68. data/lib/deprec/templates/apt/sources.list +18 -0
  69. data/lib/deprec/templates/apt_mirror/apt-mirror-cron +4 -0
  70. data/lib/deprec/templates/apt_mirror/mirror.list +33 -0
  71. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  72. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  73. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  74. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  75. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  76. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  77. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  78. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  79. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  80. data/lib/deprec/templates/mongrel/apache_vhost.erb +148 -0
  81. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  82. data/lib/deprec/{third_party/mongrel_cluster/resources/mongrel_cluster → templates/mongrel/mongrel_cluster-init-script} +19 -6
  83. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  84. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  85. data/lib/deprec/templates/mongrel/nginx_vhost.erb +41 -0
  86. data/lib/deprec/templates/monit/monit-init-script +104 -0
  87. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  88. data/lib/deprec/templates/monit/nothing +0 -0
  89. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  90. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  91. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  92. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  93. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  94. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  95. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  96. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  97. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  98. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  99. data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
  100. data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
  101. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  102. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  103. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  104. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  105. data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
  106. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  107. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  108. data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
  109. data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
  110. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  111. data/lib/deprec/templates/network/hostname.erb +1 -0
  112. data/lib/deprec/templates/network/hosts.erb +2 -0
  113. data/lib/deprec/templates/network/interfaces.erb +18 -0
  114. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  115. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  116. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  117. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  118. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  119. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  120. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  121. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  122. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  123. data/lib/deprec/templates/passenger/apache_vhost.erb +21 -0
  124. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  125. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  126. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  127. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  128. data/lib/deprec/templates/{postfix_main.conf → postfix/main.cf.erb} +6 -8
  129. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  130. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  131. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  132. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  133. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  134. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  135. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  136. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  137. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  138. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  139. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  140. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  141. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  142. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  143. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  144. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  145. data/lib/deprec/templates/vnstat/config.php +57 -0
  146. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  147. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  148. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  149. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  150. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  151. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  152. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  153. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  154. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  155. data/lib/deprec/templates/xentools/xen-tools.conf.erb +276 -0
  156. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  157. data/lib/deprec_cmd_completion.sh +26 -0
  158. data/lib/vmbuilder_plugins/all.rb +20 -0
  159. data/lib/vmbuilder_plugins/apt.rb +93 -0
  160. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  161. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/gem.rb +10 -17
  162. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/std.rb +69 -19
  163. metadata +204 -55
  164. data/bin/deprec +0 -35
  165. data/docs/README.slicehost +0 -14
  166. data/docs/README.svn_trac +0 -19
  167. data/lib/deprec/capistrano_extensions/actor_extensions.rb +0 -89
  168. data/lib/deprec/capistrano_extensions/cli_extensions.rb +0 -38
  169. data/lib/deprec/capistrano_extensions/deprec_extensions.rb +0 -137
  170. data/lib/deprec/generators/deprec/USAGE +0 -11
  171. data/lib/deprec/generators/deprec/deprec_generator.rb +0 -24
  172. data/lib/deprec/generators/deprec/templates/deploy.rb +0 -90
  173. data/lib/deprec/generators/loader.rb +0 -20
  174. data/lib/deprec/recipes/apache.rb +0 -91
  175. data/lib/deprec/recipes/cache_svn.rb +0 -74
  176. data/lib/deprec/recipes/vmware.rb +0 -114
  177. data/lib/deprec/templates/trac.ini.erb +0 -106
  178. data/lib/deprec/third_party/THIRD_PARTY_README +0 -12
  179. data/lib/deprec/third_party/mongrel_cluster/LICENSE +0 -506
  180. data/lib/deprec/third_party/mongrel_cluster/recipes.rb +0 -96
  181. data/lib/deprec/third_party/railsmachine/LICENSE +0 -506
  182. data/lib/deprec/third_party/railsmachine/recipes/apache.rb +0 -92
  183. data/lib/deprec/third_party/railsmachine/recipes/mysql.rb +0 -73
  184. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd-ssl.conf +0 -80
  185. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd.conf +0 -57
  186. data/lib/deprec/third_party/vmbuilder/plugins.rb +0 -8
  187. data/lib/deprec/third_party/vmbuilder/plugins/apt.rb +0 -144
  188. data/resources/capistrano_include_dotfiles.patch +0 -17
@@ -0,0 +1,26 @@
1
+ export CAP_TASKS=$( cap -T | grep '^cap' | cut -d' ' -f 2 )
2
+ _cap()
3
+ {
4
+ local cur tasks colonprefixes
5
+ COMPREPLY=()
6
+ cur="${COMP_WORDS[COMP_CWORD]}"
7
+
8
+ tasks=$CAP_TASKS
9
+ # uncomment this for dynamic task lists
10
+ # tasks=$( cap -T | cut -d' ' -f 2 | grep deprec)
11
+
12
+ # Work-around bash_completion issue where bash interprets a colon
13
+ # as a separator.
14
+ # Work-around borrowed from the darcs work-around for the same
15
+ # issue.
16
+ colonprefixes=${cur%"${cur##*:}"}
17
+ COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
18
+ local i=${#COMPREPLY[*]}
19
+ while [ $((--i)) -ge 0 ]; do
20
+ COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
21
+ done
22
+
23
+ return 0
24
+
25
+ }
26
+ complete -F _cap cap
@@ -0,0 +1,20 @@
1
+ # =all.rb: Load all the Capistrano Plugins in the directory.
2
+ #
3
+ # Require all other ruby files in the directory.
4
+ #
5
+ # ----
6
+ # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
7
+ #
8
+ # Licensed under the GNU Public License v2. No warranty is provided.
9
+ # ----
10
+ # = Usage
11
+ #
12
+ # require 'vmbuilder_plugins/all'
13
+
14
+ # Splitting and joining __FILE__ deals with the current directory case
15
+ # properly
16
+ Dir[File.join( File.dirname(__FILE__), '*.rb')].each do |plugin_name|
17
+ unless plugin_name == File.join(File.dirname(__FILE__), File.basename(__FILE__))
18
+ require plugin_name
19
+ end
20
+ end
@@ -0,0 +1,93 @@
1
+ # =apt.rb: Debian 'apt' Installer library
2
+ # Capistrano plugin module to install and manage apt packages
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
+ # Apt is a Capistrano plugin module providing a set of methods
13
+ # that invoke the *apt* package manager (as used in Debian and Ubuntu)
14
+ #
15
+ # Installs within Capistrano as the plugin _apt_.
16
+ #
17
+ # =Usage
18
+ #
19
+ # require 'vmbuilder_plugins/apt'
20
+ #
21
+ # Prefix all calls to the library with <tt>apt.</tt>
22
+ #
23
+ module Apt
24
+
25
+ # Default apt-get command - reduces any interactivity to the minimum.
26
+ APT_GET="DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"
27
+
28
+ # Run the apt install program across the package list in 'packages'.
29
+ # Select those packages referenced by <tt>:base</tt> and the +version+
30
+ # of the distribution you want to use.
31
+ def install(packages, version, options={})
32
+ update
33
+ special_options="--allow-unauthenticated" if version != :stable
34
+ send(run_method, %{
35
+ sh -c "#{APT_GET} -qyu --force-yes #{special_options.to_s} install #{package_list(packages, version)}"
36
+ }, options)
37
+ end
38
+
39
+ # Run an apt clean
40
+ def clean(options={})
41
+ send(run_method, %{sh -c "#{APT_GET} -qy clean"}, options)
42
+ end
43
+
44
+ # Run an apt autoclean
45
+ def autoclean(options={})
46
+ send(run_method, %{sh -c "#{APT_GET} -qy autoclean"}, options)
47
+ end
48
+
49
+ # Run an apt distribution upgrade
50
+ def dist_upgrade(options={})
51
+ update
52
+ send(run_method, %{sh -c "#{APT_GET} -qy dist-upgrade"}, options)
53
+ end
54
+
55
+ # Run an apt upgrade. Use dist_upgrade instead if you want to upgrade
56
+ # the critical base packages.
57
+ def upgrade(options={})
58
+ update
59
+ send(run_method, %{sh -c "#{APT_GET} -qy upgrade"}, options)
60
+ end
61
+
62
+ # Run an apt update.
63
+ def update(options={})
64
+ send(run_method, %{sh -c "#{APT_GET} -qy update"}, options)
65
+ end
66
+
67
+ # RPM package install via alien
68
+ def rpm_install(packages, options={})
69
+ install({:base => %w(wget alien) }, :base)
70
+ send(run_method, "wget -Ncq #{packages.join(' ')}", options)
71
+ files=packages.collect { |package| File.basename(package) }
72
+ send(run_method, "alien -i #{files.join(' ')}", options)
73
+ end
74
+
75
+ # Clear the source list and package cache
76
+ def clear_cache(options={})
77
+ clean
78
+ cmd="rm -f /var/cache/apt/*.bin /var/lib/apt/lists/*_* /var/lib/apt/lists/partial/*"
79
+ send(run_method, cmd, options)
80
+ end
81
+
82
+ private
83
+
84
+ # Provides a string containing all the package names in the base
85
+ #list plus those in +version+.
86
+ def package_list(packages, version)
87
+ packages[:base].to_a.join(' ') + ' ' + packages[version].to_a.join(' ')
88
+ end
89
+
90
+ end
91
+
92
+ Capistrano.plugin :apt, Apt
93
+ # vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
@@ -0,0 +1,76 @@
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
@@ -2,7 +2,7 @@
2
2
  # Capistrano library to install and manage Ruby Gems.
3
3
  #
4
4
  # ----
5
- # Copyright (c) 2006 Neil Wilson, Aldur Systems Ltd
5
+ # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
6
6
  #
7
7
  # Licensed under the GNU Public License v2. No warranty is provided.
8
8
 
@@ -16,7 +16,7 @@ require 'capistrano'
16
16
  #
17
17
  # =Usage
18
18
  #
19
- # require 'vmbuilder/plugins/gem'
19
+ # require 'vmbuilder_plugins/gem'
20
20
  #
21
21
  # Prefix all calls to the library with <tt>gem.</tt>
22
22
  #
@@ -27,22 +27,23 @@ module Gem
27
27
  # * doesn't install documentation
28
28
  # * installs all required dependencies automatically.
29
29
  #
30
- GEM_INSTALL="gem install -y --no-rdoc --no-ri"
30
+ GEM_INSTALL="gem install --no-rdoc --no-ri"
31
+ GEM_UPDATE=GEM_INSTALL.sub("install", "update")
31
32
 
32
33
  # Upgrade the *gem* system to the latest version. Runs via *sudo*
33
34
  def update_system
34
- sudo "gem update --system"
35
+ send(run_method, "#{GEM_UPDATE} --system")
35
36
  end
36
37
 
37
38
  # Updates all the installed gems to the latest version. Runs via *sudo*.
38
39
  # Don't use this command if any of the gems require a version selection.
39
40
  def upgrade
40
- sudo "gem update --no-rdoc"
41
+ send(run_method, GEM_UPDATE)
41
42
  end
42
43
 
43
44
  # Removes old versions of gems from installation area.
44
45
  def cleanup
45
- sudo "gem cleanup"
46
+ send(run_method, "gem cleanup")
46
47
  end
47
48
 
48
49
  # Installs the gems detailed in +packages+, selecting version +version+ if
@@ -51,7 +52,7 @@ module Gem
51
52
  # +packages+ can be a single string or an array of strings.
52
53
  #
53
54
  def install(packages, version=nil)
54
- sudo "#{GEM_INSTALL} #{if version then '-v '+version.to_s end} #{packages.to_a.join(' ')}"
55
+ send(run_method,"#{GEM_INSTALL} #{if version then '-v '+version.to_s end} #{packages.to_a.join(' ')}")
55
56
  end
56
57
 
57
58
  # Auto selects a gem from a list and installs it.
@@ -63,7 +64,7 @@ module Gem
63
64
  def select(package, version=nil, platform='ruby')
64
65
  selections={}
65
66
  cmd="#{GEM_INSTALL} #{if version then '-v '+version.to_s end} #{package}"
66
- sudo cmd do |channel, stream, data|
67
+ send run_method, cmd do |channel, stream, data|
67
68
  data.each_line do | line |
68
69
  case line
69
70
  when /\s(\d+).*\(#{platform}\)/
@@ -83,15 +84,7 @@ module Gem
83
84
  end
84
85
  end
85
86
 
86
- #def gem_select(package, version, platform='ruby')
87
- # sudo <<-CMD
88
- # sh -c "#{GEM_INSTALL} -v #{version} #{package} </dev/null 2>&1|
89
- # sed -ne '/(#{platform})/s/ \\([0-9][0-9]*\\).*/\\1/p' |
90
- # #{GEM_INSTALL} -v #{version} #{package}"
91
- # CMD
92
- # end
93
-
94
87
  end
95
88
 
96
- Capistrano.plugin :gem, Gem
89
+ Capistrano.plugin :gem2, Gem
97
90
  # vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
@@ -2,7 +2,7 @@
2
2
  # Standard library of procedures and functions that you can use with Capistrano.
3
3
  #
4
4
  # ----
5
- # Copyright (c) 2006 Neil Wilson, Aldur Systems Ltd
5
+ # Copyright (c) 2007 Neil Wilson, Aldur Systems Ltd
6
6
  #
7
7
  # Licensed under the GNU Public License v2. No warranty is provided.
8
8
 
@@ -16,7 +16,7 @@ require 'capistrano'
16
16
  #
17
17
  # = Usage
18
18
  #
19
- # require 'vmbuilder/plugins/std'
19
+ # require 'vmbuilder_plugins/std'
20
20
  #
21
21
  # Prefix all calls to the library with <tt>std.</tt>
22
22
  module Std
@@ -40,7 +40,6 @@ module Std
40
40
  def fput(file_pattern, destination, options={})
41
41
  logger.info file_pattern
42
42
  Dir.glob(file_pattern) do |fname|
43
- logger.info fname
44
43
  if File.readable?(fname) then
45
44
  if MMAP
46
45
  logger.debug "Using Memory Mapped File Upload"
@@ -49,6 +48,8 @@ module Std
49
48
  fdata=File.open(fname).read
50
49
  end
51
50
  su_put(fdata, destination, File.join('/tmp',File.basename(fname)), options)
51
+ else
52
+ logger.error "Unable to read file #{fname}"
52
53
  end
53
54
  end
54
55
  end
@@ -59,9 +60,9 @@ module Std
59
60
  # +options+ are as for *put*
60
61
  #
61
62
  def su_put(data, destination, temporary_area='/tmp', options={})
62
- temporary_area = File.join(temporary_area,File.basename(destination))
63
+ temporary_area = File.join(temporary_area,"#{File.basename(destination)}-$CAPISTRANO:HOST$")
63
64
  put(data, temporary_area, options)
64
- sudo <<-CMD
65
+ send run_method, <<-CMD
65
66
  sh -c "install -m#{sprintf("%3o",options[:mode]||0755)} #{temporary_area} #{destination} &&
66
67
  rm -f #{temporary_area}"
67
68
  CMD
@@ -81,7 +82,7 @@ module Std
81
82
  fdata=File.open(fname).read
82
83
  end
83
84
  put(fdata, target, options)
84
- sudo <<-CMD
85
+ send run_method, <<-CMD
85
86
  sh -c "cd #{destination} &&
86
87
  zcat -f #{target} | tar xvf - &&
87
88
  rm -f #{target}"
@@ -90,19 +91,6 @@ module Std
90
91
  end
91
92
  end
92
93
 
93
- # Creates the directory +web_root_dir+ using sudo is +use_sudo+ is true.
94
- #
95
- # Makes the root directory manageble by the +control_group+ group and sets the
96
- # permissions so that the directory is writeable by +control_group+ and the group
97
- # remains _sticky_
98
- #
99
- def create_web_root(web_root_dir, control_group)
100
- send run_method, <<-CMD
101
- sh -c "[ -d #{web_root_dir} ] || mkdir -m2770 -p #{web_root_dir}"
102
- CMD
103
- send(run_method, "chgrp -c #{control_group} #{web_root_dir}")
104
- end
105
-
106
94
  # Wrap this around your task calls to catch the no servers error and
107
95
  # ignore it
108
96
  #
@@ -123,6 +111,7 @@ module Std
123
111
  end
124
112
 
125
113
  # Wrap this around your task to force a connection as root.
114
+ # Flushes the session cache before and after the connection.
126
115
  #
127
116
  # std.connect_as_root do
128
117
  # install_sudo
@@ -132,9 +121,11 @@ module Std
132
121
  begin
133
122
  tempuser = user
134
123
  set :user, "root"
124
+ actor.sessions.delete_if { true }
135
125
  yield tempuser
136
126
  ensure
137
127
  set :user, tempuser if tempuser
128
+ actor.sessions.delete_if { true }
138
129
  end
139
130
  end
140
131
 
@@ -146,6 +137,65 @@ module Std
146
137
  s
147
138
  end
148
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
+
149
199
  end
150
200
 
151
201
  Capistrano.plugin :std, Std