#!/bin/bash # # # #Script to install Ruby on Rails on a cPanel server # # #This script is ©2006 Defender Technologies Group LLC., #and may not be reproduced in part or full without permission # #Tony Dodd # # if [ x`which GET` == "x" ] then echo "Sorry, GET is required for this script to run" exit 2 fi if [ `id | awk '{print $1}' | sed -e 's/(.*)$//g' | cut -d"=" -f2` -ne "0" ] then echo "Sorry, root is required for this script to run" exit 2 fi function rubyver { #function will grab the download url for latest ruby ruby_url=`GET http://ruby-lang.org/en/20020102.html | grep "stable release" -m1 | cut -d"<" -f4 | cut -d"\"" -f2` ruby_version=`echo $ruby_url | cut -d"/" -f6 | sed -e 's/\.tar\.gz//g'` ruby_file=`echo $ruby_url | cut -d"/" -f6` } function doruby { if [ -e /usr/src/rubyfiles/ruby/$ruby_version ] then echo "$ruby_version already installed, skipping" else mkdir -p /usr/src/rubyfiles/ruby cd /usr/src/rubyfiles/ruby wget $ruby_url tar -zxvf $ruby_file cd $ruby_version ./configure && make && make install fi } function gemsver { gems_url=http\:\/\/rubyforge.org`GET http://rubyforge.org/frs/?group_id=126 | grep rubygems\- -m1 | cut -d"\"" -f2` gems_version=`echo $gems_url | cut -d"/" -f7 | sed -e 's/\.tgz//g'` gems_file=`echo $gems_url | cut -d"/" -f7` } function dogems { if [ -e /usr/src/rubyfiles/gems/$gems_version ] then echo "$gems_version already installed, skipping" else mkdir /usr/src/rubyfiles/gems # if rubyfiles hasn't been created yet, there is a problem. cd /usr/src/rubyfiles/gems wget $gems_url tar -zxvf $gems_file cd $gems_version ruby setup.rb fi } function dorails { gem install rails -y #more of a placeholder than a real function, in case this method ever needs to be revised. } function fcgiver { #again, another semi place-holder in case this changes in future. fcgi_url="http://fastcgi.com/dist/fcgi-2.4.0.tar.gz" fcgi_version="fcgi-2.4.0" fcgi_file="fcgi-2.4.0.tar.gz" } function dofcgi { if [ -e /usr/src/rubyfiles/fcgi/$fcgi_version ] then echo "$fcgi_version already installed, skipping" else mkdir /usr/src/rubyfiles/fcgi cd /usr/src/rubyfiles/fcgi wget $fcgi_url tar -zxvf $fcgi_file cd $fcgi_version ./configure && make && make install fi } function modfcgiver { #another place-holder modfcgi_url="http://fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz" modfcgi_version="mod_fastcgi-2.4.2" modfcgi_file="mod_fastcgi-2.4.2.tar.gz" } function domodfcgi { if [ -e /usr/src/rubyfiles/mod_fcgi/$modfcgi_version ] then echo "$modfcgi_version already installed, skipping" else mkdir /usr/src/rubyfiles/mod_fcgi cd /usr/src/rubyfiles/mod_fcgi wget $modfcgi_url tar -zxvf $modfcgi_file cd $modfcgi_version $apxs -o mod_fastcgi.so -c *.c $apxs -i -a -n fastcgi mod_fastcgi.so fi } function findapxs { if [ -e /usr/local/apache/bin/apxs ] then apxs="/usr/local/apache/bin/apxs" echo "found apxs at $apxs" elif [ -n `whereis apxs | awk '{print $2}'` ] then apxs="`whereis apxs | awk '{print $2}'`" echo "found apxs at $apxs" else echo "I cannot find apxs, please add a symlink to it in /usr/sbin/ then run me again" fi } function dogemfcgi { #placeholder gem install fcgi -y } function httpdconf { fcgi_line=`cat /etc/httpd/conf/httpd.conf -n | grep AccessFile -m1 -B1 | head -1 | awk '{print $1}'` function getsupport { #grab support scripts that we need mkdir -p /usr/src/rubyfiles/scripts/ cd /usr/src/rubyfiles/scripts wget http://download.powervps.com/scriptsupport/insertext.sh } getsupport findapxs rubyver gemsver fcgiver doruby dogems dorails dofcgi domodfcgi dogemfcgi