<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -37,15 +37,7 @@ namespace :aptitude do
     # if it must overwrite this file, since it has been modified by OVH. \
     # data =~ /^\*\*\*\sissue/ looks for the interactive prompt to enable you to answer
     sudo 'aptitude hold console-setup -y'
-    sudo 'aptitude safe-upgrade -y', :pty =&gt; true do |ch, stream, data|
-      if data =~ /^\*\*\*\sissue/
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-       end
-     end
+    sudo_and_watch_prompt(&quot;aptitude safe-upgrade -y&quot;, /^\*\*\*\sissue/)    
   end
   
   desc &lt;&lt;-DESC</diff>
      <filename>lib/capistrano/ext/ubuntu-machine/aptitude.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,36 @@
 require 'erb'
 
+# render a template
 def render(file, binding)
   template = File.read(&quot;#{File.dirname(__FILE__)}/templates/#{file}.erb&quot;)
   result = ERB.new(template).result(binding)
 end
+
+# allows to sudo a command which require the user input via the prompt
+def sudo_and_watch_prompt(cmd, regex_to_watch)
+  sudo cmd, :pty =&gt; true do |ch, stream, data|
+    watch_prompt(ch, stream, data, regex_to_watch)
+  end
+end
+
+# allows to run a command which require the user input via the prompt
+def run_and_watch_prompt(cmd, regex_to_watch)
+  run cmd, :pty =&gt; true do |ch, stream, data|
+    watch_prompt(ch, stream, data, regex_to_watch)
+  end
+end
+
+# utility method called by sudo_and_watch_prompt and run_and_watch_prompt
+def watch_prompt(ch, stream, data, regex_to_watch)
+
+  # the regex can be an array or a single regex -&gt; we force it to always be an array with [*xx]
+  if [*regex_to_watch].find { |regex| data =~ regex}
+    # prompt, and then send the response to the remote process
+    ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
+  else
+    # use the default handler for all other text
+    Capistrano::Configuration.default_io_proc.call(ch, stream, data)
+  end
+end
+
+</diff>
      <filename>lib/capistrano/ext/ubuntu-machine/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,26 +5,9 @@ namespace :machine do
     set :user_to_create , user
     set :user, 'root'
     
-    
-    run &quot;passwd&quot;, :pty =&gt; true do |ch, stream, data|
-      if data =~ /Enter new UNIX password/ || data=~ /Retype new UNIX password:/
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-      end
-    end
-    
-    run &quot;adduser #{user_to_create}&quot;, :pty =&gt; true do |ch, stream, data|
-      if data =~ /Enter new UNIX password/ || data=~ /Retype new UNIX password:/ || data=~/\[\]\:/ || data=~/\[y\/N\]/i
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-      end
-    end
+    run_and_watch_prompt(&quot;passwd&quot;, [/Enter new UNIX password/, /Retype new UNIX password:/])
+
+    run_and_watch_prompt(&quot;adduser #{user_to_create}&quot;, [/Enter new UNIX password/, /Retype new UNIX password:/, /\[\]\:/, /\[y\/N\]/i])
     
     run &quot;echo '#{user_to_create} ALL=(ALL)ALL' &gt;&gt; /etc/sudoers&quot;
     run &quot;echo 'AllowUsers #{user_to_create}' &gt;&gt; /etc/ssh/sshd_config&quot;
@@ -52,14 +35,6 @@ namespace :machine do
   task :change_password do
     user_to_update = Capistrano::CLI.ui.ask(&quot;Name of the user whose you want to update the password : &quot;)
     
-    sudo &quot;passwd #{user_to_update}&quot;, :pty =&gt; true do |ch, stream, data|
-      if data =~ /Enter new UNIX password/ || data=~ /Retype new UNIX password:/
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-      end
-    end
+    run_and_watch_prompt(&quot;passwd #{user_to_update}&quot;, [/Enter new UNIX password/, /Retype new UNIX password:/])
   end
 end</diff>
      <filename>lib/capistrano/ext/ubuntu-machine/machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,16 +19,7 @@ namespace :mysql do
   desc &quot;Export MySQL database&quot;
   task :export, :roles =&gt; :db do
     database = Capistrano::CLI.ui.ask(&quot;Which database should we export: &quot;)
-    # sudo &quot;mysqldump -u root -p #{database} &gt; #{database}.sql&quot;, :pty =&gt; true
-    sudo &quot;mysqldump -u root -p #{database} &gt; #{database}.sql&quot;, :pty =&gt; true do |ch, stream, data|
-      if data =~ /Enter\spassword/
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-       end
-     end
+    sudo_and_watch_prompt(&quot;mysqldump -u root -p #{database} &gt; #{database}.sql&quot;, /Enter\spassword/)
     download &quot;#{database}.sql&quot;, &quot;#{default_local_files_path}/database.sql&quot;
     run &quot;rm #{database}.sql&quot;
   end
@@ -58,7 +49,6 @@ namespace :mysql do
   task :install, :roles =&gt; :db do
     db_root_password = Capistrano::CLI.ui.ask(&quot;Choose a MySQL root password : &quot;)
     sudo &quot;aptitude install -y mysql-server mysql-client libmysqlclient15-dev&quot;
-    sudo &quot;aptitude install -y libmysql-ruby1.8&quot;
     run &quot;mysqladmin -u root password #{db_root_password}&quot;
   end
   </diff>
      <filename>lib/capistrano/ext/ubuntu-machine/mysql.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,25 @@
+require 'net/http'
+
 namespace :ruby do
   desc &quot;Install Ruby 1.8&quot;
   task :install, :roles =&gt; :app do
     sudo &quot;aptitude install -y ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8&quot;
+    sudo &quot;aptitude install -y libmysql-ruby1.8&quot;
 
     sudo &quot;ln -s /usr/bin/ruby1.8 /usr/bin/ruby&quot;
     sudo &quot;ln -s /usr/bin/ri1.8 /usr/bin/ri&quot;
     sudo &quot;ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc&quot;
     sudo &quot;ln -s /usr/bin/irb1.8 /usr/bin/irb&quot;
   end
+  
+
+  set :ruby_enterprise_url do
+    Net::HTTP.get('www.rubyenterpriseedition.com', '/download.html').scan(/http:.*\.tar\.gz/).first
+  end
+
+  set :ruby_enterprise_version do
+    &quot;#{ruby_enterprise_url[/(ruby-enterprise.*)(.tar.gz)/, 1]}&quot;
+  end
 
   desc &quot;Install Ruby Enterpise Edition&quot;
   task :install_enterprise, :roles =&gt; :app do
@@ -15,7 +27,8 @@ namespace :ruby do
     sudo &quot;apt-get install libreadline5-dev -y&quot;
     
     run &quot;test ! -d /opt/#{ruby_enterprise_version}&quot;
-    run &quot;curl -LO http://rubyforge.org/frs/download.php/50087/#{ruby_enterprise_version}.tar.gz&quot;
+    # run &quot;curl -LO http://rubyforge.org/frs/download.php/50087/#{ruby_enterprise_version}.tar.gz&quot;
+    run &quot;curl -LO #{ruby_enterprise_url}&quot;
     run &quot;tar xzvf #{ruby_enterprise_version}.tar.gz&quot;
     run &quot;rm #{ruby_enterprise_version}.tar.gz&quot;
     sudo &quot;./#{ruby_enterprise_version}/installer --auto /opt/#{ruby_enterprise_version}&quot;</diff>
      <filename>lib/capistrano/ext/ubuntu-machine/ruby.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,16 +33,8 @@ namespace :utils do
 
   desc &quot;Activate Phusion Passenger Enterprise Edition.&quot;
   task :passenger_enterprise, :roles =&gt; :gateway do
-    # sudo &quot;passenger-make-enterprisey&quot;
-    sudo '/opt/ruby-enterprise/bin/passenger-make-enterprisey', :pty =&gt; true do |ch, stream, data|
-      if data =~ /Key\:/ || data =~ /again\:/
-        # prompt, and then send the response to the remote process
-        ch.send_data(Capistrano::CLI.password_prompt(data) + &quot;\n&quot;)
-      else
-        # use the default handler for all other text
-        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
-      end
-    end
+
+    sudo_and_watch_prompt(&quot;/opt/ruby-enterprise/bin/passenger-make-enterprisey&quot;, [/Key\:/,  /again\:/])    
   end
   
 end
\ No newline at end of file</diff>
      <filename>lib/capistrano/ext/ubuntu-machine/utils.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 Gem::Specification.new do |s|
   s.name     = &quot;ubuntu-machine&quot;
-  s.version  = &quot;0.3.1.2&quot;
-  s.date     = &quot;2009-01-31&quot;
+  s.version  = &quot;0.4.0&quot;
+  s.date     = &quot;2009-02-06&quot;
   s.summary  = &quot;Capistrano recipes for setting up and deploying to a Ubuntu Machine&quot;
   s.email    = &quot;thomas@suitmymind.com&quot;
   s.homepage = &quot;http://suitmymind.github.com/ubuntu-machine&quot;</diff>
      <filename>ubuntu-machine.gemspec</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>00f62c10761b61ccdfff65613a022aef80fe5065</id>
    </parent>
  </parents>
  <author>
    <name>Thomas Balthazar</name>
    <email>thomas@suitmymind.com</email>
  </author>
  <url>http://github.com/suitmymind/ubuntu-machine/commit/57daf2bb7d5ba6237752bf43d17ed4436d5cd81c</url>
  <id>57daf2bb7d5ba6237752bf43d17ed4436d5cd81c</id>
  <committed-date>2009-02-06T06:07:07-08:00</committed-date>
  <authored-date>2009-02-06T06:07:07-08:00</authored-date>
  <message>* [#6 state:resolved] : extract the sudo 'aptitude safe-upgrade -y', :pty =&gt; true do |ch, stream, data| method
* libmysql-ruby1.8 is now installed by the ruby:install task instead of the mysql task, which is more coherent for people that do not need ruby</message>
  <tree>cf7aa1caf3b6a471d94595a54db167e31bd2cbb8</tree>
  <committer>
    <name>Thomas Balthazar</name>
    <email>thomas@suitmymind.com</email>
  </committer>
</commit>
