Last active
May 4, 2016 14:09
-
-
Save sdorunga/913e40b07e8383c848b06e974f2ca4a6 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
HOMEBREW_INSTALL_URL=https://raw.githubusercontent.com/Homebrew/install/master/install | |
set -e | |
function already_in_path { | |
which $1 > /dev/null; | |
} | |
function set_up_ssh_keys { | |
if [ ! -f "~/.ssh/id_rsa" ]; then | |
echo "Setting up ssh keys" | |
ssh-keygen -t rsa -b 4096 -C $1 | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
echo "Public key has been copied to your clipboard" | |
echo "Please add the key to your Github account" | |
echo "SSH keys live under Settings > SSH and GPG keys" | |
pbcopy < ~/.ssh/id_rsa.pub | |
else | |
echo "SSH keys already exist" | |
fi | |
} | |
function setup_git { | |
if ! already_in_path git; then | |
echo "Setting up Git" | |
brew_install git | |
echo "What is your name" | |
read GIT_USERNAME | |
git config --global user.name $GIT_USERNAME | |
echo "What is your email" | |
read GIT_EMAIL | |
git config --global user.email $GIT_EMAIL | |
set_up_ssh_keys $GIT_EMAIL | |
else | |
echo "Git already set up, you might need to run configurations manually" | |
fi | |
} | |
function install_homebrew { | |
if ! already_in_path brew; then | |
/usr/bin/ruby -e "$(curl -fsSL $HOMEBREW_INSTALL_URL)" | |
fi | |
} | |
function brew_install { | |
if ! brew ls $1 > /dev/null; then | |
brew install $1 | |
echo "Installed $1" | |
else | |
echo "$1 already installed" | |
fi | |
} | |
function set_up_postgresql { | |
if ! already_in_path psql; then | |
brew_install homebrew/versions/postgresql94 | |
fi | |
} | |
function set_up_gettext { | |
if ! brew ls $1 > /dev/null; then | |
brew install $1 | |
brew link gettext --force | |
echo "GetText installed and force linked" | |
else | |
echo "GetText already installed and force linked" | |
fi | |
} | |
function set_up_rabbitmq { | |
rabbitmq-plugins enable rabbitmq_stomp | |
rabbitmq-plugins enable rabbitmq_management | |
} | |
function set_up_orderweb_db { | |
createdb delivery_test | |
createdb delivery_dev | |
psql -e "CREATE ROLE roo WITH PASSWORD 'b1gg3stm@rsup1@l12' SUPERUSER LOGIN CREATEDB" >> /dev/null | |
} | |
function install_ruby { | |
if ! rbenv version == *$1* > /dev/null; then | |
echo "Installing Ruby version $1" | |
rbenv install $1 | |
rbenv global $1 | |
echo "Installing bundler" | |
gem install bundler | |
echo "Installed Ruby version $1 and set as global" | |
else | |
echo "Ruby version $1 already installed" | |
fi | |
} | |
install_homebrew | |
setup_git | |
brew_install rbenv | |
brew_install ruby-build | |
brew_install redis | |
brew_install rabbitmq | |
set_up_rabbitmq | |
brew_install imagemagick | |
brew_install qt | |
brew_install phantomjs | |
brew_install node | |
brew_install openssl | |
brew link --force openssl | |
set_up_gettext | |
set_up_postgresql | |
set_up_orderweb_db | |
install_ruby "2.2.3" | |
echo "Which folder do you want to install OrderWeb in?" | |
DIRECTORY="orderweb" | |
if [ -d "$DIRECTORY" ]; then | |
echo "Directory already exists, make sure to delete it and run this script again" | |
else | |
git clone git@github.com:deliveroo/orderweb.git $DIRECTORY | |
cd $DIRECTORY | |
echo "Running npm Postinstall task" | |
npm run postinstall > /dev/null; | |
echo "Running npm Build task" | |
npm run build > /dev/null; | |
echo "Bundling" | |
bundle install > /dev/null; | |
echo "Running migrations" | |
bundle exec rake db:setup db:migrate db:refresh | |
RAILS_ENV=test bundle exec rake db:setup db:migrate db:refresh | |
echo "Preparing GeoIP information" | |
bundle exec rake geoip:download | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment