{"id":44,"date":"2011-12-27T11:41:00","date_gmt":"2011-12-27T07:41:00","guid":{"rendered":"http:\/\/xxxl.co.za\/?p=44"},"modified":"2012-08-11T21:41:48","modified_gmt":"2012-08-11T17:41:48","slug":"updating-ruby-in-centos-5-x","status":"publish","type":"post","link":"https:\/\/xxxl.co.za\/?p=44","title":{"rendered":"Updating Ruby in Centos 5.X"},"content":{"rendered":"<p>Many thanx to John Alberts whom created this script.<\/p>\n<p>I found this invaluable while working with Metasploit.<\/p>\n<p>Originally from: <a href=\"https:\/\/raw.github.com\/albertsj1\/Misc-Scripts\/master\/install_gems.sh\" target=\"_blank\">https:\/\/raw.github.com\/albertsj1\/Misc-Scripts\/master\/install_gems.sh<\/a><\/p>\n<p>&nbsp;<\/p>\n<pre>\r\n#!\/bin\/sh\r\n\r\n########################################\r\n# Created by John Alberts\r\n# Last modified: 04\/21\/2011\r\n#\r\n# Error Codes:\r\n#  1 - Not running as root\r\n#  2 - Invalid hostname\r\n#  3 - Failed to get remove Ruby OS packages\r\n#  4 - Failed to compile and install Ruby\r\n#\r\n# NOTES:\r\n#  This only works on CentOS 5.  Only tested on x86_64\r\n#\r\n#########################################\r\n\r\n#RUBY_SOURCE_URL=\"ftp:\/\/ftp.ruby-lang.org\/pub\/ruby\/1.9\/ruby-1.9.2-p136.tar.gz\"\r\nRUBY_SOURCE_URL=\"http:\/\/ftp.ruby-lang.org\/pub\/ruby\/1.9\/ruby-1.9.2-p180.tar.gz\"\r\n# The below URL only works from within the exlibrisgroup network.  Anyone else should use the URL above.\r\n# RUBY_SOURCE_URL=\"https:\/\/helpdesk.hosted.exlibrisgroup.com\/downloads\/ruby-1.9.2-p180.tar.gz\"\r\n\r\nif ! ( whoami | grep root > \/dev\/null 2>&1); then\r\n  echo \"YOU MUST BE ROOT TO RUN THIS SCRIPT\"'!'\r\n  exit 1\r\nfi\r\n\r\nif ! ( ping -c1 -q `hostname -f` > \/dev\/null 2>&1 ); then\r\n  echo \"hostname -f must be a valid fqdn for Chef to work properly\"'!'\r\n  exit 2\r\nfi\r\n\r\necho \"Removing already installed Ruby OS packages...\"\r\nPKGLIST=\"$(yum list | grep installed | grep ruby | sed -n 's\/\\([^.]*\\)\\.\\(x86_64\\|i386\\).*$\/\\1\/p' | tr '\\n' ' ')\"\r\nif [[ $PKGLIST != \"\" ]]; then\r\n  yum -y erase $PKGLIST\r\n  RETVAL=$?\r\nelse\r\n  RETVAL=0\r\nfi\r\n\r\necho;echo\r\nif [[ ${RETVAL} -ne 0 ]]; then\r\n  echo \"Failed to remove Ruby OS packages\"'!'\r\n  exit 3\r\nfi\r\n\r\necho \"Installing Ruby and dependencies...\"\r\nyum -y install gcc gcc-c++ zlib-devel openssl-devel readline-devel make\r\n\r\nmkdir \/tmp\/sources\r\ncd \/tmp\/sources\r\n\r\n# Get # cpu's to make this faster\r\nif [[ ! $CPUS ]]; then\r\n  CPUS=\"$(grep processor \/proc\/cpuinfo | wc -l)\"\r\nfi\r\n\r\nwget \"${RUBY_SOURCE_URL}\"\r\ntar -xvzf $(basename ${RUBY_SOURCE_URL})\r\ncd $(basename ${RUBY_SOURCE_URL\/.tar.gz})\r\n.\/configure\r\nmake -j $CPUS\r\nmake -j $CPUS install\r\nRETVAL=$?\r\n\r\necho;echo\r\n\r\nif [[ ${RETVAL} -ne 0 ]]; then\r\n  echo \"RUBY INSTALLATION FAILED\"'!'\r\n  exit 4\r\nfi\r\n\r\necho 'gem: --no-ri --no-rdoc' > \/root\/.gemrc\r\n\r\necho \"Installation completed.\"\r\n<\/pre>\n<p>Many thanx to John!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many thanx to John Alberts whom created this script. I found this invaluable while working with Metasploit. Originally from: https:\/\/raw.github.com\/albertsj1\/Misc-Scripts\/master\/install_gems.sh &nbsp; #!\/bin\/sh ######################################## # Created by John Alberts # Last modified: 04\/21\/2011 # # Error Codes: # 1 &#8211; Not running as root # 2 &#8211; Invalid hostname # 3 &#8211; Failed to get remove &hellip; <a href=\"https:\/\/xxxl.co.za\/?p=44\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Updating Ruby in Centos 5.X<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":8,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":135,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/135"}],"wp:attachment":[{"href":"https:\/\/xxxl.co.za\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xxxl.co.za\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}