1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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