setup 883 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env ruby
  2. require 'fileutils'
  3. include FileUtils
  4. # path to your application root.
  5. APP_ROOT = File.expand_path('..', __dir__)
  6. def system!(*args)
  7. system(*args) || abort("\n== Command #{args} failed ==")
  8. end
  9. chdir APP_ROOT do
  10. # This script is a starting point to setup your application.
  11. # Add necessary setup steps to this file.
  12. puts '== Installing dependencies =='
  13. system! 'gem install bundler --conservative'
  14. system('bundle check') || system!('bundle install')
  15. # puts "\n== Copying sample files =="
  16. # unless File.exist?('config/database.yml')
  17. # cp 'config/database.yml.sample', 'config/database.yml'
  18. # end
  19. puts "\n== Preparing database =="
  20. system! 'bin/rails db:setup'
  21. puts "\n== Removing old logs and tempfiles =="
  22. system! 'bin/rails log:clear tmp:clear'
  23. puts "\n== Restarting application server =="
  24. system! 'bin/rails restart'
  25. end