From b901ab34e7d0c7a55ac7784a9cea9e2303e339e5 Mon Sep 17 00:00:00 2001 From: Heitor Reis Date: Wed, 3 Feb 2016 09:41:35 -0200 Subject: [PATCH] Update setup --- bin/setup | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) mode change 100644 => 100755 bin/setup diff --git a/bin/setup b/bin/setup old mode 100644 new mode 100755 index db9fc79..fd0dada --- a/bin/setup +++ b/bin/setup @@ -1,5 +1,14 @@ #!/usr/bin/env ruby require 'pathname' +require 'colorize' + +def run(command) + system(command) + unless $?.exitstatus.zero? + puts "Command #{command} exited with nonzero status".red + exit 1 + end +end # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) @@ -8,22 +17,27 @@ Dir.chdir APP_ROOT do # This script is a starting point to setup your application. # Add necessary setup steps to this file: - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + puts "== Installing dependencies ==".green + run "gem install bundler --conservative" + run "bundle check || bundle install" - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" - # end + puts "\n== Copying sample files ==".green + unless File.exist?("config/database.yml") + run "cp config/database.yml.sample config/database.yml" + end - puts "\n== Preparing database ==" - system "bin/rake db:setup" + puts "\n== Preparing database ==".green + puts "\n== Create database ==".yellow + run "bin/rake db:create" + puts "\n== Run migrations ==".yellow + run "bin/rake db:migrate" + puts "\n== Run seeds (may fail if the Kalibro Configurations Service is not up and running) ==".yellow + run "bin/rake db:seed" - puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + puts "\n== Removing old logs and tempfiles ==".green + run 'bin/rake log:clear' + run 'bin/rake tmp:clear' - puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" -end \ No newline at end of file + puts "\n== Restarting application server ==".green + run "touch tmp/restart.txt" +end -- libgit2 0.21.2