Skip to content

Instantly share code, notes, and snippets.

@davidlee
Created May 15, 2012 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlee/2699823 to your computer and use it in GitHub Desktop.
Save davidlee/2699823 to your computer and use it in GitHub Desktop.
rbenv-global.sh
#!/bin/bash
DEFAULT_VERSION='1.9.3-p194'
if [ -z "$1" ] ;
then
echo "Usage: ruby VERSION"
echo "Example: ruby $DEFAULT_VERSION"
echo "or, just wait a sec and we'll install $DEFAULT_VERSION"
sleep 2.5
fi
export DEBIAN_FRONTEND=noninteractive # for unattended apt-get installs
apt-get install 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 ncurses-dev automake build-essential -y
export RBENV_ROOT="/usr/local/rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
# rbenv for everyone
echo "
export RBENV_ROOT=/usr/local/rbenv
if [ -d \$RBENV_ROOT ]; then
export PATH=\"\$RBENV_ROOT/bin:\$PATH\"
eval \"\$(rbenv init -)\"
fi
" >> /etc/bash.bashrc
# Install rbenv, customized from https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer
if [ ! -d "$RBENV_ROOT" ] ; then
git clone git://github.com/sstephenson/rbenv.git $RBENV_ROOT
else
pushd $RBENV_ROOT > /dev/null
echo "Pulling rbenv updates."
git pull
popd > /dev/null
fi
# Install plugins:
PLUGINS=( "sstephenson:rbenv-vars"
"sstephenson:ruby-build"
"fesplugas:rbenv-installer" )
for plugin in ${PLUGINS[@]} ; do
KEY=${plugin%%:*}
VALUE=${plugin#*:}
RBENV_PLUGIN_ROOT="${RBENV_ROOT}/plugins/$VALUE"
if [ ! -d "$RBENV_PLUGIN_ROOT" ] ; then
git clone git://github.com/$KEY/$VALUE.git $RBENV_PLUGIN_ROOT
else
pushd $RBENV_PLUGIN_ROOT > /dev/null
echo "Pulling $VALUE updates."
git pull
popd > /dev/null
fi
done
cat << EOF > .gemrc
---
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
install: --no-rdoc --no-ri
update: --no-ri --no-rdoc
EOF
mkdir -p ~/.bundle
cat << EOF > ~/.bundle/config
BUNDLE_BIN: bin
BUNDLE_SHEBANG: ruby-local-exec
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_PATH: vendor
EOF
cp -R ~/.bundle ~/.gemrc /etc/skel
eval "$(rbenv init -)"
rbenv install 1.9.3-p194
rbenv global 1.9.3-p194
rbenv rehash
gem update --system
gem install bundler rake --no-ri --no-rdoc
rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment