Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
137 lines (77 sloc) 3.81 KB
#!/usr/bin/env bash
#
# Author: Wayne E. Seguin <wayneeseguin@gmail.com>
# Licence: MIT
#
#
# This script when sourced will bootstrap a Rails development environment
# on Linux and OSX
#
# Source this file so that it will leave you in the Sites directory.
rails_version="3.0.3"
ruby_version="1.8.7"
sites_path="$HOME/Sites"
abort=false
if [[ $(id | sed -e 's/(.*//' | awk -F= '{print $2}') -eq 0 ]] ; then
printf "ERROR: This script may not be sourced as the root user."
abort=true
else
if [[ ! -d "$sites_path" ]]; then
mkdir -p "$sites_path"
fi
cd "$sites_path"
printf "#\n# Bootstrapping a Rails development environment!\n#\n"
if [[ "Linux" = "$(uname)" ]]; then
printf "#\n# Ensuring OS packges are installed, you will be prompted for your password.\n#\n"
if command -v aptitude || command -v apt-get ; then
sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
elif command -v pacman ; then
sudo pacman -S --noconfirm gcc patch curl bison zlib readline libxml2 libxslt git autoconf diffutils patch bison make
elif command -v yum ; then
sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel
sudo yum install -y iconv-devel >/dev/null 2>&1 # NOTE: For centos 5.4 final iconv-devel might not be available :(
fi
elif [[ "Darwin" = "$(uname)" ]]; then
if [[ ! -s /Library/Developer/Shared/XcodeTools.plist ]]; then
printf "Please Install XCode Tools before sourcing this environment bootstrap script."
abort=true
fi
fi
fi
if ! abort ; then
printf "Ensuring that git is installed...\n"
if command -v git ; then
printf "Found git! Moving right along.\n"
else
printf "=> Installing Git (git command not found)"
curl -L http://rvm.beginrescueend.com/install/git -o gitinstall
chmod +x "$PWD/gitinstall"
sudo bash "$PWD/gitinstall"
[[ -f gitinstall ]] && rm -f gitinstall
fi
printf "=> Installing RVM the Ruby enVironment Manager\n http://rvm.beginrescueend.com/rvm/install/\n"
curl -O -L http://rvm.beginrescueend.com/releases/rvm-install-head
chmod +x rvm-install-head
"$PWD/rvm-install-head"
[[ -f rvm-install-head ]] && rm -f rvm-install-head
printf "=> Setting up RVM to load with new shells.\n"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> "$HOME/.bash_profile"
printf "=> Loading RVM"
source ~/.rvm/scripts/rvm
printf "=> Installing Ruby 1.8.7\n More information about installing rubies can be found at http://rvm.beginrescueend.com/rubies/installing/"
rvm install $ruby_version
printf "=> Using 1.8.7 and setting it as default for new shells\n More information about Rubies can be found at http://rvm.beginrescueend.com/rubies/default/\n"
rvm use $ruby_version --default
printf "=> Installing Rails 3 to the default gemset.\n More information about gemsets can be found at http://rvm.beginrescueend.com/gemsets/\n"
gem install rails --no-rdoc --no-ri
printf "=> Installing Bundler to the global gemset.\n http://rvm.beginrescueend.com/gemsets/global/\n"
rvm gemset use global
gem install bundler --no-rdoc --no-ri
rvm gemset clear
printf "=> Installing the sqlite3 Gem.\n http://rubydoc.info/gems/sqlite3/1.3.3/frames\n"
gem install sqlite3 --no-rdoc --no-ri
printf "\nRails development environment bootstrapped, please enjoy Rails!\n"
printf "\n ~Wayne E. Seguin <wayneeseguin@gmail.com>\n"
printf "P.S. You should now be able to generate a new Rails Application in ~/Sites with the command 'rails new <name>'\n"
fi
unset ruby_version rails_version sites_path
Jump to Line
Something went wrong with that request. Please try again.