Skip to content

Instantly share code, notes, and snippets.

@tolbkni
Created January 8, 2014 12:45
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 tolbkni/ef775a5249b36992e0aa to your computer and use it in GitHub Desktop.
Save tolbkni/ef775a5249b36992e0aa to your computer and use it in GitHub Desktop.
#!/bin/bash
PREFIX="/usr/local"
BIN_DIR="${PREFIX}/bin"
RBENV_DIR="${PREFIX}/rbenv"
RBENV_PLUGINS_DIR="${RBENV_DIR}/plugins"
RBENV_GROUP="rbenv"
# Install rbenv
pushd ${PREFIX}
git clone git://github.com/sstephenson/rbenv.git
popd
# Install ruby-build and rbenv-gem-rehash
pushd ${RBENV_PLUGINS_DIR}
git clone git://github.com/sstephenson/ruby-build.git
git clone git://github.com/sstephenson/rbenv-gem-rehash.git
popd
# make rbenv symbol link
ln -s ${RBENV_DIR}/bin/rbenv ${BIN_DIR}/rbenv
# add rbenv to profile, will be sourced in login shell
cat <<EOF > /etc/profile.d/rbenv.sh
# rbenv setup
export RBENV_ROOT=${RBENV_DIR}
eval "\$(rbenv init -)"
EOF
# source rbenv in current shell
source /etc/profile.d/rbenv.sh
# add rbenv group
groupadd $RBENV_GROUP
chgrp -R $RBENV_GROUP $RBENV_DIR
find $RBENV_DIR -type d -or -type f | grep -v .git | xargs --max-args=1 chmod g+w
# install special version of ruby
rbenv install 2.1.0
rbenv global 2.1.0
rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment