Include the following lines at the top of your script (make sure you're
using bash
as the interpreter):
#!/usr/bin/env bash
cd "$(dirname $0)/.."
[ -f ".h" ] || curl -s -o ".h" -L https://https://gist.githubusercontent.com/gjorquera/a398ab36fd9fc49539b1ed2decf00ef0/raw/6bf500bfc5ea5adf3bb443557dc1a819655ff3e7/helpers.bash; . ".h"
Don't forget to add .cache.*
and .h
to your .gitignore
file:
echo ".cache.*" >> .gitignore
echo ".h" >> .gitignore
#!/usr/bin/env bash
cd "$(dirname $0)/.."
[ -f ".h" ] || curl -s -o ".h" -L https://gist.githubusercontent.com/gjorquera/a398ab36fd9fc49539b1ed2decf00ef0/raw/6bf500bfc5ea5adf3bb443557dc1a819655ff3e7/helpers.bash; . ".h"
RAILS_ENV=${RAILS_ENV:-development}
title "Checking system dependencies..."
ensure "which heroku" "brew install heroku-toolbelt"
ensure "which identify" "brew install imagemagick"
ensure "which phantomjs" "brew install phantomjs"
title "Setting up pow..."
ensure "which pow" "brew install pow"
ensure "test -d $HOME/.pow" "brew info pow"
ensure "echo 5000 > $HOME/.pow/kipict"
title "Setting up ruby..."
ensure "which ruby" "brew install rbenv"
ensure "which bundle" "gem install bundler"
ensure "cached Gemfile || bundle install"
title "Setting up postgres..."
ensure "which psql" "brew install postgresql"
ensure "echo '\\l' | psql postgres" "postgres -D /opt/boxen/homebrew/var/postgres"
ensure "echo '\\l' | psql postgres | grep kipict_$RAILS_ENV" \
"heroku local:run rake db:create"
ensure "cached db/migrate || heroku local:run rake db:migrate"
title "Setting up redis..."
ensure "which redis-server" "brew install redis"
ensure "redis-cli ping | grep PONG" "redis-server /opt/boxen/homebrew/etc/redis.conf"
Used to group several ensure
s under the same concept:
title "Checking system dependencies..."
Makes sure that a given command is successful and prints it's status along with a short message on error.
ensure "which identify"
ensure "test -d $HOME/.pow" "brew info pow"
Caches the contents of a file or directory, returning whether the existing cache was updated or not.
It should be used inside a ensure
to avoid running time consuming
commands if the file or directory used to run that command hasn't
changed.
ensure "cached Gemfile || bundle install"
ensure "cached db/migrate || heroku local:run rake db:migrate"