Forked from jpfuentes2/rbenv-install-system-wide.sh
Last active
August 29, 2015 14:05
-
-
Save grepwood/5062ccf48a17446807b0 to your computer and use it in GitHub Desktop.
Quieter and works on Debian as well
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
#!/bin/bash | |
# rbenv system wide installation script | |
# Forked from https://gist.github.com/jpfuentes2/2002954 | |
JOB_PID=$$ | |
# Installs rbenv system wide on CentOS 5/6 and Debian, also allows single user installs. | |
if command -v yum >/dev/null 2>&1; then | |
DISTRO="Redhat" | |
elif command -v aptitude >/dev/null 2>&1; then | |
DISTRO="Debian" | |
fi | |
# Install pre-requirements | |
if [ "$DISTRO" == "Redhat" ]; then | |
yum install -y -q 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 > rbenv.yum.$JOB_PID | |
if [ `grep -E Package.*'gcc-c\+\+|patch|readline|zlib-|zlib-devel|make|bzip2|autoconf|automake|libtool|bison|git'.*already\ installed\ and\ latest\ version rbenv.yum.$JOB_PID | wc -l` -eq "12" ]; then | |
rm -f rbenv.yum.$JOB_PID | |
else | |
echo "While installing rbenv, yum behaved differently than before groupinstalling devtools" | |
echo "Check rbenv.yum.$JOB_PID" | |
fi | |
elif [ "$DISTRO" == "Debian" ]; then | |
# Needs testing | |
aptitude install gcc patch readline readline-dev zlib1g zlib1g-dev libyaml-dev libffi-dev openssl-dev \ | |
make bzip2 autoconf automake libtool bison iconv-dev git | |
fi | |
# 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 | |
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv > git.rbenv.$JOB_PID | |
# Check if clone succesful | |
if [ $? -gt 0 ]; then | |
echo >&2 "Error: Git clone error! See above."; | |
exit 1; | |
else | |
rm -f git.rbenv.$JOB_PID | |
fi | |
# Add rbenv to the path | |
echo '# rbenv setup - only add RBENV PATH variables if no single user install found' > /etc/profile.d/rbenv.sh | |
echo 'if [[ ! -d "${HOME}/.rbenv" ]]; then' >> /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 | |
echo 'fi' >> /etc/profile.d/rbenv.sh | |
chmod +x /etc/profile.d/rbenv.sh | |
# Install ruby-build: | |
pushd /tmp | |
rm -rf /tmp/ruby-build | |
git clone git://github.com/sstephenson/ruby-build.git > git.ruby-build.$JOB_PID | |
# Check if clone succesful | |
if [ $? -gt 0 ]; then | |
echo >&2 "Error: Git clone error! See above."; | |
exit 1; | |
else | |
rm -f git.ruby-build.$JOB_PID | |
fi | |
cd ruby-build | |
./install.sh > ruby-build.install.log.$JOB_PID | |
popd | |
echo '---------------------------------' | |
echo ' rbenv installed system wide to /usr/local/rbenv' | |
echo " For your convenience, ruby-install log is in ruby-build.install.log.$JOB_PID" | |
echo ' Remember to restart your shell for the changes to take effect!' | |
echo '---------------------------------' |
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
#!/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 git://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