Skip to content

Instantly share code, notes, and snippets.

@joelmoss
Created May 10, 2012 08:40
Show Gist options
  • Select an option

  • Save joelmoss/2651918 to your computer and use it in GitHub Desktop.

Select an option

Save joelmoss/2651918 to your computer and use it in GitHub Desktop.
Short setup script for rails projects
#!/bin/sh
set -e
export PATH="$(dirname "$0")/../bin:$PATH" # Use binstubs
if [ "$1" = "-v" ]; then
exec 3>&1
else
exec 3>/dev/null
fi
# Wipe out logs and scss cache.
echo "Cleaning out old logs and tempfiles"
{ rm -f log/*
rm -rf tmp/cache
} >&3 2>&1
# Install dependencies
echo "Installing libraries and plugins"
{ gem list -i bundler || gem install bundler && rbenv rehash
bundle install && rbenv rehash
} >&3 2>&1
# Wipe and load the database unless KEEPDB=1 env var is set.
if [ -z "$KEEPDB" ]; then
echo "Reloading the database"
{ rake db:create:all db:drop:all db:setup db:fixtures:load --trace
rake db:test:prepare --trace
} >&3 2>&1
fi
echo "Restarting Pow"
touch tmp/restart.txt
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment