setup 909 Bytes
Newer Older
Eugen Rochko's avatar
Eugen Rochko committed
1
#!/usr/bin/env ruby
Eugen Rochko's avatar
Eugen Rochko committed
2 3
require 'fileutils'
include FileUtils
Eugen Rochko's avatar
Eugen Rochko committed
4 5

# path to your application root.
6
APP_ROOT = File.expand_path('..', __dir__)
Eugen Rochko's avatar
Eugen Rochko committed
7

Eugen Rochko's avatar
Eugen Rochko committed
8 9 10 11 12
def system!(*args)
  system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
Eugen Rochko's avatar
Eugen Rochko committed
13
  # This script is a starting point to setup your application.
Eugen Rochko's avatar
Eugen Rochko committed
14
  # Add necessary setup steps to this file.
Eugen Rochko's avatar
Eugen Rochko committed
15

Eugen Rochko's avatar
Eugen Rochko committed
16 17 18
  puts '== Installing dependencies =='
  system! 'gem install bundler --conservative'
  system('bundle check') || system!('bundle install')
19
  system!('yarn install')
Eugen Rochko's avatar
Eugen Rochko committed
20 21

  # puts "\n== Copying sample files =="
Eugen Rochko's avatar
Eugen Rochko committed
22 23
  # unless File.exist?('config/database.yml')
  #   cp 'config/database.yml.sample', 'config/database.yml'
Eugen Rochko's avatar
Eugen Rochko committed
24 25 26
  # end

  puts "\n== Preparing database =="
Eugen Rochko's avatar
Eugen Rochko committed
27
  system! 'bin/rails db:setup'
Eugen Rochko's avatar
Eugen Rochko committed
28 29

  puts "\n== Removing old logs and tempfiles =="
Eugen Rochko's avatar
Eugen Rochko committed
30
  system! 'bin/rails log:clear tmp:clear'
Eugen Rochko's avatar
Eugen Rochko committed
31 32

  puts "\n== Restarting application server =="
Eugen Rochko's avatar
Eugen Rochko committed
33
  system! 'bin/rails restart'
Eugen Rochko's avatar
Eugen Rochko committed
34
end