Skip to content

Instantly share code, notes, and snippets.

@maxmeyer

maxmeyer/ruby_install.sh

Last active Aug 29, 2015
Embed
What would you like to do?
#!/bin/bash
## MAKE SURE YOU'VE INSTALLED EPEL
# See http://dokuwiki.nausch.org/doku.php/centos:epel6 (German) for a good guide
##
# development tools
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
# ruby
version=2.1.1
if [ "$(/usr/local/bin/ruby -e "print RUBY_VERSION")" != $version ]; then
cd /usr/local/src
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-$version.tar.gz
tar zxvf ruby-$version.tar.gz
cd ruby-$version
./configure
make
make install
fi
# ruby-gems
version=2.2.2
if [ "$(/usr/local/bin/gem --version)" != $version ]; then
cd ..
wget http://production.cf.rubygems.org/rubygems/rubygems-$version.tgz
tar zxvf rubygems-$version.tgz
cd rubygems-$version
/usr/local/bin/ruby setup.rb
fi
# puppet
if [ -z "$(/usr/local/bin/gem list -l puppet)" ]; then
/usr/local/bin/gem install bundler puppet ruby-shadow --no-ri --no-rdoc
fi
file=/etc/profile.d/ruby.sh
if [ ! -f $file ]; then
cat > $file << 'EOS'
export GEM_ROOT=$HOME/.gems/ruby/$(ruby -e "print Gem.ruby_api_version")
export GEM_HOME=$HOME/.gems/ruby/$(ruby -e "print Gem.ruby_api_version")
export GEM_PATH=$HOME/.gems/ruby/$(ruby -e "print Gem.ruby_api_version")
export PATH=$HOME/.gems/ruby/$(ruby -e "print Gem.ruby_api_version")/bin:$PATH
EOS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment