12/18/2014 - 4:20 AM

Initial setup for Ruby developers. Creating developer laptop.

Initial setup for Ruby developers. Creating developer laptop.


# Helper function.
successfully() {
  $* || (echo -e "\e[38;5;196mFAILED" 1>&2 && exit 1)

# Helper colorized function.
fancy_echo() {
  echo -e "${ORANGE}$*${CLEAR}\n"

# Install aptitude and use it.
update_system() {
  if command -v aptitude >/dev/null; then
    fancy_echo "Using aptitude ..."
    fancy_echo "Installing aptitude ..."
    successfully sudo apt-get install -y aptitude
  successfully sudo aptitude update
  successfully sudo aptitude -y dist-upgrade

# Helper function for install.
install_pkg() {
  successfully sudo aptitude install -y $1

if lsb_release -c | grep -qEv 'precise|trusty'
  fancy_echo "Sorry! we don't currently support that distro."
  exit 1;

fancy_echo "Updating system packages ..."

fancy_echo "Installing zsh ..."
  successfully sudo aptitude install -y zsh

fancy_echo "Installing oh-my-zsh ..."
  successfully curl -L http://install.ohmyz.sh | sh

fancy_echo "Changing your shell to zsh ..."
  successfully chsh -s `which zsh`

fancy_echo "Installing curl for transferring data with URL syntax ..."
  install_pkg curl

fancy_echo "Installing vim the best editor..."
  install_pkg vim

fancy_echo "Installing git, for source control management ..."
  install_pkg git

fancy_echo "Installing rvm for changing Ruby versions ..."
  install_pkg libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
  successfully curl -L https://get.rvm.io | bash -s stable
  successfully source ~/.rvm/scripts/rvm
  successfully echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
  successfully rvm install 2.1.5
  successfully rvm use 2.1.5 --default
  successfully rvm get stable
  successfully rvm requirements
  successfully echo "gem: --no-ri --no-rdoc" > ~/.gemrc
  # command curl -sSL https://rvm.io/mpapis.asc | gpg --import -

fancy_echo "Installing Ruby ..."
  successfully rvm install ruby
  successfully rvm use ruby --default

fancy_echo "Installing RubyGems ..." 
  successfully rvm rubygems current

fancy_echo "Installing Ruby on Rails ..."
  successfully gem install rails

fancy_echo "Installing NodeJS - Javascript runtime ..."
  successfully curl -sL https://deb.nodesource.com/setup | sudo bash -
  install_pkg build-essential
  install_pkg install nodejs
  install_pkg npm

fancy_echo "Installing Compass ..."
  successfully gem install sass
  successfully gem install compass

fancy_echo "Installing coffee-script ..."
  successfully npm install -g coffee-script
  successfully gem install coffee

fancy_echo "Installing PostgreSQl ..."
  install_pkg postgresql postgresql-contrib

fancy_echo "Installing Sqlite3 ..."
  install_pkg sqlite3 libsqlite3-dev

fancy_echo "Installing Yaml ..."
  install_pkg libyaml-dev

fancy_echo "Installing libraries for common gem dependencies ..."
  install_pkg libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libqtwebkit-dev

fancy_echo "Installing Postgres, a good open source relational database ..."
  install_pkg postgresql postgresql-server-dev-all

fancy_echo "Installing Redis, a good key-value database ..."
  install_pkg redis-server

fancy_echo "Installing Heroku Toolbelt ..."
  successfully wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

fancy_echo "Installing Apache2, a good open source web-server"
  install_pkg apache2

# fancy_echo "Installing passenger, an apache2 module for production ..."
#   successfully sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
#   install_pkg apt-transport-https ca-certificates
#   successfully sudo touch /etc/apt/sources.list.d/passenger.list
#   successfully sudo echo 'deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main' > /etc/apt/sources.list.d/passenger.list
#   successfully sudo chown root: /etc/apt/sources.list.d/passenger.list
#   successfully sudo chmod 644 /etc/apt/sources.list.d/passenger.list
#   successfully sudo aptitude update
#   install_pkg libapache2-mod-passenger
#   successfully sudo a2enmod passenger
#   successfully sudo service apache2 restart
#   successfully gem install passenger
#   successfully passenger-install-apache2-module

fancy_echo "Your shell will now restart to apply changes."
  exec `which zsh` -l

exit 0;