refile-postgres 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +16 -0
- data/README.md +12 -0
- data/docker-compose.yml +22 -0
- data/lib/generators/refile/postgres/migration/templates/migration.rb.erb +25 -5
- data/lib/refile/postgres/backend.rb +14 -8
- data/lib/refile/postgres/version.rb +1 -1
- data/migration_to_1_3_0.md +47 -0
- data/spec/refile/postgres/backend_spec.rb +14 -2
- data/spec/spec_helper.rb +42 -13
- metadata +5 -12
- data/Berksfile +0 -4
- data/Berksfile.lock +0 -7
- data/Vagrantfile +0 -24
- data/cookbooks/dev-essential/metadata.rb +0 -8
- data/cookbooks/dev-essential/recipes/default.rb +0 -9
- data/cookbooks/postgresql/metadata.rb +0 -8
- data/cookbooks/postgresql/recipes/default.rb +0 -29
- data/cookbooks/ruby/attributes/default.rb +0 -2
- data/cookbooks/ruby/metadata.rb +0 -6
- data/cookbooks/ruby/recipes/default.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8bef59aba0412348cf839d73d050fe0884d0a76
|
4
|
+
data.tar.gz: 67e92c6a6f7ff603458ffa802c45af72468f2c4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb11435d032ab11d7b3f7fe05ca49b2d9d50b3bce200d08d6d8b706b3b4d4c47f647c43483b10c3806424e8b62c051ed2d18c9b6ef8216d6c7fd8c4c56e683d1
|
7
|
+
data.tar.gz: ffce481c8f6aafd7c3a8665c496cab13d598b123ba662e06fd1b1bc169a999be377f3e32084ec970833cccbd864807fc73c889110ad2b715dc992a64893811f2
|
data/Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
FROM ruby:2.3.0
|
2
|
+
|
3
|
+
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" >> /etc/apt/sources.list.d/pgdg.list \
|
4
|
+
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
5
|
+
&& apt-get update -qq \
|
6
|
+
&& apt-get install -y build-essential libpq-dev postgresql-client-9.5 postgresql-contrib-9.5
|
7
|
+
|
8
|
+
|
9
|
+
ENV APP_PATH=/app BUNDLE_JOBS=4 BUNDLE_RETRY=3 BUNDLE_PATH=/gems
|
10
|
+
|
11
|
+
RUN mkdir ${APP_PATH}
|
12
|
+
WORKDIR ${APP_PATH}
|
13
|
+
|
14
|
+
ADD . ${APP_PATH}
|
15
|
+
|
16
|
+
CMD bundle check || bundle install; bundle exec rspec spec
|
data/README.md
CHANGED
@@ -36,6 +36,13 @@ Or install it yourself as:
|
|
36
36
|
|
37
37
|
## Usage with Rails
|
38
38
|
|
39
|
+
Application must have sql as schema format to properly dump OID type.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# config/application.rb
|
43
|
+
config.active_record.schema_format = :sql
|
44
|
+
```
|
45
|
+
|
39
46
|
Generate migration for table were to store list of attachments.
|
40
47
|
|
41
48
|
$ rails g refile:postgres:migration
|
@@ -48,6 +55,11 @@ Generate initializer and set Refile::Postgres as `store` backend.
|
|
48
55
|
|
49
56
|
$ rails g refile:postgres:initializer
|
50
57
|
|
58
|
+
## Upgrade to 1.3.0
|
59
|
+
|
60
|
+
If you have been using refile-postgres before 1.3.0 version then please follow [upgrade guide](https://github.com/krists/refile-postgres/blob/master/migration_to_1_3_0.md)
|
61
|
+
|
62
|
+
|
51
63
|
## Contributing
|
52
64
|
|
53
65
|
1. Fork it ( https://github.com/krists/refile-postgres/fork )
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
app:
|
2
|
+
build: .
|
3
|
+
links:
|
4
|
+
- postgres
|
5
|
+
volumes_from:
|
6
|
+
- gems
|
7
|
+
environment:
|
8
|
+
POSTGRES_HOST: postgres
|
9
|
+
POSTGRES_PORT: 5432
|
10
|
+
POSTGRES_DB: refile_test
|
11
|
+
POSTGRES_USER: refile_postgres_test_user
|
12
|
+
POSTGRES_PASSWORD: refilepostgres
|
13
|
+
postgres:
|
14
|
+
environment:
|
15
|
+
POSTGRES_USER: refile_postgres_test_user
|
16
|
+
POSTGRES_PASSWORD: refilepostgres
|
17
|
+
POSTGRES_DB: refile_test
|
18
|
+
image: postgres:9.5.1
|
19
|
+
gems:
|
20
|
+
image: busybox
|
21
|
+
volumes:
|
22
|
+
- /gems
|
@@ -1,13 +1,33 @@
|
|
1
1
|
class Create<%= table_name.camelize %> < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
execute %Q{
|
4
|
+
CREATE TABLE <%= table_name %> (
|
5
|
+
id integer NOT NULL,
|
6
|
+
oid oid NOT NULL,
|
7
|
+
namespace character varying NOT NULL,
|
8
|
+
created_at timestamp without time zone DEFAULT ('now'::text)::timestamp without time zone
|
9
|
+
);
|
10
|
+
|
11
|
+
CREATE SEQUENCE <%= table_name %>_id_seq
|
12
|
+
START WITH 1
|
13
|
+
INCREMENT BY 1
|
14
|
+
NO MINVALUE
|
15
|
+
NO MAXVALUE
|
16
|
+
CACHE 1;
|
17
|
+
|
18
|
+
ALTER SEQUENCE <%= table_name %>_id_seq OWNED BY <%= table_name %>.id;
|
19
|
+
|
20
|
+
ALTER TABLE ONLY <%= table_name %> ALTER COLUMN id SET DEFAULT nextval('<%= table_name %>_id_seq'::regclass);
|
21
|
+
|
22
|
+
ALTER TABLE ONLY <%= table_name %> ADD CONSTRAINT <%= table_name %>_pkey PRIMARY KEY (id);
|
23
|
+
|
24
|
+
CREATE INDEX index_<%= table_name %>_on_namespace ON <%= table_name %> USING btree (namespace);
|
25
|
+
|
26
|
+
CREATE INDEX index_<%= table_name %>_on_oid ON <%= table_name %> USING btree (oid);
|
27
|
+
}
|
7
28
|
end
|
8
29
|
|
9
30
|
def drop
|
10
|
-
remove_index :<%= table_name %>, :namespace
|
11
31
|
drop_table :<%= table_name %>
|
12
32
|
end
|
13
33
|
end
|
@@ -46,7 +46,7 @@ module Refile
|
|
46
46
|
connection.lo_write(handle, buffer)
|
47
47
|
end
|
48
48
|
uploadable.close
|
49
|
-
connection.exec_params("INSERT INTO #{registry_table} VALUES ($1::
|
49
|
+
connection.exec_params("INSERT INTO #{registry_table} (oid, namespace) VALUES ($1::oid, $2::varchar);", [oid, namespace])
|
50
50
|
Refile::File.new(self, oid.to_s)
|
51
51
|
ensure
|
52
52
|
connection.lo_close(handle)
|
@@ -80,9 +80,9 @@ module Refile
|
|
80
80
|
connection.exec_params(%{
|
81
81
|
SELECT count(*) FROM #{registry_table}
|
82
82
|
INNER JOIN #{PG_LARGE_OBJECT_METADATA_TABLE}
|
83
|
-
ON #{registry_table}.
|
83
|
+
ON #{registry_table}.oid = #{PG_LARGE_OBJECT_METADATA_TABLE}.oid
|
84
84
|
WHERE #{registry_table}.namespace = $1::varchar
|
85
|
-
AND #{registry_table}.
|
85
|
+
AND #{registry_table}.oid = $2::integer;
|
86
86
|
}, [namespace, id.to_s.to_i]) do |result|
|
87
87
|
result[0]["count"].to_i > 0
|
88
88
|
end
|
@@ -101,8 +101,14 @@ module Refile
|
|
101
101
|
if exists?(id)
|
102
102
|
with_connection do |connection|
|
103
103
|
ensure_in_transaction(connection) do
|
104
|
-
connection.
|
105
|
-
|
104
|
+
rez = connection.exec_params(%{
|
105
|
+
SELECT * FROM #{registry_table}
|
106
|
+
WHERE #{registry_table}.oid = $1::integer
|
107
|
+
LIMIT 1
|
108
|
+
}, [id.to_s.to_i])
|
109
|
+
oid = rez[0]['oid'].to_i
|
110
|
+
connection.lo_unlink(oid)
|
111
|
+
connection.exec_params("DELETE FROM #{registry_table} WHERE oid = $1::integer;", [oid])
|
106
112
|
end
|
107
113
|
end
|
108
114
|
end
|
@@ -114,12 +120,12 @@ module Refile
|
|
114
120
|
with_connection do |connection|
|
115
121
|
ensure_in_transaction(connection) do
|
116
122
|
connection.exec_params(%{
|
117
|
-
SELECT
|
118
|
-
INNER JOIN #{PG_LARGE_OBJECT_METADATA_TABLE} ON #{registry_table}.
|
123
|
+
SELECT #{registry_table}.oid FROM #{registry_table}
|
124
|
+
INNER JOIN #{PG_LARGE_OBJECT_METADATA_TABLE} ON #{registry_table}.oid = #{PG_LARGE_OBJECT_METADATA_TABLE}.oid
|
119
125
|
WHERE #{registry_table}.namespace = $1::varchar;
|
120
126
|
}, [namespace]) do |result|
|
121
127
|
result.each_row do |row|
|
122
|
-
connection.lo_unlink(row[0].
|
128
|
+
connection.lo_unlink(row[0].to_i)
|
123
129
|
end
|
124
130
|
end
|
125
131
|
connection.exec_params("DELETE FROM #{registry_table} WHERE namespace = $1::varchar;", [namespace])
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Migration to refile-postgres version 1.3.0
|
2
|
+
|
3
|
+
Please check [issue](https://github.com/krists/refile-postgres/issues/9) for more details.
|
4
|
+
|
5
|
+
1) Change Rails schema dump format to SQL in your `config/application.rb` file
|
6
|
+
```ruby
|
7
|
+
# Use structure.sql instead of schema.rb
|
8
|
+
config.active_record.schema_format = :sql
|
9
|
+
```
|
10
|
+
2) Change version number in Gemfile
|
11
|
+
```ruby
|
12
|
+
gem 'refile-postgres', '~> 1.3.0'
|
13
|
+
```
|
14
|
+
3) Create Rails migration
|
15
|
+
```
|
16
|
+
rails g migration refile_postgres_migration_to_1_3_0
|
17
|
+
```
|
18
|
+
4) Add content to migration
|
19
|
+
```ruby
|
20
|
+
class RefilePostgresMigrationTo130 < ActiveRecord::Migration
|
21
|
+
def up
|
22
|
+
execute <<-SQL
|
23
|
+
DROP INDEX index_refile_attachments_on_namespace;
|
24
|
+
ALTER TABLE refile_attachments RENAME TO old_refile_attachments;
|
25
|
+
ALTER TABLE ONLY old_refile_attachments RENAME CONSTRAINT refile_attachments_pkey TO old_refile_attachments_pkey;
|
26
|
+
CREATE TABLE refile_attachments (
|
27
|
+
id integer NOT NULL,
|
28
|
+
oid oid NOT NULL,
|
29
|
+
namespace character varying NOT NULL,
|
30
|
+
created_at timestamp without time zone DEFAULT ('now'::text)::timestamp without time zone
|
31
|
+
);
|
32
|
+
ALTER TABLE ONLY refile_attachments ADD CONSTRAINT refile_attachments_pkey PRIMARY KEY (id);
|
33
|
+
ALTER SEQUENCE refile_attachments_id_seq RESTART OWNED BY refile_attachments.id;
|
34
|
+
ALTER TABLE ONLY refile_attachments ALTER COLUMN id SET DEFAULT nextval('refile_attachments_id_seq'::regclass);
|
35
|
+
INSERT INTO refile_attachments (oid, namespace) SELECT id, namespace FROM old_refile_attachments;
|
36
|
+
CREATE INDEX index_refile_attachments_on_namespace ON refile_attachments USING btree (namespace);
|
37
|
+
CREATE INDEX index_refile_attachments_on_oid ON refile_attachments USING btree (oid);
|
38
|
+
DROP TABLE old_refile_attachments;
|
39
|
+
SQL
|
40
|
+
end
|
41
|
+
|
42
|
+
def down
|
43
|
+
raise ActiveRecord::IrreversibleMigration
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
5) Now it is safe to run [vacuumlo](http://www.postgresql.org/docs/9.5/static/vacuumlo.html)
|
@@ -8,7 +8,7 @@ describe Refile::Postgres::Backend do
|
|
8
8
|
context "when not using procs and providing PG::Connection directly" do
|
9
9
|
let(:connection_or_proc) { connection }
|
10
10
|
it "reuses the same PG::Connection" do
|
11
|
-
expect(backend.with_connection { |c| c.db }).to eq(
|
11
|
+
expect(backend.with_connection { |c| c.db }).to eq(TEST_DB_NAME)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -25,7 +25,7 @@ describe Refile::Postgres::Backend do
|
|
25
25
|
context "when lambda does yield a PG::Connection" do
|
26
26
|
let(:connection_or_proc) { lambda { |&blk| blk.call(connection) } }
|
27
27
|
it "is usable in queries" do
|
28
|
-
expect(backend.with_connection { |c| c.db }).to eq(
|
28
|
+
expect(backend.with_connection { |c| c.db }).to eq(TEST_DB_NAME)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -64,6 +64,18 @@ describe Refile::Postgres::Backend do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
describe "Orphaned large object cleaning" do
|
68
|
+
let(:connection_or_proc) { test_connection }
|
69
|
+
let(:backend) { Refile::Postgres::Backend.new(connection_or_proc, max_size: 10000 ) }
|
70
|
+
it "does not garbage collect attachments after vacuumlo call" do
|
71
|
+
uploadable = File.open(File.expand_path(__FILE__))
|
72
|
+
file = backend.upload(uploadable)
|
73
|
+
expect(backend.exists?(file.id)).to eq(true)
|
74
|
+
run_vacuumlo
|
75
|
+
expect(backend.exists?(file.id)).to eq(true)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
67
79
|
context "Refile Provided tests" do
|
68
80
|
let(:connection_or_proc) { connection }
|
69
81
|
it_behaves_like :backend
|
data/spec/spec_helper.rb
CHANGED
@@ -8,30 +8,59 @@ require "refile/spec_helper"
|
|
8
8
|
require "pg"
|
9
9
|
require "pry"
|
10
10
|
require "refile/postgres"
|
11
|
+
require "open3"
|
11
12
|
|
12
13
|
WebMock.disable!(:except => [:codeclimate_test_reporter])
|
13
14
|
|
15
|
+
TEST_DB_NAME = ENV.fetch('POSTGRES_DB', 'refile_test')
|
16
|
+
TEST_DB_HOST = ENV.fetch('POSTGRES_HOST','localhost')
|
17
|
+
TEST_DB_USER = ENV.fetch('POSTGRES_USER','refile_postgres_test_user')
|
18
|
+
TEST_DB_PASSWD = ENV.fetch('POSTGRES_PASSWORD','refilepostgres')
|
14
19
|
module DatabaseHelpers
|
15
20
|
def test_connection
|
16
|
-
@@connection ||= PG.connect(host:
|
21
|
+
@@connection ||= PG.connect(host: TEST_DB_HOST, dbname: TEST_DB_NAME, user: TEST_DB_USER, password: TEST_DB_PASSWD)
|
17
22
|
end
|
18
23
|
|
19
|
-
def create_registy_table
|
20
|
-
test_connection.exec %{
|
21
|
-
|
22
|
-
(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
)
|
27
|
-
WITH(
|
28
|
-
OIDS=FALSE
|
24
|
+
def create_registy_table(name = Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE)
|
25
|
+
test_connection.exec %Q{
|
26
|
+
DROP TABLE IF EXISTS #{name};
|
27
|
+
CREATE TABLE #{name} (
|
28
|
+
id integer NOT NULL,
|
29
|
+
oid oid NOT NULL,
|
30
|
+
namespace character varying NOT NULL,
|
31
|
+
created_at timestamp without time zone DEFAULT ('now'::text)::timestamp without time zone
|
29
32
|
);
|
33
|
+
|
34
|
+
CREATE SEQUENCE #{name}_id_seq
|
35
|
+
START WITH 1
|
36
|
+
INCREMENT BY 1
|
37
|
+
NO MINVALUE
|
38
|
+
NO MAXVALUE
|
39
|
+
CACHE 1;
|
40
|
+
|
41
|
+
ALTER SEQUENCE #{name}_id_seq OWNED BY #{name}.id;
|
42
|
+
|
43
|
+
ALTER TABLE ONLY #{name} ALTER COLUMN id SET DEFAULT nextval('#{name}_id_seq'::regclass);
|
44
|
+
|
45
|
+
ALTER TABLE ONLY #{name} ADD CONSTRAINT #{name}_pkey PRIMARY KEY (id);
|
46
|
+
|
47
|
+
CREATE INDEX index_#{name}_on_namespace ON #{name} USING btree (namespace);
|
48
|
+
|
49
|
+
CREATE INDEX index_#{name}_on_oid ON #{name} USING btree (oid);
|
30
50
|
}
|
31
51
|
end
|
32
52
|
|
33
|
-
def drop_registry_table
|
34
|
-
test_connection.exec %{ DROP TABLE IF EXISTS #{
|
53
|
+
def drop_registry_table(name = Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE)
|
54
|
+
test_connection.exec %{ DROP TABLE IF EXISTS #{name} CASCADE; }
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_vacuumlo
|
58
|
+
command = "export PGPASSWORD=#{TEST_DB_PASSWD}; vacuumlo -h #{TEST_DB_HOST} -U #{TEST_DB_USER} -w -v #{TEST_DB_NAME}"
|
59
|
+
Open3.popen3(command) do |stdin, stdout, stderr, thread|
|
60
|
+
stdin.close
|
61
|
+
IO.copy_stream(stderr, $stderr)
|
62
|
+
IO.copy_stream(stdout, $stdout)
|
63
|
+
end
|
35
64
|
end
|
36
65
|
end
|
37
66
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refile-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krists Ozols
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: refile
|
@@ -160,20 +160,12 @@ extra_rdoc_files: []
|
|
160
160
|
files:
|
161
161
|
- ".gitignore"
|
162
162
|
- ".travis.yml"
|
163
|
-
-
|
164
|
-
- Berksfile.lock
|
163
|
+
- Dockerfile
|
165
164
|
- Gemfile
|
166
165
|
- LICENSE.txt
|
167
166
|
- README.md
|
168
167
|
- Rakefile
|
169
|
-
-
|
170
|
-
- cookbooks/dev-essential/metadata.rb
|
171
|
-
- cookbooks/dev-essential/recipes/default.rb
|
172
|
-
- cookbooks/postgresql/metadata.rb
|
173
|
-
- cookbooks/postgresql/recipes/default.rb
|
174
|
-
- cookbooks/ruby/attributes/default.rb
|
175
|
-
- cookbooks/ruby/metadata.rb
|
176
|
-
- cookbooks/ruby/recipes/default.rb
|
168
|
+
- docker-compose.yml
|
177
169
|
- lib/generators/refile/postgres/initializer/USAGE
|
178
170
|
- lib/generators/refile/postgres/initializer/initializer_generator.rb
|
179
171
|
- lib/generators/refile/postgres/initializer/templates/refile.rb
|
@@ -185,6 +177,7 @@ files:
|
|
185
177
|
- lib/refile/postgres/backend/reader.rb
|
186
178
|
- lib/refile/postgres/smart_transaction.rb
|
187
179
|
- lib/refile/postgres/version.rb
|
180
|
+
- migration_to_1_3_0.md
|
188
181
|
- postgres-setup
|
189
182
|
- refile-postgres.gemspec
|
190
183
|
- spec/refile/postgres/backend_spec.rb
|
data/Berksfile
DELETED
data/Berksfile.lock
DELETED
data/Vagrantfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant.configure(2) do |config|
|
5
|
-
config.vm.box = "chef/ubuntu-14.04"
|
6
|
-
|
7
|
-
config.ssh.forward_agent = true
|
8
|
-
config.vm.synced_folder ".", "/home/vagrant/project"
|
9
|
-
|
10
|
-
config.vm.provider "virtualbox" do |vb|
|
11
|
-
vb.memory = "2048"
|
12
|
-
vb.cpus = 2
|
13
|
-
end
|
14
|
-
|
15
|
-
config.berkshelf.enabled = false
|
16
|
-
|
17
|
-
config.vm.provision "chef_solo" do |chef|
|
18
|
-
chef.cookbooks_path = ["cookbooks", "berks-cookbooks"]
|
19
|
-
chef.log_level = :info
|
20
|
-
chef.add_recipe "dev-essential"
|
21
|
-
chef.add_recipe "ruby"
|
22
|
-
chef.add_recipe "postgresql"
|
23
|
-
end
|
24
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
apt_repository 'postgresql' do
|
2
|
-
uri 'http://apt.postgresql.org/pub/repos/apt/'
|
3
|
-
distribution 'trusty-pgdg'
|
4
|
-
components ['main']
|
5
|
-
key 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
|
6
|
-
action :add
|
7
|
-
end
|
8
|
-
|
9
|
-
%w{
|
10
|
-
postgresql-9.4
|
11
|
-
postgresql-client-9.4
|
12
|
-
postgresql-contrib-9.4
|
13
|
-
postgresql-server-dev-9.4
|
14
|
-
}.each do |p|
|
15
|
-
package p do
|
16
|
-
action :install
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
execute 'Create vagrant postgresql user' do
|
21
|
-
guard = <<-EOH
|
22
|
-
psql -U postgres -c "select * from pg_user where
|
23
|
-
usename='vagrant'" |
|
24
|
-
grep -c vagrant
|
25
|
-
EOH
|
26
|
-
user 'postgres'
|
27
|
-
command %{psql -U postgres -c "CREATE ROLE vagrant PASSWORD 'vagrant' SUPERUSER CREATEDB LOGIN;"}
|
28
|
-
not_if guard, user: 'postgres'
|
29
|
-
end
|
data/cookbooks/ruby/metadata.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
|
2
|
-
remote_file "/tmp/ruby-install-#{node[:ruby_install][:version]}.tar.gz" do
|
3
|
-
source "https://github.com/postmodern/ruby-install/archive/v#{node[:ruby_install][:version]}.tar.gz"
|
4
|
-
action :create
|
5
|
-
end
|
6
|
-
|
7
|
-
bash "Extract ruby-install source code" do
|
8
|
-
code <<-EOH
|
9
|
-
cd /tmp
|
10
|
-
tar -zxvf ruby-install-#{node[:ruby_install][:version]}.tar.gz
|
11
|
-
EOH
|
12
|
-
not_if { ::File.exists?("/tmp/ruby-install-#{node[:ruby_install][:version]}") }
|
13
|
-
end
|
14
|
-
|
15
|
-
execute 'Install ruby-install' do
|
16
|
-
cwd "/tmp/ruby-install-#{node[:ruby_install][:version]}"
|
17
|
-
command 'make install'
|
18
|
-
action :run
|
19
|
-
not_if { ::File.exists?("/usr/local/bin/ruby-install") }
|
20
|
-
end
|
21
|
-
|
22
|
-
remote_file "/tmp/chruby-#{node[:chruby][:version]}.tar.gz" do
|
23
|
-
source "https://github.com/postmodern/chruby/archive/v#{node[:chruby][:version]}.tar.gz"
|
24
|
-
action :create
|
25
|
-
end
|
26
|
-
|
27
|
-
bash "Extract chruby source code" do
|
28
|
-
code <<-EOH
|
29
|
-
cd /tmp
|
30
|
-
tar -zxvf chruby-#{node[:chruby][:version]}.tar.gz
|
31
|
-
EOH
|
32
|
-
not_if { ::File.exists?("/tmp/chruby-#{node[:chruby][:version]}") }
|
33
|
-
end
|
34
|
-
|
35
|
-
execute 'Install chruby' do
|
36
|
-
cwd "/tmp/chruby-#{node[:chruby][:version]}"
|
37
|
-
command 'make install'
|
38
|
-
action :run
|
39
|
-
not_if { ::File.exists?("/usr/local/bin/chruby") }
|
40
|
-
end
|
41
|
-
|
42
|
-
file "/etc/profile.d/chruby.sh" do
|
43
|
-
owner 'root'
|
44
|
-
group 'root'
|
45
|
-
mode '0644'
|
46
|
-
content <<-EOC
|
47
|
-
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
|
48
|
-
source /usr/local/share/chruby/chruby.sh
|
49
|
-
source /usr/local/share/chruby/auto.sh
|
50
|
-
fi
|
51
|
-
EOC
|
52
|
-
end
|