Forked from jpfuentes2/rbenv-install-system-wide.sh
Last active
December 21, 2015 08:49
-
-
Save fpauser/6281085 to your computer and use it in GitHub Desktop.
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 | |
# Ubuntu/Debian rbenv system wide installation script | |
# Forked from https://gist.github.com/1237417 | |
# Installs rbenv system wide on Debian/Ubuntu, also allows single user installs. | |
# Install pre-requirements | |
apt-get install build-essential git-core \ | |
bison openssl libssl-dev libreadline6 libreadline6-dev \ | |
curl zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev \ | |
autoconf libc6-dev ncurses-dev automake libtool | |
# Check if Git is installed | |
hash git 2>&- || { | |
echo >&2 "Error: Git not found."; | |
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 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 | |
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: | |
mkdir -p /usr/local/rbenv/plugins | |
# Check if /usr/local/rbenv/plugins/ruby-build already exists | |
if [[ -d "/usr/local/rbenv/plugins/ruby-build" ]]; then | |
echo >&2 "Error: /usr/local/rbenv/plugins/ruby-build already exists. Aborting installation."; | |
exit 1; | |
fi | |
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build | |
# Install rbenv-sudo | |
# Check if /usr/local/rbenv/plugins/rbenv-sudo already exists | |
if [[ -d "/usr/local/rbenv/plugins/rbenv-sudo" ]]; then | |
echo >&2 "Error: /usr/local/rbenv/plugins/rbenv-sudo already exists. Aborting installation."; | |
exit 1; | |
fi | |
git clone https://github.com/dcarley/rbenv-sudo.git /usr/local/rbenv/plugins/rbenv-sudo | |
echo '---------------------------------' | |
echo ' rbenv installed system wide to /usr/local/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