Skip to content

Instantly share code, notes, and snippets.

@jcastroc
Forked from grumpit/rbenv-install-system-wide.sh
Last active December 12, 2015 00:58
Show Gist options
  • Save jcastroc/4687250 to your computer and use it in GitHub Desktop.
Save jcastroc/4687250 to your computer and use it in GitHub Desktop.
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
#yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
# make bzip2 autoconf automake libtool bison iconv-devel git-core
# Check if Git is installed
hash git 2>&- || {
echo >&2 "Error: Git not found. Hint: Try installing the RPMForge or EPEL package repository.";
exit 1;
}
# Check if /usr/local/rbenv already exists
if [[ -d "/usr/local/rbenv" ]]; then
echo >&2 "Error: /usr/local/rbenv already exists. Aborting installation.";
exit 1;
fi
# Install rbenv
sudo git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Check if clone succesful
if [ $? -gt 0 ]; then
echo >&2 "Error: Git clone error! See above.";
exit 1;
fi
# Add rbenv to the path
sudo echo '# rbenv setup - only add RBENV PATH variables if no single user install found' > /etc/profile.d/rbenv.sh
sudo echo 'if [[ ! -d "${HOME}/.rbenv" ]]; then' >> /etc/profile.d/rbenv.sh
sudo echo ' export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
sudo echo ' export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
sudo echo ' eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
sudo echo 'fi' >> /etc/profile.d/rbenv.sh
sudo chmod +x /etc/profile.d/rbenv.sh
# Install ruby-build:
pushd /tmp
rm -rf /tmp/ruby-build
git clone https://github.com/sstephenson/ruby-build.git
# Check if clone succesful
if [ $? -gt 0 ]; then
echo >&2 "Error: Git clone error! See above.";
exit 1;
fi
cd ruby-build
sudo ./install.sh
popd
echo '---------------------------------'
echo ' rbenv installed system wide to /usr/local/rbenv'
echo ' Remember to restart your shell for the changes to take effect!'
echo '---------------------------------'
#!/bin/bash
# CentOS rbenv installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv to user home on CentOS 5/6.
if [[ -d "${HOME}/.rbenv" ]]; then
echo >&2 "Error: ${HOME}/.rbenv already exists. Aborting installation.";
exit 1;
fi
# Install rbenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to the path
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
echo '---------------------------------'
echo " rbenv installed to $HOME/.rbenv"
echo ' Remember to restart your shell for the changes to take effect!'
echo '---------------------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment