#!/bin/sh ######################################## # Created by John Alberts # Last modified: 05/23/2012 # # Error Codes: # 1 - Not running as root # 2 - Invalid hostname # 3 - Failed to get remove Ruby OS packages # 4 - Failed to compile and install Ruby # # NOTES: # Confirmed to work on centos 5 and 6, x86_64 # ######################################### #RUBY_SOURCE_URL="ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p136.tar.gz" #RUBY_SOURCE_URL="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz" #RUBY_SOURCE_URL="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz" # The below URL only works from within the exlibrisgroup network. Anyone else should use the URL above. RUBY_SOURCE_URL="https://helpdesk.hosted.exlibrisgroup.com/downloads/ruby-1.9.3-p392.tar.gz" if ! ( whoami | grep root > /dev/null 2>&1); then echo "YOU MUST BE ROOT TO RUN THIS SCRIPT"'!' exit 1 fi if ! ( ping -c1 -q `hostname -f` > /dev/null 2>&1 ); then echo "hostname -f must be a valid fqdn for Chef to work properly"'!' exit 2 fi echo "Removing already installed Ruby OS packages..." PKGLIST="$(yum list installed | grep ruby | sed -n 's/\([^.]*\)\.\(x86_64\|i386\).*$/\1/p' | tr '\n' ' ')" if [[ $PKGLIST != "" ]]; then yum -y erase $PKGLIST RETVAL=$? else RETVAL=0 fi echo;echo if [[ ${RETVAL} -ne 0 ]]; then echo "Failed to remove Ruby OS packages"'!' exit 3 fi echo "Updating glibc glibc-common glibc-headers glibc-devel" echo "This is necessary to work around a bug" echo "https://bugzilla.redhat.com/show_bug.cgi?id=228430" yum -y update glibc glibc-common glibc-headers glibc-devel echo "Updating hal and then yum otherwise Chef fails for really old versions of yum" yum -y update hal yum -y update yum echo "Installing Ruby and dependencies..." yum -y install gcc gcc-c++ zlib-devel openssl-devel readline-devel make autoconf flex bison libyaml-devel libffi-devel gdbm-devel libtool mkdir /tmp/sources cd /tmp/sources # Get # cpu's to make this faster if [[ ! $CPUS ]]; then CPUS="$(grep processor /proc/cpuinfo | wc -l)" fi wget "${RUBY_SOURCE_URL}" tar -xvzf $(basename ${RUBY_SOURCE_URL}) cd $(basename ${RUBY_SOURCE_URL/.tar.gz}) ./configure make -j $CPUS make -j $CPUS install RETVAL=$? echo;echo if [[ ${RETVAL} -ne 0 ]]; then echo "RUBY INSTALLATION FAILED"'!' exit 4 fi echo 'gem: --no-ri --no-rdoc' > /root/.gemrc echo "Installation completed."