vito 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/README.md +32 -19
- data/Rakefile +5 -20
- data/bin/vito +1 -1
- data/lib/vito.rb +5 -1
- data/lib/vito/command_line/command.rb +21 -0
- data/lib/vito/command_line/document_flags.rb +30 -0
- data/lib/vito/command_line/options.rb +41 -0
- data/lib/vito/command_line/string.rb +35 -0
- data/lib/vito/commands/help.rb +62 -0
- data/lib/vito/commands/install.rb +17 -0
- data/lib/vito/core_ext/string.rb +33 -0
- data/lib/vito/dsl/installation.rb +5 -2
- data/lib/vito/dsl/server.rb +3 -3
- data/lib/vito/dsl_file.rb +11 -5
- data/lib/vito/operating_systems/ubuntu_10.rb +4 -0
- data/lib/vito/output.rb +3 -1
- data/lib/vito/recipe.rb +29 -4
- data/lib/vito/recipes/apache/install.rb +155 -0
- data/lib/vito/recipes/apache/service.rb +20 -0
- data/lib/vito/recipes/git/install.rb +39 -0
- data/lib/vito/recipes/passenger/install.rb +83 -0
- data/lib/vito/recipes/passenger/paths.rb +27 -0
- data/lib/vito/recipes/postgres/install.rb +106 -0
- data/lib/vito/recipes/rbenv/install.rb +54 -0
- data/lib/vito/recipes/ruby/install.rb +57 -0
- data/lib/vito/recipes/ruby/paths.rb +19 -0
- data/lib/vito/tasks/vagrant_bootstrap.rb +49 -0
- data/lib/vito/tests/vagrant_test_box.rb +44 -0
- data/lib/vito/utils/program_version.rb +2 -2
- data/lib/vito/version.rb +1 -1
- data/spec/acceptance/recipes/apache_acceptance_spec.rb +25 -0
- data/spec/acceptance/recipes/git_acceptance_spec.rb +11 -11
- data/spec/acceptance/recipes/postgres_acceptance_spec.rb +11 -11
- data/spec/acceptance/recipes/rbenv_acceptance_spec.rb +13 -13
- data/spec/acceptance/recipes/ruby_acceptance_spec.rb +15 -15
- data/spec/support/vagrant.rb +21 -16
- data/spec/vagrant_boxes/centos63/.gitkeep +0 -0
- data/{Vagrantfile → spec/vagrant_boxes/centos63/Vagrantfile} +5 -4
- data/spec/vagrant_boxes/ubuntu10/Vagrantfile +100 -0
- data/spec/vagrant_boxes/ubuntu12/Vagrantfile +100 -0
- data/spec/vito/command_line/command_spec.rb +20 -0
- data/spec/vito/command_line/options_spec.rb +50 -0
- data/spec/vito/command_line/string_spec.rb +32 -0
- data/spec/vito/commands/install_spec.rb +9 -0
- data/spec/vito/connection_spec.rb +2 -2
- data/spec/vito/core_ext/string_spec.rb +19 -0
- data/spec/vito/dsl/installation_spec.rb +2 -2
- data/spec/vito/dsl_file_spec.rb +56 -18
- data/spec/vito/output_spec.rb +2 -2
- data/spec/vito/recipe_spec.rb +53 -3
- data/spec/vito/recipes/apache/install_spec.rb +140 -0
- data/spec/vito/recipes/passenger/paths_spec.rb +18 -0
- data/spec/vito/recipes/ruby_spec.rb +5 -5
- data/spec/vito/tasks/vagrant_bootstrap_spec.rb +65 -0
- data/spec/vito/tests/vagrant_test_box_spec.rb +69 -0
- data/spec/vito/utils/program_version_spec.rb +4 -2
- data/templates/apache2/vito_site +12 -0
- data/vito.gemspec +1 -1
- data/vito.rb +7 -5
- metadata +53 -13
- data/lib/vito/recipes/git.rb +0 -37
- data/lib/vito/recipes/postgres.rb +0 -104
- data/lib/vito/recipes/rbenv.rb +0 -47
- data/lib/vito/recipes/ruby.rb +0 -43
- data/lib/vito/shell_initializer.rb +0 -21
- data/spec/vito/shell_initializer_spec.rb +0 -22
@@ -0,0 +1,69 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Vito::Tests::VagrantTestBox do
|
4
|
+
let(:os_name) { "ubuntu10" }
|
5
|
+
|
6
|
+
subject { described_class.new(os_name) }
|
7
|
+
|
8
|
+
describe ".boxes" do
|
9
|
+
context "no custom box names passed in" do
|
10
|
+
it "returns class instances for each box" do
|
11
|
+
described_class.boxes.any? { |b| b.name == "centos63" }.should be_true
|
12
|
+
described_class.boxes.any? { |b| b.name == "ubuntu10" }.should be_true
|
13
|
+
described_class.boxes.any? { |b| b.name == "ubuntu12" }.should be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "custom box names passed in" do
|
18
|
+
it "returns class instances for each box" do
|
19
|
+
described_class.boxes(:ubuntu10, :ubuntu12).any? { |b| b.name == "ubuntu12" }.should be_true
|
20
|
+
described_class.boxes(:ubuntu10, :ubuntu12).any? { |b| b.name == "ubuntu10" }.should be_true
|
21
|
+
described_class.boxes(:ubuntu10, :ubuntu12).any? { |b| b.name == "centos63" }.should be_false
|
22
|
+
described_class.boxes(:ubuntu10).any? { |b| b.name == "ubuntu10" }.should be_true
|
23
|
+
described_class.boxes(:ubuntu10).any? { |b| b.name == "centos63" }.should be_false
|
24
|
+
described_class.boxes(:ubuntu10).any? { |b| b.name == "ubuntu12" }.should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#ssh_port" do
|
30
|
+
context "ubuntu10" do
|
31
|
+
let(:os_name) { "ubuntu10" }
|
32
|
+
its(:ssh_port) { should == "2223" }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "ubuntu12" do
|
36
|
+
let(:os_name) { "ubuntu12" }
|
37
|
+
its(:ssh_port) { should == "2224" }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "centos63" do
|
41
|
+
let(:os_name) { "centos63" }
|
42
|
+
its(:ssh_port) { should == "2225" }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#path" do
|
47
|
+
context "ubuntu10" do
|
48
|
+
let(:os_name) { "ubuntu10" }
|
49
|
+
its(:path) { should == "spec/vagrant_boxes/ubuntu10" }
|
50
|
+
end
|
51
|
+
|
52
|
+
context "ubuntu12" do
|
53
|
+
let(:os_name) { "ubuntu12" }
|
54
|
+
its(:path) { should == "spec/vagrant_boxes/ubuntu12" }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#initial_snapshot_name" do
|
59
|
+
context "ubuntu10" do
|
60
|
+
let(:os_name) { "ubuntu10" }
|
61
|
+
its(:initial_snapshot_name) { should == "ubuntu10_initial_box" }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "ubuntu12" do
|
65
|
+
let(:os_name) { "ubuntu12" }
|
66
|
+
its(:initial_snapshot_name) { should == "ubuntu12_initial_box" }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -16,9 +16,10 @@ describe Vito::Utils::ProgramVersion do
|
|
16
16
|
subject.matches?("2.0.0-p195").should be_true
|
17
17
|
subject.matches?("2.0.0p195").should be_true
|
18
18
|
subject.matches?("2.0.0").should be_true
|
19
|
+
subject.matches?.should be_true
|
19
20
|
end
|
20
21
|
|
21
|
-
it "returns false if it doesn't
|
22
|
+
it "returns false if it doesn't match" do
|
22
23
|
subject.matches?("2.0.0p125").should be_false
|
23
24
|
subject.matches?("1.9.3").should be_false
|
24
25
|
end
|
@@ -35,9 +36,10 @@ describe Vito::Utils::ProgramVersion do
|
|
35
36
|
subject.matches?("2.0.0").should be_false
|
36
37
|
end
|
37
38
|
|
38
|
-
it "returns false if it doesn't
|
39
|
+
it "returns false if it doesn't match" do
|
39
40
|
subject.matches?("2.0.0p125").should be_false
|
40
41
|
subject.matches?("1.9.3").should be_false
|
42
|
+
subject.matches?.should be_false
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<VirtualHost *:{{VITO_PORT}}>
|
2
|
+
ServerName {{VITO_SERVERNAME}}
|
3
|
+
# !!! Be sure to point DocumentRoot to 'public'!
|
4
|
+
DocumentRoot {{VITO_SITE_PATH}}
|
5
|
+
<Directory {{VITO_SITE_PATH}}>
|
6
|
+
# This relaxes Apache security settings.
|
7
|
+
AllowOverride all
|
8
|
+
# MultiViews must be turned off.
|
9
|
+
Options -MultiViews
|
10
|
+
</Directory>
|
11
|
+
</VirtualHost>
|
12
|
+
|
data/vito.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = Vito::VERSION
|
18
18
|
|
19
|
-
gem.
|
19
|
+
gem.add_development_dependency("rake")
|
20
20
|
gem.add_development_dependency("rspec")
|
21
21
|
gem.add_development_dependency("pry-debugger")
|
22
22
|
end
|
data/vito.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
server :ruby_server, :one do
|
2
2
|
# Vagrant box
|
3
|
-
connection :ssh, command: "ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -
|
3
|
+
connection :ssh, command: "ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p2224"
|
4
4
|
|
5
5
|
install :rbenv
|
6
6
|
install :git
|
7
7
|
install :ruby, version: "1.9.3-p125"
|
8
|
-
install :postgres
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
#install :postgres, username: 'vito', password: 'corleone'
|
9
|
+
install :apache do
|
10
|
+
with :passenger
|
11
|
+
vhosts with: :ssl, path: "/var/projects/someapp/current/public"
|
12
|
+
end
|
13
|
+
# install :tmux
|
12
14
|
end
|
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -65,16 +65,23 @@ files:
|
|
65
65
|
- .gitignore
|
66
66
|
- .rspec
|
67
67
|
- .rvmrc
|
68
|
+
- .travis.yml
|
68
69
|
- Gemfile
|
69
70
|
- LICENSE
|
70
71
|
- README.md
|
71
72
|
- Rakefile
|
72
|
-
- Vagrantfile
|
73
73
|
- bin/vito
|
74
74
|
- docs/manual.md
|
75
75
|
- lib/samples/vito_for_rails.rb
|
76
76
|
- lib/vito.rb
|
77
|
+
- lib/vito/command_line/command.rb
|
78
|
+
- lib/vito/command_line/document_flags.rb
|
79
|
+
- lib/vito/command_line/options.rb
|
80
|
+
- lib/vito/command_line/string.rb
|
81
|
+
- lib/vito/commands/help.rb
|
82
|
+
- lib/vito/commands/install.rb
|
77
83
|
- lib/vito/connection.rb
|
84
|
+
- lib/vito/core_ext/string.rb
|
78
85
|
- lib/vito/dsl/installation.rb
|
79
86
|
- lib/vito/dsl/server.rb
|
80
87
|
- lib/vito/dsl_file.rb
|
@@ -83,13 +90,20 @@ files:
|
|
83
90
|
- lib/vito/operating_systems/ubuntu_10.rb
|
84
91
|
- lib/vito/output.rb
|
85
92
|
- lib/vito/recipe.rb
|
86
|
-
- lib/vito/recipes/
|
87
|
-
- lib/vito/recipes/
|
88
|
-
- lib/vito/recipes/
|
89
|
-
- lib/vito/recipes/
|
90
|
-
- lib/vito/
|
93
|
+
- lib/vito/recipes/apache/install.rb
|
94
|
+
- lib/vito/recipes/apache/service.rb
|
95
|
+
- lib/vito/recipes/git/install.rb
|
96
|
+
- lib/vito/recipes/passenger/install.rb
|
97
|
+
- lib/vito/recipes/passenger/paths.rb
|
98
|
+
- lib/vito/recipes/postgres/install.rb
|
99
|
+
- lib/vito/recipes/rbenv/install.rb
|
100
|
+
- lib/vito/recipes/ruby/install.rb
|
101
|
+
- lib/vito/recipes/ruby/paths.rb
|
102
|
+
- lib/vito/tasks/vagrant_bootstrap.rb
|
103
|
+
- lib/vito/tests/vagrant_test_box.rb
|
91
104
|
- lib/vito/utils/program_version.rb
|
92
105
|
- lib/vito/version.rb
|
106
|
+
- spec/acceptance/recipes/apache_acceptance_spec.rb
|
93
107
|
- spec/acceptance/recipes/git_acceptance_spec.rb
|
94
108
|
- spec/acceptance/recipes/postgres_acceptance_spec.rb
|
95
109
|
- spec/acceptance/recipes/rbenv_acceptance_spec.rb
|
@@ -97,7 +111,16 @@ files:
|
|
97
111
|
- spec/fixtures/vito.rb
|
98
112
|
- spec/spec_helper.rb
|
99
113
|
- spec/support/vagrant.rb
|
114
|
+
- spec/vagrant_boxes/centos63/.gitkeep
|
115
|
+
- spec/vagrant_boxes/centos63/Vagrantfile
|
116
|
+
- spec/vagrant_boxes/ubuntu10/Vagrantfile
|
117
|
+
- spec/vagrant_boxes/ubuntu12/Vagrantfile
|
118
|
+
- spec/vito/command_line/command_spec.rb
|
119
|
+
- spec/vito/command_line/options_spec.rb
|
120
|
+
- spec/vito/command_line/string_spec.rb
|
121
|
+
- spec/vito/commands/install_spec.rb
|
100
122
|
- spec/vito/connection_spec.rb
|
123
|
+
- spec/vito/core_ext/string_spec.rb
|
101
124
|
- spec/vito/dsl/installation_spec.rb
|
102
125
|
- spec/vito/dsl/server_spec.rb
|
103
126
|
- spec/vito/dsl_file_spec.rb
|
@@ -106,10 +129,14 @@ files:
|
|
106
129
|
- spec/vito/operating_systems/ubuntu_10_spec.rb
|
107
130
|
- spec/vito/output_spec.rb
|
108
131
|
- spec/vito/recipe_spec.rb
|
132
|
+
- spec/vito/recipes/apache/install_spec.rb
|
109
133
|
- spec/vito/recipes/git_spec.rb
|
134
|
+
- spec/vito/recipes/passenger/paths_spec.rb
|
110
135
|
- spec/vito/recipes/ruby_spec.rb
|
111
|
-
- spec/vito/
|
136
|
+
- spec/vito/tasks/vagrant_bootstrap_spec.rb
|
137
|
+
- spec/vito/tests/vagrant_test_box_spec.rb
|
112
138
|
- spec/vito/utils/program_version_spec.rb
|
139
|
+
- templates/apache2/vito_site
|
113
140
|
- vito.gemspec
|
114
141
|
- vito.rb
|
115
142
|
homepage: http://github.com/kurko/vito
|
@@ -132,11 +159,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
159
|
version: '0'
|
133
160
|
requirements: []
|
134
161
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.0.
|
162
|
+
rubygems_version: 2.0.3
|
136
163
|
signing_key:
|
137
164
|
specification_version: 4
|
138
165
|
summary: Install webserver environments automatically in an easier way
|
139
166
|
test_files:
|
167
|
+
- spec/acceptance/recipes/apache_acceptance_spec.rb
|
140
168
|
- spec/acceptance/recipes/git_acceptance_spec.rb
|
141
169
|
- spec/acceptance/recipes/postgres_acceptance_spec.rb
|
142
170
|
- spec/acceptance/recipes/rbenv_acceptance_spec.rb
|
@@ -144,7 +172,16 @@ test_files:
|
|
144
172
|
- spec/fixtures/vito.rb
|
145
173
|
- spec/spec_helper.rb
|
146
174
|
- spec/support/vagrant.rb
|
175
|
+
- spec/vagrant_boxes/centos63/.gitkeep
|
176
|
+
- spec/vagrant_boxes/centos63/Vagrantfile
|
177
|
+
- spec/vagrant_boxes/ubuntu10/Vagrantfile
|
178
|
+
- spec/vagrant_boxes/ubuntu12/Vagrantfile
|
179
|
+
- spec/vito/command_line/command_spec.rb
|
180
|
+
- spec/vito/command_line/options_spec.rb
|
181
|
+
- spec/vito/command_line/string_spec.rb
|
182
|
+
- spec/vito/commands/install_spec.rb
|
147
183
|
- spec/vito/connection_spec.rb
|
184
|
+
- spec/vito/core_ext/string_spec.rb
|
148
185
|
- spec/vito/dsl/installation_spec.rb
|
149
186
|
- spec/vito/dsl/server_spec.rb
|
150
187
|
- spec/vito/dsl_file_spec.rb
|
@@ -153,7 +190,10 @@ test_files:
|
|
153
190
|
- spec/vito/operating_systems/ubuntu_10_spec.rb
|
154
191
|
- spec/vito/output_spec.rb
|
155
192
|
- spec/vito/recipe_spec.rb
|
193
|
+
- spec/vito/recipes/apache/install_spec.rb
|
156
194
|
- spec/vito/recipes/git_spec.rb
|
195
|
+
- spec/vito/recipes/passenger/paths_spec.rb
|
157
196
|
- spec/vito/recipes/ruby_spec.rb
|
158
|
-
- spec/vito/
|
197
|
+
- spec/vito/tasks/vagrant_bootstrap_spec.rb
|
198
|
+
- spec/vito/tests/vagrant_test_box_spec.rb
|
159
199
|
- spec/vito/utils/program_version_spec.rb
|
data/lib/vito/recipes/git.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Vito
|
2
|
-
module Recipes
|
3
|
-
class Git < Vito::Recipe
|
4
|
-
def run
|
5
|
-
if git_installed?
|
6
|
-
Vito::Log.write "Git is already installed."
|
7
|
-
else
|
8
|
-
Vito::Log.write "Installing Git's OS dependencies"
|
9
|
-
install_os_dependencies
|
10
|
-
Vito::Log.write "Installing Git itself"
|
11
|
-
install_git
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def git_installed?
|
18
|
-
query("git --version").success?
|
19
|
-
end
|
20
|
-
|
21
|
-
def install_git
|
22
|
-
string = []
|
23
|
-
string << "sudo apt-get install -y git-core"
|
24
|
-
string << "git --version"
|
25
|
-
run_command(string.join(" && "))
|
26
|
-
end
|
27
|
-
|
28
|
-
def os_dependencies
|
29
|
-
%w(build-essential openssl libreadline6
|
30
|
-
libreadline6-dev zlib1g zlib1g-dev libssl-dev
|
31
|
-
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3
|
32
|
-
libxml2-dev libxslt1-dev autoconf libc6-dev
|
33
|
-
libncurses5-dev)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module Vito
|
2
|
-
module Recipes
|
3
|
-
class Postgres < Vito::Recipe
|
4
|
-
def run
|
5
|
-
if installed?
|
6
|
-
Vito::Log.write "Postgres already installed."
|
7
|
-
else
|
8
|
-
Vito::Log.write "Installing Postgres"
|
9
|
-
install_os_dependencies
|
10
|
-
install
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def postgres_installed?
|
17
|
-
@memo ||= query("psql --version").success?
|
18
|
-
end
|
19
|
-
|
20
|
-
def user_exists?
|
21
|
-
query("sudo su - postgres -c \"psql -tAc \\\\\"SELECT 1 FROM pg_roles WHERE rolname='#{username}'\\\\\" | grep -q 1 || echo 'hey'\"").result == ""
|
22
|
-
end
|
23
|
-
|
24
|
-
def utf_template?
|
25
|
-
query("sudo su - postgres -c \"psql -d template1 -c \\\\\"SHOW SERVER_ENCODING;\\\\\" | grep -q UTF || echo 'hey'\"").result == ""
|
26
|
-
end
|
27
|
-
|
28
|
-
def installed?
|
29
|
-
# Only verifies Postgres configuration if it's installed
|
30
|
-
if postgres_installed?
|
31
|
-
Vito::Log.write "User doesn't exist. I will create one." unless user_exists?
|
32
|
-
Vito::Log.write "template1 database's encoding should be UTF-8. I'll adjust this." unless utf_template?
|
33
|
-
end
|
34
|
-
|
35
|
-
postgres_installed? &&
|
36
|
-
user_exists? &&
|
37
|
-
utf_template?
|
38
|
-
end
|
39
|
-
|
40
|
-
def username
|
41
|
-
"vitouser"
|
42
|
-
end
|
43
|
-
|
44
|
-
def password
|
45
|
-
"123456"
|
46
|
-
end
|
47
|
-
|
48
|
-
def install
|
49
|
-
string = []
|
50
|
-
run_command "sudo apt-get install -y postgresql-9.1 libpq-dev"
|
51
|
-
|
52
|
-
# Create user only if it doesn't exist yet
|
53
|
-
unless user_exists?
|
54
|
-
string << "sudo su - postgres -c \"createuser -d -r -s #{username}\""
|
55
|
-
end
|
56
|
-
|
57
|
-
run_command(string.join(" && ")) unless string.empty?
|
58
|
-
convert_template1_to_utf8 unless utf_template?
|
59
|
-
string = []
|
60
|
-
|
61
|
-
if os.is?(:ubuntu, "10")
|
62
|
-
string << "sudo /etc/init.d/postgresql restart"
|
63
|
-
else
|
64
|
-
string << "sudo service postgresql restart"
|
65
|
-
end
|
66
|
-
run_command "sudo su - postgres -c \"psql -d template1 -c \\\\\"alter user #{username} with password '#{password}'\\\\\";\""
|
67
|
-
|
68
|
-
run_command(string.join(" && "))
|
69
|
-
end
|
70
|
-
|
71
|
-
def install_os_dependencies
|
72
|
-
return if postgres_installed?
|
73
|
-
Vito::Log.write "Installing some OS dependencies first"
|
74
|
-
if os.is?(:ubuntu, "10")
|
75
|
-
run_command("sudo apt-get remove -y postgresql")
|
76
|
-
run_command("sudo apt-get autoremove -y")
|
77
|
-
run_command("sudo apt-get install -y python-software-properties")
|
78
|
-
run_command("sudo add-apt-repository ppa:pitti/postgresql && sudo apt-get update")
|
79
|
-
end
|
80
|
-
|
81
|
-
super
|
82
|
-
end
|
83
|
-
|
84
|
-
def os_dependencies
|
85
|
-
%w(libpq-dev postgresql-contrib)
|
86
|
-
end
|
87
|
-
|
88
|
-
def convert_template1_to_utf8
|
89
|
-
# In some cases, the OS locale won't be compatible with UTF-8. When
|
90
|
-
# creating a database, Rails will try to use Postgres' template1 with
|
91
|
-
# UTF-8.
|
92
|
-
#
|
93
|
-
# Here, we delete template1, then login in template0 to recreate
|
94
|
-
# template1 with UTF-8 encoding.
|
95
|
-
run_command "sudo su - postgres -c \"psql -d template1 -c \\\\\"UPDATE pg_database SET datallowconn = TRUE where datname = 'template0';\\\\\"\""
|
96
|
-
run_command "sudo su - postgres -c \"psql -d template0 -c \\\\\"UPDATE pg_database SET datistemplate = FALSE where datname = 'template1'; \\\\\"\""
|
97
|
-
run_command "sudo su - postgres -c \"psql -d template0 -c \\\\\"drop database template1; \\\\\"\""
|
98
|
-
run_command "sudo su - postgres -c \"psql -d template0 -c \\\\\"create database template1 with template = template0 encoding = 'UNICODE' LC_CTYPE = 'en_US.UTF-8' LC_COLLATE = 'C'; \\\\\"\""
|
99
|
-
run_command "sudo su - postgres -c \"psql -d template0 -c \\\\\" UPDATE pg_database SET datistemplate = TRUE where datname = 'template1'; \\\\\"\""
|
100
|
-
run_command "sudo su - postgres -c \"psql -d template1 -c \\\\\" UPDATE pg_database SET datallowconn = FALSE where datname = 'template0'; \\\\\"\""
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
data/lib/vito/recipes/rbenv.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Vito
|
2
|
-
module Recipes
|
3
|
-
class Rbenv < Vito::Recipe
|
4
|
-
def run
|
5
|
-
if rbenv_installed?
|
6
|
-
Vito::Log.write "Rbenv already installed."
|
7
|
-
else
|
8
|
-
Vito::Log.write "Installing Rbenv"
|
9
|
-
depends_on_recipe(:git)
|
10
|
-
install_rbenv
|
11
|
-
install_ruby_build
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def rbenv_installed?
|
18
|
-
string = []
|
19
|
-
string << "cd ~/"
|
20
|
-
string << "rbenv commands"
|
21
|
-
query(string.join(" && ")).success?
|
22
|
-
end
|
23
|
-
|
24
|
-
def install_rbenv
|
25
|
-
puts "Installing Rbenv..."
|
26
|
-
string = []
|
27
|
-
# TODO verify if this folder already exists
|
28
|
-
run_command "git clone git://github.com/sstephenson/rbenv.git ~/.rbenv"
|
29
|
-
|
30
|
-
# TODO verify if .bashrc already have these lines
|
31
|
-
string = []
|
32
|
-
string << "echo 'eval \"$(rbenv init -)\"' | cat - ~/.bashrc > vitotemp && mv vitotemp ~/.bashrc"
|
33
|
-
string << "echo 'export PATH=\"\\$HOME/.rbenv/bin:\\$PATH\"' | cat - ~/.bashrc > vitotemp && mv vitotemp ~/.bashrc"
|
34
|
-
|
35
|
-
run_command string.join(" && ")
|
36
|
-
end
|
37
|
-
|
38
|
-
def install_ruby_build
|
39
|
-
puts "Installing ruby-build embedded into rbenv..."
|
40
|
-
string = []
|
41
|
-
# TODO verify if this dir already exists
|
42
|
-
string << "git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build"
|
43
|
-
run_command string.join(" && ")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|