2013-02-06

Ubuntu ruby and rails development setup script

I've been configuring ubuntu for ruby and rails development for a while now, so I started maintaining a bash script to help in the process, here's the github link:

At the time of posting I have been running this on ubuntu 12.10

https://github.com/ELouisYoung/init-ubuntu

Feel free to take a peek.  There's still some stuff specific to me in there, so edit it before running.

Foe SEO purposes I will paste the current version of the script here:


#! /bin/bash
#
#  Written from scratch by Eric Young
#  Do whatever you want with it.
#

echo "executing with $SHELL"
echo "Installing git..."
sudo apt-get install -y git

#create .files directory so we can check if it's empty or not
DOTFILES="$HOME/.files"
mkdir -p $DOTFILES

if [ "$(ls -A $DOTFILES)" ]
then
  echo "You already have the .files, lets see if there's an update"
  cd $DOTFILES
  git pull --rebase
else
  echo "You dont have the .files, lets clone the repo"
  cd $DOTFILES
  git clone git@github.com:ELouisYoung/dotfiles.git .
fi

#make symlinks
SYMFILES=( .tmux.conf .vimrc .gitconfig .zshrc .gemrc )

for SYMFILE in ${SYMFILES[@]}
do
  echo "Working on $SYMFILE --"
  if [ -e "$HOME/$SYMFILE" ]
  then
    "echo that file already exists, is it a symlink?"
    if [ -L "$HOME/$SYMFILE" ]
    then
      echo "Yep, it's a symlink, assuming it's what you want"
      echo "You already have $SYMFILE symlinked, doing nothing"
    else
      echo "Nope, it's a not a symlink, backing it up and linking the sym from .files"
      echo "Your pre-existing $SYMFILE file is being moved to ~/$SYMFILE.moved"
      mv "$HOME/$SYMFILE" "$HOME/$SYMFILE.moved"
      ln -s "$HOME/.files/$SYMFILE" $HOME
    fi
  else
    echo "$SYMFILE was not linked, doing it now"
    ln -s "$HOME/.files/$SYMFILE" $HOME
  fi
done

#purge the undesirables
sudo apt-get purge -y -qq\
 libreoffice* thunderbird pidgin

sudo apt-get install -y\
 vim-gnome\
 tmux\
 xclip\
 build-essential\
 openssl\
 libreadline6\
 libreadline6-dev\
 libmagickwand-dev\
 libterm-readkey-perl\
 curl\
 zlib1g\
 zlib1g-dev\
 libssl-dev\
 libyaml-dev\
 libsqlite3-dev\
 sqlite3\
 libxml2-dev\
 libxslt-dev\
 autoconf\
 libc6-dev\
 ncurses-dev\
 automake\
 libtool\
 bison\
 pkg-config\
 zsh\
 openjdk-7-jdk\
 vlc\
 htop\
 postgresql\
 postgresql-server-dev-9.1\
 libpq-dev\
 ia32-libs\
 libcurl4-gnutls-dev\
 gitk\
 chromium-browser\
 chromium-codecs-ffmpeg-extra\
 redis-server\
 exuberant-ctags\
 ack\
 dnsmasq\
 mongodb


#rbenv
if [ -d "$HOME/.rbenv" ]
then
  echo "You already have rbenv"
else
  git clone git://github.com/sstephenson/rbenv.git "$HOME/.rbenv"
fi

#heroku toolbelt
if [ -e "/usr/local/heroku/bin/heroku" ]
then
  echo "You already have the heroku toolbelt"
else
  echo "Installing heroku toolbelt, will ask for password"
  wget -qO- https://toolbelt.heroku.com/install.sh | sh
fi

#vim Vundle prep
if [ -d "$HOME/.vim/bundle/vundle" ]
then
  echo "You already have Vundle, doing nothing, assuming you have set it up"
else
  echo "PRESS ENTER WHEN VIM EXECUTES"
  git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
  vim +BundleInstall +qall
fi