Created
April 14, 2016 15:49
-
-
Save unixmonkey/5ae9ce11e505cc68cffea17ea78f76b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pathname' | |
# path to your application root. | |
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
Dir.chdir APP_ROOT do | |
# This script is a starting point to setup your application. | |
# Add necessary setup steps to this file: | |
puts "== Installing system dependencies==" | |
if RUBY_PLATFORM =~ /darwin/ | |
system('ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"') unless system('which brew') | |
system('brew install postgresql') unless system('which postgres') | |
system('brew install qt') unless system('which qmake') | |
system('brew install imagemagick') unless system('which convert') | |
elsif (RUBY_PLATFORM =~ /linux/) && system('which apt-get') | |
system('sudo apt-get install postgresql postgresql-contrib libpq-dev -y') unless system('which postgres') | |
system('sudo apt-get install libqt4-dev -y') unless system('which qmake') | |
system('sudo apt-get install imagemagick libmagickwand-dev -y') unless system('which convert') | |
else | |
puts "System platform configuration not supported. Edit bin/setup to add configuration for your system and re-run bin/setup." | |
exit 1 | |
end | |
puts "\n== Installing gem dependencies ==" | |
system "gem install bundler --conservative" | |
system "bundle check || bundle install" | |
puts "\n== Copying sample files ==" | |
unless File.exist?("config/database.yml") | |
system "cp -v config/database.example.yml config/database.yml" | |
puts "Please edit config/database.yml with local database configuration and re-run bin/setup." | |
exit 1 | |
end | |
unless File.exist?("config/application.yml") | |
system "cp -v config/application.example.yml config/application.yml" | |
puts "Please edit config/application.yml with application configuration and re-run bin/setup." | |
exit 1 | |
end | |
puts "\n== Preparing database ==" | |
system "bin/rake db:setup" | |
puts "\n== Removing old logs and tempfiles ==" | |
system "rm -f log/*" | |
system "rm -rf tmp/cache" | |
puts "bin/setup all done!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment