Last active
August 10, 2016 02:11
-
-
Save briangonzalez/8903526 to your computer and use it in GitHub Desktop.
Install rbenv systemwide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Verify Git is installed: | |
if [ ! $(which git) ]; then | |
echo "Git is not installed, can't continue." | |
exit 1 | |
fi | |
if [ -z "${RBENV_ROOT}" ]; then | |
RBENV_ROOT="/usr/local/rbenv" | |
fi | |
# Install rbenv: | |
if [ ! -d "$RBENV_ROOT" ] ; then | |
git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT | |
else | |
cd $RBENV_ROOT | |
if [ ! -d '.git' ]; then | |
git init | |
git remote add origin https://github.com/sstephenson/rbenv.git | |
fi | |
git pull origin master | |
fi | |
# Install plugins: | |
PLUGINS=( | |
sstephenson/rbenv-vars | |
sstephenson/ruby-build | |
sstephenson/rbenv-default-gems | |
sstephenson/rbenv-gem-rehash | |
fesplugas/rbenv-installer | |
fesplugas/rbenv-bootstrap | |
rkh/rbenv-update | |
rkh/rbenv-whatis | |
rkh/rbenv-use | |
carsomyr/rbenv-bundler | |
) | |
for plugin in ${PLUGINS[@]} ; do | |
KEY=${plugin%%/*} | |
VALUE=${plugin#*/} | |
RBENV_PLUGIN_ROOT="${RBENV_ROOT}/plugins/$VALUE" | |
if [ ! -d "$RBENV_PLUGIN_ROOT" ] ; then | |
git clone https://github.com/$KEY/$VALUE.git $RBENV_PLUGIN_ROOT | |
else | |
cd $RBENV_PLUGIN_ROOT | |
echo "Pulling $VALUE updates." | |
git pull | |
fi | |
done | |
echo "rbenv installed to the following location: ${RBENV_ROOT}" | |
# Add rbenv to the path: | |
echo '# rbenv setup' > /etc/profile.d/rbenv.sh | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh | |
echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh | |
chmod +x /etc/profile.d/rbenv.sh | |
source /etc/profile.d/rbenv.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment