-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_gems.sh
91 lines (70 loc) · 2.36 KB
/
install_gems.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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."