suitmymind-ubuntu-machine 0.3.1.2 → 0.4.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.
- data/README +5 -1
- data/lib/capistrano/ext/ubuntu-machine/aptitude.rb +1 -9
- data/lib/capistrano/ext/ubuntu-machine/helpers.rb +36 -0
- data/lib/capistrano/ext/ubuntu-machine/machine.rb +4 -29
- data/lib/capistrano/ext/ubuntu-machine/mysql.rb +1 -11
- data/lib/capistrano/ext/ubuntu-machine/ruby.rb +14 -1
- data/lib/capistrano/ext/ubuntu-machine/utils.rb +2 -10
- metadata +3 -3
- data/lib/capistrano/ext/ubuntu-machine/render.rb +0 -6
data/README
CHANGED
@@ -37,15 +37,7 @@ namespace :aptitude do
|
|
37
37
|
# if it must overwrite this file, since it has been modified by OVH. \
|
38
38
|
# data =~ /^\*\*\*\sissue/ looks for the interactive prompt to enable you to answer
|
39
39
|
sudo 'aptitude hold console-setup -y'
|
40
|
-
|
41
|
-
if data =~ /^\*\*\*\sissue/
|
42
|
-
# prompt, and then send the response to the remote process
|
43
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
44
|
-
else
|
45
|
-
# use the default handler for all other text
|
46
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
47
|
-
end
|
48
|
-
end
|
40
|
+
sudo_and_watch_prompt("aptitude safe-upgrade -y", /^\*\*\*\sissue/)
|
49
41
|
end
|
50
42
|
|
51
43
|
desc <<-DESC
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
# render a template
|
4
|
+
def render(file, binding)
|
5
|
+
template = File.read("#{File.dirname(__FILE__)}/templates/#{file}.erb")
|
6
|
+
result = ERB.new(template).result(binding)
|
7
|
+
end
|
8
|
+
|
9
|
+
# allows to sudo a command which require the user input via the prompt
|
10
|
+
def sudo_and_watch_prompt(cmd, regex_to_watch)
|
11
|
+
sudo cmd, :pty => true do |ch, stream, data|
|
12
|
+
watch_prompt(ch, stream, data, regex_to_watch)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# allows to run a command which require the user input via the prompt
|
17
|
+
def run_and_watch_prompt(cmd, regex_to_watch)
|
18
|
+
run cmd, :pty => true do |ch, stream, data|
|
19
|
+
watch_prompt(ch, stream, data, regex_to_watch)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# utility method called by sudo_and_watch_prompt and run_and_watch_prompt
|
24
|
+
def watch_prompt(ch, stream, data, regex_to_watch)
|
25
|
+
|
26
|
+
# the regex can be an array or a single regex -> we force it to always be an array with [*xx]
|
27
|
+
if [*regex_to_watch].find { |regex| data =~ regex}
|
28
|
+
# prompt, and then send the response to the remote process
|
29
|
+
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
30
|
+
else
|
31
|
+
# use the default handler for all other text
|
32
|
+
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
@@ -5,26 +5,9 @@ namespace :machine do
|
|
5
5
|
set :user_to_create , user
|
6
6
|
set :user, 'root'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# prompt, and then send the response to the remote process
|
12
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
13
|
-
else
|
14
|
-
# use the default handler for all other text
|
15
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
run "adduser #{user_to_create}", :pty => true do |ch, stream, data|
|
20
|
-
if data =~ /Enter new UNIX password/ || data=~ /Retype new UNIX password:/ || data=~/\[\]\:/ || data=~/\[y\/N\]/i
|
21
|
-
# prompt, and then send the response to the remote process
|
22
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
23
|
-
else
|
24
|
-
# use the default handler for all other text
|
25
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
26
|
-
end
|
27
|
-
end
|
8
|
+
run_and_watch_prompt("passwd", [/Enter new UNIX password/, /Retype new UNIX password:/])
|
9
|
+
|
10
|
+
run_and_watch_prompt("adduser #{user_to_create}", [/Enter new UNIX password/, /Retype new UNIX password:/, /\[\]\:/, /\[y\/N\]/i])
|
28
11
|
|
29
12
|
run "echo '#{user_to_create} ALL=(ALL)ALL' >> /etc/sudoers"
|
30
13
|
run "echo 'AllowUsers #{user_to_create}' >> /etc/ssh/sshd_config"
|
@@ -52,14 +35,6 @@ namespace :machine do
|
|
52
35
|
task :change_password do
|
53
36
|
user_to_update = Capistrano::CLI.ui.ask("Name of the user whose you want to update the password : ")
|
54
37
|
|
55
|
-
|
56
|
-
if data =~ /Enter new UNIX password/ || data=~ /Retype new UNIX password:/
|
57
|
-
# prompt, and then send the response to the remote process
|
58
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
59
|
-
else
|
60
|
-
# use the default handler for all other text
|
61
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
62
|
-
end
|
63
|
-
end
|
38
|
+
run_and_watch_prompt("passwd #{user_to_update}", [/Enter new UNIX password/, /Retype new UNIX password:/])
|
64
39
|
end
|
65
40
|
end
|
@@ -19,16 +19,7 @@ namespace :mysql do
|
|
19
19
|
desc "Export MySQL database"
|
20
20
|
task :export, :roles => :db do
|
21
21
|
database = Capistrano::CLI.ui.ask("Which database should we export: ")
|
22
|
-
|
23
|
-
sudo "mysqldump -u root -p #{database} > #{database}.sql", :pty => true do |ch, stream, data|
|
24
|
-
if data =~ /Enter\spassword/
|
25
|
-
# prompt, and then send the response to the remote process
|
26
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
27
|
-
else
|
28
|
-
# use the default handler for all other text
|
29
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
30
|
-
end
|
31
|
-
end
|
22
|
+
sudo_and_watch_prompt("mysqldump -u root -p #{database} > #{database}.sql", /Enter\spassword/)
|
32
23
|
download "#{database}.sql", "#{default_local_files_path}/database.sql"
|
33
24
|
run "rm #{database}.sql"
|
34
25
|
end
|
@@ -58,7 +49,6 @@ namespace :mysql do
|
|
58
49
|
task :install, :roles => :db do
|
59
50
|
db_root_password = Capistrano::CLI.ui.ask("Choose a MySQL root password : ")
|
60
51
|
sudo "aptitude install -y mysql-server mysql-client libmysqlclient15-dev"
|
61
|
-
sudo "aptitude install -y libmysql-ruby1.8"
|
62
52
|
run "mysqladmin -u root password #{db_root_password}"
|
63
53
|
end
|
64
54
|
|
@@ -1,13 +1,25 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
1
3
|
namespace :ruby do
|
2
4
|
desc "Install Ruby 1.8"
|
3
5
|
task :install, :roles => :app do
|
4
6
|
sudo "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"
|
7
|
+
sudo "aptitude install -y libmysql-ruby1.8"
|
5
8
|
|
6
9
|
sudo "ln -s /usr/bin/ruby1.8 /usr/bin/ruby"
|
7
10
|
sudo "ln -s /usr/bin/ri1.8 /usr/bin/ri"
|
8
11
|
sudo "ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc"
|
9
12
|
sudo "ln -s /usr/bin/irb1.8 /usr/bin/irb"
|
10
13
|
end
|
14
|
+
|
15
|
+
|
16
|
+
set :ruby_enterprise_url do
|
17
|
+
Net::HTTP.get('www.rubyenterpriseedition.com', '/download.html').scan(/http:.*\.tar\.gz/).first
|
18
|
+
end
|
19
|
+
|
20
|
+
set :ruby_enterprise_version do
|
21
|
+
"#{ruby_enterprise_url[/(ruby-enterprise.*)(.tar.gz)/, 1]}"
|
22
|
+
end
|
11
23
|
|
12
24
|
desc "Install Ruby Enterpise Edition"
|
13
25
|
task :install_enterprise, :roles => :app do
|
@@ -15,7 +27,8 @@ namespace :ruby do
|
|
15
27
|
sudo "apt-get install libreadline5-dev -y"
|
16
28
|
|
17
29
|
run "test ! -d /opt/#{ruby_enterprise_version}"
|
18
|
-
run "curl -LO http://rubyforge.org/frs/download.php/50087/#{ruby_enterprise_version}.tar.gz"
|
30
|
+
# run "curl -LO http://rubyforge.org/frs/download.php/50087/#{ruby_enterprise_version}.tar.gz"
|
31
|
+
run "curl -LO #{ruby_enterprise_url}"
|
19
32
|
run "tar xzvf #{ruby_enterprise_version}.tar.gz"
|
20
33
|
run "rm #{ruby_enterprise_version}.tar.gz"
|
21
34
|
sudo "./#{ruby_enterprise_version}/installer --auto /opt/#{ruby_enterprise_version}"
|
@@ -33,16 +33,8 @@ namespace :utils do
|
|
33
33
|
|
34
34
|
desc "Activate Phusion Passenger Enterprise Edition."
|
35
35
|
task :passenger_enterprise, :roles => :gateway do
|
36
|
-
|
37
|
-
|
38
|
-
if data =~ /Key\:/ || data =~ /again\:/
|
39
|
-
# prompt, and then send the response to the remote process
|
40
|
-
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
41
|
-
else
|
42
|
-
# use the default handler for all other text
|
43
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
44
|
-
end
|
45
|
-
end
|
36
|
+
|
37
|
+
sudo_and_watch_prompt("/opt/ruby-enterprise/bin/passenger-make-enterprisey", [/Key\:/, /again\:/])
|
46
38
|
end
|
47
39
|
|
48
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suitmymind-ubuntu-machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Balthazar
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- MIT-LICENSE
|
35
35
|
- lib/capistrano/ext/ubuntu-machine.rb
|
36
36
|
- lib/capistrano/ext/ubuntu-machine
|
37
|
+
- lib/capistrano/ext/ubuntu-machine/helpers.rb
|
37
38
|
- lib/capistrano/ext/ubuntu-machine/ruby.rb
|
38
39
|
- lib/capistrano/ext/ubuntu-machine/gems.rb
|
39
40
|
- lib/capistrano/ext/ubuntu-machine/git.rb
|
@@ -41,7 +42,6 @@ files:
|
|
41
42
|
- lib/capistrano/ext/ubuntu-machine/php.rb
|
42
43
|
- lib/capistrano/ext/ubuntu-machine/ssh.rb
|
43
44
|
- lib/capistrano/ext/ubuntu-machine/machine.rb
|
44
|
-
- lib/capistrano/ext/ubuntu-machine/render.rb
|
45
45
|
- lib/capistrano/ext/ubuntu-machine/apache.rb
|
46
46
|
- lib/capistrano/ext/ubuntu-machine/iptables.rb
|
47
47
|
- lib/capistrano/ext/ubuntu-machine/mysql.rb
|