capitate 0.1.9 → 0.2.1

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 (78) hide show
  1. data/Capfile +3 -2
  2. data/History.txt +6 -0
  3. data/Manifest.txt +28 -11
  4. data/bin/capitate +13 -61
  5. data/config/hoe.rb +2 -2
  6. data/docs/nginx.README +12 -0
  7. data/docs/recipes/centos.txt +33 -0
  8. data/docs/recipes/deploy-pending.txt +25 -0
  9. data/docs/recipes/deploy-web.txt +33 -0
  10. data/docs/recipes/deploy.txt +159 -0
  11. data/docs/recipes/docs.txt +26 -0
  12. data/docs/recipes/imagemagick-centos.txt +20 -0
  13. data/docs/recipes/imagemagick.txt +8 -0
  14. data/docs/recipes/index.txt +26 -0
  15. data/docs/recipes/memcached-centos.txt +32 -0
  16. data/docs/recipes/memcached.txt +35 -0
  17. data/docs/recipes/mongrel_cluster-centos.txt +27 -0
  18. data/docs/recipes/mongrel_cluster.txt +40 -0
  19. data/docs/recipes/monit-centos.txt +32 -0
  20. data/docs/recipes/monit.txt +8 -0
  21. data/docs/recipes/mysql-centos.txt +22 -0
  22. data/docs/recipes/mysql.txt +58 -0
  23. data/docs/recipes/nginx-centos.txt +43 -0
  24. data/docs/recipes/nginx.txt +51 -0
  25. data/docs/recipes/rails.txt +58 -0
  26. data/docs/recipes/ruby-centos.txt +22 -0
  27. data/docs/recipes/ruby.txt +8 -0
  28. data/docs/recipes/sphinx-centos.txt +35 -0
  29. data/docs/recipes/sphinx.txt +89 -0
  30. data/lib/capitate/cap_ext/run_via.rb +14 -0
  31. data/lib/capitate/plugins/gem.rb +2 -3
  32. data/lib/capitate/plugins/prompt.rb +24 -0
  33. data/lib/capitate/plugins/script.rb +29 -15
  34. data/lib/capitate/plugins/templates.rb +45 -40
  35. data/lib/capitate/plugins/yum.rb +12 -22
  36. data/lib/capitate/task_node.rb +28 -9
  37. data/lib/capitate/version.rb +2 -2
  38. data/lib/capitate.rb +4 -5
  39. data/lib/deployment/deploy.rb +42 -0
  40. data/lib/deployment/install-centos-rubyweb.rb +131 -0
  41. data/lib/recipes/centos/centos.rb +30 -21
  42. data/lib/recipes/centos/imagemagick.rb +9 -8
  43. data/lib/recipes/centos/memcached.rb +11 -21
  44. data/lib/recipes/centos/mongrel_cluster.rb +7 -11
  45. data/lib/recipes/centos/monit.rb +13 -18
  46. data/lib/recipes/centos/mysql.rb +6 -9
  47. data/lib/recipes/centos/nginx.rb +17 -30
  48. data/lib/recipes/centos/ruby.rb +14 -19
  49. data/lib/recipes/centos/sphinx.rb +14 -28
  50. data/lib/recipes/docs.rb +22 -6
  51. data/lib/recipes/memcached.rb +14 -8
  52. data/lib/recipes/mongrel_cluster.rb +11 -14
  53. data/lib/recipes/mysql.rb +22 -40
  54. data/lib/recipes/nginx.rb +9 -4
  55. data/lib/recipes/rails.rb +53 -6
  56. data/lib/recipes/sphinx.rb +86 -17
  57. data/lib/templates/capistrano/Capfile +2 -6
  58. data/lib/templates/monit/cert.sh +1 -1
  59. data/lib/templates/mysql/install_db.sql.erb +2 -2
  60. data/lib/templates/sphinx/sphinx.conf.erb +28 -399
  61. data/lib/templates/sphinx/sphinx_app.initd.centos.erb +1 -1
  62. data/website/index.html +20 -34
  63. data/website/index.txt +12 -22
  64. data/website/stylesheets/screen.css +22 -11
  65. data/website/template.rhtml +7 -5
  66. data/website/template_recipe.rhtml +7 -3
  67. metadata +55 -15
  68. data/lib/capitate/plugins/package.rb +0 -30
  69. data/lib/capitate/plugins/profiles.rb +0 -33
  70. data/lib/capitate/plugins/wget.rb +0 -23
  71. data/lib/profiles/centos-sick.rb +0 -116
  72. data/lib/recipes/README +0 -5
  73. data/lib/recipes/centos/README +0 -3
  74. data/lib/recipes/gems.rb +0 -20
  75. data/lib/recipes/packages.rb +0 -39
  76. data/lib/recipes/recipes.rb +0 -30
  77. data/lib/templates/centos/setup_for_web.sh +0 -17
  78. data/lib/templates/centos/sudoers +0 -95
@@ -0,0 +1,40 @@
1
+ h1. mongrel_cluster
2
+
3
+ "home":../index.html > "recipes":index.html > mongrel_cluster
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "mongrel_cluster:centos":mongrel_cluster-centos.html (1)
9
+
10
+
11
+ h2. Tasks
12
+
13
+ * "mongrel_cluster:setup_monit":#mongrel_cluster:setup_monit
14
+
15
+
16
+ h2. Task documentation
17
+
18
+ h3(#mongrel_cluster:setup_monit). mongrel_cluster:setup_monit
19
+
20
+ Create monit configuration for mongrel cluster.
21
+
22
+ *mongrel_size*: Number of mongrels.
23
+
24
+ @set :mongrel_size, 3@
25
+
26
+ *mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000, then instances
27
+ will be at 9000, 9001, and 9002
28
+
29
+ @set :mongrel_port, 9000@
30
+
31
+ *mongrel_config_script*: Config script to load with mongrel. _Defaults to nil_
32
+
33
+ @set :mongrel_config_script, "config/mongrel_handler.rb"@
34
+
35
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
36
+
37
+ @set :monit_conf_dir, "/etc/monit"@
38
+
39
+
40
+
@@ -0,0 +1,32 @@
1
+ h1. monit:centos
2
+
3
+ "home":../index.html > "recipes":index.html > "monit":monit.html > centos
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "monit:centos:install":#monit:centos:install
9
+
10
+
11
+ h2. Task documentation
12
+
13
+ h3(#monit:centos:install). monit:centos:install
14
+
15
+ Install monit.
16
+
17
+ *monit_build_options*: Monit build options.
18
+
19
+ *monit_port*: Monit port. _Defaults to 2812_
20
+
21
+ @set :monit_port, 2812@
22
+
23
+ *monit_password*: Monit password. _Defaults to password prompt_
24
+
25
+ @set :monit_password, prompt.password('Monit admin password (to set): ')@
26
+
27
+ *monit_conf_dir*: Directory for monitrc files.
28
+
29
+ @set :monit_conf_dir, "/etc/monit"@
30
+
31
+
32
+
@@ -0,0 +1,8 @@
1
+ h1. monit
2
+
3
+ "home":../index.html > "recipes":index.html > monit
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "monit:centos":monit-centos.html (1)
@@ -0,0 +1,22 @@
1
+ h1. mysql:centos
2
+
3
+ "home":../index.html > "recipes":index.html > "mysql":mysql.html > centos
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "mysql:centos:install":#mysql:centos:install
9
+
10
+
11
+ h2. Task documentation
12
+
13
+ h3(#mysql:centos:install). mysql:centos:install
14
+
15
+ Install mysql.
16
+
17
+ *mysql_admin_password_set*: Mysql admin password (to set). _Defaults to password prompt._
18
+
19
+ <pre>set :mysql_admin_password_set, prompt.password('Mysql admin password (to set): ')</pre>
20
+
21
+
22
+
@@ -0,0 +1,58 @@
1
+ h1. mysql
2
+
3
+ "home":../index.html > "recipes":index.html > mysql
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "mysql:centos":mysql-centos.html (1)
9
+
10
+
11
+ h2. Tasks
12
+
13
+ * "mysql:install_monit":#mysql:install_monit
14
+ * "mysql:setup":#mysql:setup
15
+
16
+
17
+ h2. Task documentation
18
+
19
+ h3(#mysql:install_monit). mysql:install_monit
20
+
21
+ Install mysql monit hooks.
22
+
23
+ *db_port*: Mysql port. _Defaults to 3306_
24
+
25
+ *mysql_pid_path*: Path to mysql pid file. _Defaults to /var/run/mysqld/mysqld.pid_
26
+
27
+ @set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"@
28
+
29
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
30
+
31
+ @set :monit_conf_dir, "/etc/monit"@
32
+
33
+
34
+
35
+ h3(#mysql:setup). mysql:setup
36
+
37
+ Create database, database user, and set grant permissions.
38
+
39
+ *db_name*: Database name (application).
40
+
41
+ *db_user*: Database user (application).
42
+
43
+ *db_pass*: Database password (application).
44
+
45
+ *grant_locations*: Grant locations. _Defaults to localhost_
46
+
47
+ @set :grant_locations, [ "localhost", "192.168.1.111" ]@
48
+
49
+ *grant_priv_type*: Grant privilege types. _Defaults to ALL_
50
+
51
+ @set :grant_priv_type, "ALL"@
52
+
53
+ *mysql_admin_password*: Mysql admin password (to use to connect). Defaults to password prompt.
54
+
55
+ @set :mysql_admin_password, prompt.password('Mysql admin password: '))@
56
+
57
+
58
+
@@ -0,0 +1,43 @@
1
+ h1. nginx:centos
2
+
3
+ "home":../index.html > "recipes":index.html > "nginx":nginx.html > centos
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "nginx:centos:install":#nginx:centos:install
9
+ * "nginx:centos:restart":#nginx:centos:restart
10
+
11
+
12
+ h2. Task documentation
13
+
14
+ h3(#nginx:centos:install). nginx:centos:install
15
+
16
+ Install nginx, conf, initscript, nginx user and service.
17
+
18
+ *nginx_build_options*: Nginx build options.
19
+
20
+ *nginx_bin_path*: Nginx sbin path. _Defaults to /sbin/nginx_
21
+
22
+ @set :nginx_bin_path, "/sbin/nginx"@
23
+
24
+ *nginx_conf_path*: Path to nginx conf. _Defaults to /etc/nginx/nginx.conf_
25
+
26
+ @set :nginx_conf_path, "/etc/nginx/nginx.conf"@
27
+
28
+ *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_
29
+
30
+ @set :nginx_pid_path, "/var/run/nginx.pid"@
31
+
32
+ *nginx_prefix_path*: Nginx install prefix. _Defaults to /var/nginx_
33
+
34
+ @set :nginx_prefix_path, "/var/nginx"@
35
+
36
+
37
+
38
+ h3(#nginx:centos:restart). nginx:centos:restart
39
+
40
+ Restart nginx (service)
41
+
42
+
43
+
@@ -0,0 +1,51 @@
1
+ h1. nginx
2
+
3
+ "home":../index.html > "recipes":index.html > nginx
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "nginx:centos":nginx-centos.html (2)
9
+
10
+
11
+ h2. Tasks
12
+
13
+ * "nginx:install_monit":#nginx:install_monit
14
+ * "nginx:setup_mongrel":#nginx:setup_mongrel
15
+
16
+
17
+ h2. Task documentation
18
+
19
+ h3(#nginx:install_monit). nginx:install_monit
20
+
21
+ Install nginx monit hooks.
22
+
23
+ *nginx_pid_path*: Path to nginx pid file. _Defaults to /var/run/nginx.pid_
24
+
25
+ @set :nginx_pid_path, "/var/run/nginx.pid"@
26
+
27
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
28
+
29
+ @set :monit_conf_dir, "/etc/monit"@
30
+
31
+
32
+
33
+ h3(#nginx:setup_mongrel). nginx:setup_mongrel
34
+
35
+ Create and update the nginx vhost include.
36
+
37
+ mongrel_size: Number of mongrels.
38
+
39
+ set :mongrel_size, 3
40
+
41
+ mongrel_port: Starting port for mongrels.
42
+ If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002
43
+
44
+ set :mongrel_port, 9000
45
+
46
+ domain_name: Domain name for nginx virtual host, (without www prefix).
47
+
48
+ set :domain_name, "foo.com"
49
+
50
+
51
+
@@ -0,0 +1,58 @@
1
+ h1. rails
2
+
3
+ "home":../index.html > "recipes":index.html > rails
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "rails:console":#rails:console
9
+ * "rails:mate_logs":#rails:mate_logs
10
+ * "rails:setup":#rails:setup
11
+ * "rails:tail_logs":#rails:tail_logs
12
+ * "rails:update_code":#rails:update_code
13
+
14
+
15
+ h2. Task documentation
16
+
17
+ h3(#rails:console). rails:console
18
+
19
+ Remotely console. (http://errtheblog.com/posts/19-streaming-capistrano)
20
+
21
+
22
+
23
+ h3(#rails:mate_logs). rails:mate_logs
24
+
25
+ Check production log files in TextMate. (http://errtheblog.com/posts/19-streaming-capistrano)
26
+
27
+
28
+
29
+ h3(#rails:setup). rails:setup
30
+
31
+ Create database yaml in shared path.
32
+
33
+ *db_name*: Database name (rails).
34
+
35
+ @set :db_name, "app_db_name"@
36
+
37
+ *db_user*: Database user (rails).
38
+
39
+ @set :db_user, "app_db_user"@
40
+
41
+ *db_pass*: Database password (rails).
42
+
43
+ @set :db_pass, "the_password"@
44
+
45
+
46
+
47
+ h3(#rails:tail_logs). rails:tail_logs
48
+
49
+ Tail production log files. (http://errtheblog.com/posts/19-streaming-capistrano)
50
+
51
+
52
+
53
+ h3(#rails:update_code). rails:update_code
54
+
55
+ Make symlink for database yaml
56
+
57
+
58
+
@@ -0,0 +1,22 @@
1
+ h1. ruby:centos
2
+
3
+ "home":../index.html > "recipes":index.html > "ruby":ruby.html > centos
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "ruby:centos:install":#ruby:centos:install
9
+
10
+
11
+ h2. Task documentation
12
+
13
+ h3(#ruby:centos:install). ruby:centos:install
14
+
15
+ Install ruby and rubygems.
16
+
17
+ *ruby_build_options*: Ruby build options.
18
+
19
+ *rubygems_build_options*: Rubygems build options.
20
+
21
+
22
+
@@ -0,0 +1,8 @@
1
+ h1. ruby
2
+
3
+ "home":../index.html > "recipes":index.html > ruby
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "ruby:centos":ruby-centos.html (1)
@@ -0,0 +1,35 @@
1
+ h1. sphinx:centos
2
+
3
+ "home":../index.html > "recipes":index.html > "sphinx":sphinx.html > centos
4
+
5
+
6
+ h2. Tasks
7
+
8
+ * "sphinx:centos:install":#sphinx:centos:install
9
+ * "sphinx:centos:setup":#sphinx:centos:setup
10
+
11
+
12
+ h2. Task documentation
13
+
14
+ h3(#sphinx:centos:install). sphinx:centos:install
15
+
16
+ Install sphinx.
17
+
18
+ *sphinx_build_options*: Sphinx build options.
19
+
20
+ *sphinx_prefix*: Sphinx install prefix. _Defaults to "/usr/local/sphinx"_
21
+
22
+
23
+
24
+ h3(#sphinx:centos:setup). sphinx:centos:setup
25
+
26
+ Setup sphinx for application.
27
+
28
+ *sphinx_prefix*: Sphinx install prefix. _Defaults to "/usr/local/sphinx"_
29
+
30
+ *sphinx_pid_path*: Directory to sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_
31
+
32
+ *sphinx_conf_path*: Path to sphinx.conf. _Defaults to "[shared_path]/config/sphinx.conf"_
33
+
34
+
35
+
@@ -0,0 +1,89 @@
1
+ h1. sphinx
2
+
3
+ "home":../index.html > "recipes":index.html > sphinx
4
+
5
+
6
+ h2. Namespaces
7
+
8
+ * "sphinx:centos":sphinx-centos.html (2)
9
+
10
+
11
+ h2. Tasks
12
+
13
+ * "sphinx:index_all":#sphinx:index_all
14
+ * "sphinx:restart":#sphinx:restart
15
+ * "sphinx:rotate_all":#sphinx:rotate_all
16
+ * "sphinx:setup_monit":#sphinx:setup_monit
17
+ * "sphinx:update_conf":#sphinx:update_conf
18
+
19
+
20
+ h2. Task documentation
21
+
22
+ h3(#sphinx:index_all). sphinx:index_all
23
+
24
+ Build sphinx indexes for application.
25
+
26
+ *sphinx_prefix*: Location to sphinx install. _Defaults to nil_
27
+
28
+ *sphinx_conf*: Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_
29
+
30
+
31
+
32
+ h3(#sphinx:restart). sphinx:restart
33
+
34
+ Restart sphinx
35
+
36
+
37
+
38
+ h3(#sphinx:rotate_all). sphinx:rotate_all
39
+
40
+ Rotate sphinx index for application.
41
+
42
+ *sphinx_prefix*: Location to sphinx install. _Defaults to nil_
43
+
44
+ *sphinx_conf*: Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_
45
+
46
+
47
+
48
+ h3(#sphinx:setup_monit). sphinx:setup_monit
49
+
50
+ Create monit configuration for sphinx.
51
+
52
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_
53
+
54
+ *sphinx_pid_path*: Location for sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_
55
+
56
+
57
+
58
+ h3(#sphinx:update_conf). sphinx:update_conf
59
+
60
+ Update sphinx for application.
61
+
62
+ *sphinx_conf_template*: Path to sphinx.conf.erb. _Defaults to "config/templates/sphinx.conf.erb"_
63
+
64
+ *sphinx_conf_path*: Path to sphinx.conf. _Defaults to "[shared_path]/config/sphinx.conf"_
65
+
66
+ *sphinx_port*: Sphinx port. _Defaults to 3312_
67
+
68
+ *sphinx_conf_root*: Directory for sphinx configuration, like stopwords.txt. _Defaults to [current_path]/config_
69
+
70
+ *sphinx_index_root*: Directory for sphinx indexes. _Defaults to "[shared_path]/var/index"_
71
+
72
+ *sphinx_log_root*: Directory for sphinx logs. _Defaults to "[shared_path]/log"_
73
+
74
+ *sphinx_pid_root*: Directory for sphinx pids. _Defaults to "[shared_path]/pids"_
75
+
76
+
77
+ *sphinx_db_user*: Sphinx DB user. _Defaults to db_user_
78
+
79
+ *sphinx_db_pass*: Sphinx DB password. _Defaults to db_pass_
80
+
81
+ *sphinx_db_name*: Sphinx DB name. _Defaults to db_name_
82
+
83
+
84
+ *sphinx_db_host*: Sphinx DB host. _Defaults to location for primary :db role_
85
+
86
+ *sphinx_host*: Sphinx DB host. _Defaults to location for :search role_
87
+
88
+
89
+
@@ -0,0 +1,14 @@
1
+ module Capitate::CapExt::RunVia
2
+
3
+ # Invoke command with current run_method setting.
4
+ #
5
+ # ==== Options
6
+ # +cmd+:: Command to run
7
+ # +options+:: Options (see invoke_command options)
8
+ #
9
+ def run_via(cmd, options = {}, &block)
10
+ options[:via] = fetch(:run_method, :sudo) unless options.has_key?(:via)
11
+ invoke_command(cmd, options, &block)
12
+ end
13
+
14
+ end
@@ -14,12 +14,11 @@ module Capitate::Plugins::Gem
14
14
  gems = [ gems ] unless gems.is_a?(Array)
15
15
 
16
16
  # Install one at a time because we may need to pass install args (e.g. mysql)
17
- # TODO: Fix this
18
17
  gems.each do |gem|
19
- sudo "gem install --no-rdoc --no-ri --no-verbose #{gem}"
18
+ run_via "gem install --no-rdoc --no-ri --no-verbose #{gem}"
20
19
  end
21
20
  end
22
21
 
23
22
  end
24
23
 
25
- Capistrano.plugin :gemc, Capitate::Plugins::Gem
24
+ Capistrano.plugin :gems, Capitate::Plugins::Gem
@@ -0,0 +1,24 @@
1
+
2
+ module Capitate::Plugins::Prompt
3
+
4
+ def ask(label, &block)
5
+ Capistrano::CLI.ui.ask(label, &block)
6
+ end
7
+
8
+ def password(label, verify = false)
9
+ # Lazy
10
+ Proc.new {
11
+ password = Capistrano::CLI.password_prompt(label)
12
+
13
+ if verify
14
+ password_verify = Capistrano::CLI.password_prompt("[Verify] #{label}")
15
+ raise "Passwords do not match" if password != password_verify
16
+ end
17
+
18
+ password
19
+ }
20
+ end
21
+
22
+ end
23
+
24
+ Capistrano.plugin :prompt, Capitate::Plugins::Prompt
@@ -16,9 +16,12 @@ module Capitate::Plugins::Script
16
16
  def make_install(name, options)
17
17
  install(name, options) do |dir|
18
18
  configure_options = options[:configure_options] || ""
19
- sudo "echo 'Configuring #{name}...' && cd #{dir} && ./configure #{configure_options} > configure.log"
20
- sudo "echo 'Compiling #{name}...' && cd #{dir} && make > make.log"
21
- sudo "echo 'Installing #{name}...' && cd #{dir} && make install > make_install.log"
19
+
20
+ run_all <<-CMDS
21
+ echo 'Configuring #{name}...' && cd #{dir} && ./configure #{configure_options} > configure.log
22
+ echo 'Compiling #{name}...' && cd #{dir} && make > make.log
23
+ echo 'Installing #{name}...' && cd #{dir} && make install > make_install.log
24
+ CMDS
22
25
  end
23
26
  end
24
27
 
@@ -62,21 +65,18 @@ module Capitate::Plugins::Script
62
65
 
63
66
  if File.extname(script) == ".erb"
64
67
  name = script[0...script.length-4]
65
- dest = "/tmp/#{name}"
66
- run "mkdir -p #{File.dirname(dest)}"
68
+ dest = "/tmp/cap/#{name}"
69
+ run_via "mkdir -p #{File.dirname(dest)}"
67
70
  put template.load(script, override_binding || binding), dest
68
71
  else
69
72
  name = script
70
- dest = "/tmp/#{name}"
71
- run "mkdir -p #{File.dirname(dest)}"
73
+ dest = "/tmp/cap/#{name}"
74
+ run_via "mkdir -p #{File.dirname(dest)}"
72
75
  put template.load(script), dest
73
76
  end
74
77
 
75
78
  # If want verbose, -v
76
- sudo "sh -v #{dest}"
77
-
78
- # Cleanup
79
- sudo "rm -rf #{File.dirname(dest)}"
79
+ run_via "sh -v #{dest} && rm -rf #{File.dirname(dest)}"
80
80
  end
81
81
 
82
82
  # Download and unpack URL.
@@ -103,16 +103,30 @@ module Capitate::Plugins::Script
103
103
 
104
104
  unpack_dir ||= file.gsub(/\.tar\.gz|\.tgz/, "")
105
105
 
106
- sudo "echo 'Getting #{url}...' && mkdir -p #{dest} && cd #{dest} && wget -nv #{url}"
107
- sudo "echo 'Unpacking...' && cd #{dest} && tar zxf #{file}"
106
+ run_all <<-CMDS
107
+ echo 'Getting #{url}...' && mkdir -p #{dest} && cd #{dest} && wget -nv #{url}
108
+ echo 'Unpacking...' && cd #{dest} && tar zxf #{file}
109
+ CMDS
108
110
 
109
111
  if block_given?
110
112
  yield("#{dest}/#{unpack_dir}")
111
- sudo "rm -f #{dest}/#{file}"
112
- sudo "rm -rf #{dest}" if clean
113
+ run_via "rm -f #{dest}/#{file}"
114
+ run_via "rm -rf #{dest}" if clean
113
115
  end
114
116
  end
115
117
 
118
+ # Run all commands (separated by newlines)
119
+ #
120
+ # ==== Options
121
+ # +cmds+:: Commands (separated by newlines)
122
+ # +options+:: See invoke_command options
123
+ #
124
+ def run_all(cmds, options = {}, &block)
125
+ cmds.split("\n").each do |cmd|
126
+ run_via(cmd, options, &block)
127
+ end
128
+ end
129
+
116
130
  end
117
131
 
118
132
  Capistrano.plugin :script, Capitate::Plugins::Script