-
Notifications
You must be signed in to change notification settings - Fork 23
/
postinstall
executable file
·55 lines (46 loc) · 1.43 KB
/
postinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env ruby
require 'yaml'
DB_ADAPTER = "postgresql"
DATABASE = "rails_france_production"
ENCODING = 'utf8'
TIMEOUT = 5000
POOL = 5
def load_dotcloud_env
YAML.load(IO.read('/home/dotcloud/environment.yml'))
end
def write_to_file(file, data)
File.open(file, 'w') do |file|
file.write data
end
end
def overwrite_database_file
env = load_dotcloud_env
database = {
'production' => {
'adapter' => DB_ADAPTER,
'database' => DATABASE,
'host' => env['DOTCLOUD_DB_SQL_HOST'],
'port' => env['DOTCLOUD_DB_SQL_PORT'].to_i,
'username' => env['DOTCLOUD_DB_SQL_LOGIN'],
'password' => env['DOTCLOUD_DB_SQL_PASSWORD'],
'encoding' => ENCODING,
'timeout' => TIMEOUT,
'pool' => POOL
}
}
write_to_file('config/database.yml', database.to_yaml)
end
def create_exceptional_file
env = load_dotcloud_env
exceptional = {
'api-key' => env['EXCEPTIONAL_API_KEY']
}
write_to_file('config/exceptional.yml', exceptional.to_yaml)
end
puts '=== Start to overwrite database.yml ==='
overwrite_database_file
puts '=== Finished overwriting! ==='
puts '=== Creating exceptional.yml ==='
create_exceptional_file
puts '=== Finished exceptional.yml ==='
`cd /home/dotcloud/current && bundle exec whenever -c && cd /home/dotcloud/current && bundle exec rake db:migrate && cd /home/dotcloud/current && bundle exec whenever -i && cd /home/dotcloud/current && bundle exec rake assets:precompile`