Skip to content

Instantly share code, notes, and snippets.

@linyiru
Forked from dlackty/gist:3483170
Created August 27, 2012 01:58
Show Gist options
  • Select an option

  • Save linyiru/3484999 to your computer and use it in GitHub Desktop.

Select an option

Save linyiru/3484999 to your computer and use it in GitHub Desktop.
OS X Rails Setup
#! /usr/bin/env bash
# llvm-gcc
if `type -P llvm-gcc &>/dev/null`; then
echo "Command Line Tools found."
else
echo "Command Line Tools not found."
echo "Please go https://developer.apple.com/downloads and install **Command Line Tools for Xcode**" && exit 0;
fi
# Homebrew
if `type -P brew &>/dev/null`; then
echo "Homebrew found."
else
echo "Homebrew not found. Installing..."
ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go)
echo "Put Homebrew location earlier in PATH (Bash by default)..."
echo "export PATH='/usr/local/bin:$PATH'" >> ~/.bashrc
source ~/.bashrc
brew update
fi
# rbenv
if `type -P rbenv &>/dev/null`; then
echo "rbenv found."
else
echo "rbenv not found. Installing..."
brew install rbenv
echo "Put rbenv init in shell profile (Bash by default)..."
echo "if which rbenv > /dev/null; then eval \"\$(rbenv init -)\"; fi" >> ~/.bashrc
source ~/.bashrc
fi
# Ruby 1.9.3-p194
if [[ `rbenv versions` =~ '1.9.3-p194' ]]; then
echo "Ruby 1.9.3-p194 found."
else
echo "Ruby 1.9.3-p194 not found. Installing..."
# ruby-build
if `type -P ruby-build &>/dev/null`; then
echo "ruby-build found."
else
echo "ruby-build not found. Installing..."
brew install ruby-build
fi
rbenv install 1.9.3-p194
fi
echo "Set current ruby version to 1.9.3-p194"
rbenv global 1.9.3-p194
# MySQL
if `type -P mysqld &>/dev/null`; then
echo "MySQL found."
else
echo "MySQL not found. Installing..."
brew install mysql
fi
# Starting MySQL
if [[ `ps x` =~ 'mysqld' ]]; then
echo "MySQL process found."
else
echo "MySQL process not found. Setting up..."
if [[ -e ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist ]]; then
echo "MySQL launch agent plist found."
else
echo "MySQL launch agent plist not found. Installing..."
mkdir -p ~/Library/LaunchAgents
cp `ls /usr/local/Cellar/redis/*/homebrew.mxcl.mysql.plist | tail -1` ~/Library/LaunchAgents/
fi
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
fi
# ImageMagick
if `type -P convert &>/dev/null`; then
echo "ImageMagick found."
else
echo "ImageMagick not found. Installing..."
brew install imagemagick
fi
# Redis
if `type -P redis-server &>/dev/null`; then
echo "Redis found."
else
echo "Redis not found. Installing..."
brew install redis
fi
# Starting Redis
if [[ `ps x` =~ 'redis-server' ]]; then
echo "Redis process found."
else
echo "Redis process not found. Setting up..."
if [[ -e ~/Library/LaunchAgents/homebrew.mxcl.redis.plist ]]; then
echo "Redis launch agent plist found."
else
echo "Redis launch agent plist not found. Installing..."
mkdir -p ~/Library/LaunchAgents
cp `ls /usr/local/Cellar/redis/*/homebrew.mxcl.redis.plist | tail -1` ~/Library/LaunchAgents/
fi
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
fi
# Bundler
if `type -P bundle &>/dev/null`; then
echo "Bundler found."
else
echo "Bundler not found. Installing..."
gem install bundler --no-rdoc --no-ri
rbenv rehash
fi
# Rails
if `type -P rails &>/dev/null`; then
echo "Rails found."
else
echo "Rails not found. Installing..."
gem install rails --no-rdoc --no-ri
rbenv rehash
fi
# Powder
if `type -P powder &>/dev/null`; then
echo "Powder found."
else
echo "Powder not found. Installing..."
gem install powder
rbenv rehash
fi
# Pow
if [[ `powder up` =~ 'missing' ]]; then
echo "Pow not found. Installing..."
powder install
else
echo "Pow was already started."
fi
echo "Everyting done. You're ready to go!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment