1
1
#!/usr/bin/env ruby
2
2
require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
3
5
4
6
# path to your application root.
5
- APP_ROOT = Pathname . new File . expand_path ( '../../' , __FILE__ )
7
+ APP_ROOT = Pathname . new File . expand_path ( '../../' , __FILE__ )
6
8
7
- Dir . chdir APP_ROOT do
9
+ def system! ( *args )
10
+ system ( *args ) || abort ( "\n == Command #{ args } failed ==" )
11
+ end
12
+
13
+ chdir APP_ROOT do
8
14
# This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
15
+ # Add necessary setup steps to this file.
10
16
11
- puts " == Installing dependencies =="
12
- system " gem install bundler --conservative"
13
- system " bundle check || bundle install"
17
+ puts ' == Installing dependencies =='
18
+ system! ' gem install bundler --conservative'
19
+ system ( ' bundle check' ) || system! ( ' bundle install' )
14
20
15
21
puts "\n == Copying sample files =="
16
- unless File . exist? ( " config/database.yml" )
17
- system " cp config/database.yml.postgresql_sample config/database.yml"
22
+ unless File . exist? ( ' config/database.yml' )
23
+ cp ' config/database.yml.sample' , ' config/database.yml'
18
24
end
19
25
unless File . exist? ( "config/repositories.yml" )
20
26
system "cp config/repositories.yml.sample config/repositories.yml"
@@ -24,11 +30,13 @@ Dir.chdir APP_ROOT do
24
30
end
25
31
26
32
puts "\n == Preparing database =="
27
- system "bin/ rake db:setup"
33
+ system! ' rake db:setup'
28
34
29
35
puts "\n == Removing old logs and tempfiles =="
30
- system "rm -f log/*"
31
- system "rm -rf tmp/cache"
36
+ system! 'bin/rake log:clear tmp:clear'
37
+
38
+ puts "\n == Creating tempfiles =="
39
+ system! 'rake tmp:create'
32
40
33
41
puts "\n == Restarting application server =="
34
42
system "touch tmp/restart.txt"
0 commit comments