やっつけRubyインストール

2011/07/24
#!/bin/sh
workdir=/usr/local/src/rubysrc
ver_major='1.9'
ver_major_minor='1.9.2'
_patch_or_stable='p290'
_ext='tar.gz'
_prefix='/usr/local/ruby'
_arc=`uname -i`

_ruby_srcpackage="ruby-${ver_major_minor}-${_patch_or_stable}"
_url="http://ftp.ruby-lang.org/pub/ruby/${ver_major}"

yum install zlib.${_arc} zlib-devel.${_arc} -y

rubysrc_url="${_url}/${_ruby_srcpackage}.${_ext}"
noruby='noexist'
ls ${_prefix}/bin/ruby && noruby='installed'
if [ ! "${noruby}" = 'installed' ] ; then
  if [ ! -e ${workdir} ] ; then
          mkdir ${workdir}
        fi
        cd ${workdir} && \
          wget ${rubysrc_url} > /dev/null 2>&1  && \
          tar zxvf ${_ruby_srcpackage}.${_ext} && \
          cd ${_ruby_srcpackage} && \
          ./configure --prefix=${_prefix} && \
          make && make install && ${_prefix}/bin/ruby -v
        echo "export PATH=${_prefix}/bin:\$PATH"
else
  echo "\nRuby was installed\n"
fi