rendered paste body#!/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 <tony@defenderhosting.com>##if [ x`which GET` == "x" ]then echo "Sorry, GET is required for this script to run" exit 2fiif [ `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 2fifunction rubyver {#function will grab the download url for latest rubyruby_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 ]thenecho "$ruby_version already installed, skipping"elsemkdir -p /usr/src/rubyfiles/rubycd /usr/src/rubyfiles/rubywget $ruby_urltar -zxvf $ruby_filecd $ruby_version./configure && make && make installfi}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 ]thenecho "$gems_version already installed, skipping"elsemkdir /usr/src/rubyfiles/gems # if rubyfiles hasn't been created yet, there is a problem.cd /usr/src/rubyfiles/gemswget $gems_urltar -zxvf $gems_filecd $gems_versionruby setup.rbfi}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 ]thenecho "$fcgi_version already installed, skipping"elsemkdir /usr/src/rubyfiles/fcgicd /usr/src/rubyfiles/fcgiwget $fcgi_urltar -zxvf $fcgi_filecd $fcgi_version./configure && make && make installfi}function modfcgiver {#another place-holdermodfcgi_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 ]thenecho "$modfcgi_version already installed, skipping"elsemkdir /usr/src/rubyfiles/mod_fcgicd /usr/src/rubyfiles/mod_fcgiwget $modfcgi_urltar -zxvf $modfcgi_filecd $modfcgi_version$apxs -o mod_fastcgi.so -c *.c$apxs -i -a -n fastcgi mod_fastcgi.sofi}function findapxs {if [ -e /usr/local/apache/bin/apxs ]thenapxs="/usr/local/apache/bin/apxs"echo "found apxs at $apxs"elif [ -n `whereis apxs | awk '{print $2}'` ]thenapxs="`whereis apxs | awk '{print $2}'`"echo "found apxs at $apxs"elseecho "I cannot find apxs, please add a symlink to it in /usr/sbin/ then run me again"fi}function dogemfcgi {#placeholdergem install fcgi -y}function httpdconf {if [ -e /etc/httpd/conf/httpd.conf ]thenhttpd_conf="/etc/httpd/conf/httpd.conf"elsehttpd_conf="/usr/local/apache/conf/httpd.conf"fifcgi_if_line=`cat $httpd_conf -n | grep AccessFile -m1 -B1 | head -1 | awk '{print $1}'`fcgi_load_line=$(( `cat -n $httpd_conf | grep LoadModule | tail -1 | awk '{print $1}'` + 1 ))cd /usr/src/rubyfiles/scripts/chmod +x insertext.sh/usr/src/rubyfiles/scripts/insertext.sh $fcgi_if_line fcgi_if $httpd_conf/usr/src/rubyfiles/scripts/insertext.sh $fcgi_load_line fcgi_load $httpd_conf}function getsupport {#grab support scripts that we needmkdir -p /usr/src/rubyfiles/scripts/cd /usr/src/rubyfiles/scriptsif [ -e insertext.sh ]thenecho "insertext.sh already exists, overwriting"wget -O insertext.sh http://download.powervps.com/scriptsupport/insertext.shfiif [ -e fcgi_load ]thenecho "fcgi_load already exists, overwriting"wget -O fcgi_load http://download.powervps.com/scriptsupport/fcgi_loadfiif [ -e fcgi_if ]thenecho "fcgi_if already exists, overwriting"wget -O fcgi_if http://download.powervps.com/scriptsupport/fcgi_iffi}function folders {mkdir -p /fcgi_ipcchown nobody.nobody /fcgi_ipc -Rchmod 755 /fcgi_ipc -R}function cleaning_up {echo "cleaning up files we do not need"rm -rf /usr/src/rubyfiles}function finished {echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!! INSTALLATION COMPLETE !!!! !!!! The following will get a test app set up to make sure RoR is working. !!!! !!!! cd /home/USER !!!! rails /home/USER/testapp !!!! cd /home/USER/testapp/ !!!! ruby script/generate controller test !!!! cd /home/USER/public_html !!!! ln -s ../testapp/public rails !!!! !!!! Then visit http://www.yourtestdomain.com/rails/ !!!! and you should see a congratulations page. !!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}getsupportfindapxsrubyvergemsverfcgiverdorubydogemsdorailsdofcgidomodfcgidogemfcgihttpdconffolderscleaning_upfinished