Skip to content

Instantly share code, notes, and snippets.

@fcoury
Created August 6, 2009 15:44
Show Gist options
  • Save fcoury/163378 to your computer and use it in GitHub Desktop.
Save fcoury/163378 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define some Constants as Variables
SCRIPT_VERSION="0.9.9"
RUBYGEMS_FILENAME="rubygems-1.3.5.tgz"
RUBYGEMS_FOLDER="rubygems-1.3.5"
RUBYGEMS_SOURCE="http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz"
SPAWNFCGI_FILENAME="spawn-fcgi-1.6.2.tar.gz"
SPAWNFCGI_FOLDER="spawn-fcgi-1.6.2"
SPAWNFCGI_SOURCE="http://www.lighttpd.net/download/spawn-fcgi-1.6.2.tar.gz"
CHEROKEE_FILENAME="cherokee-0.99.22.tar.gz"
CHEROKEE_FOLDER="cherokee-0.99.22"
CHEROKEE_SOURCE="http://www.cherokee-project.com/download/0.99/0.99.22/cherokee-0.99.22.tar.gz"
CHEROKEE_PARAMS="--localstatedir=/var --prefix=/usr --sysconfdir=/etc --with-wwwroot=/var/www"
trap onexit 1 2 3 15 ERR
function onexit() {
local exit_status=${1:-$?}
echo " "
echo "It's time for the script to end. If you didn't recieve the"
echo "'Installation Completed!' message box, then please assume "
echo "something went wrong. Check 'cherokee-script.log' for more"
echo "details on any errors which may have occured"
echo " "
echo "Quitting Script..."
echo " "
exit $exit_status
}
# Clear the screen first and output an intro
clear
echo "-------------------------------------------------------"
echo "# > Cherokee Web Server Install w/ Ruby on Rails "
echo "# > Version: $SCRIPT_VERSION - Written by Suhail Patel "
echo "# > Tested on Debian Lenny 64bit @ Webbynode "
echo "-------------------------------------------------------"
echo " "
echo "WARNING: Please note this script is provided as-is and "
echo "is only meant to be used in a non-production "
echo "environment. I will not be held responsible for any "
echo "damages incurred as a result of using this script. If "
echo "you do not agree with this then please stop usage of "
echo "this script. "
echo " "
# Check if the script was run as a root user
if [[ $EUID -ne 0 ]]; then
echo "This script must be ran as a root user... Quitting" 1>&2
exit 1
fi
# Lets start off by making sure the list of packages is up-to-date
echo "Making sure your list of packages are up-to-date..."
apt-get -y update >> cherokee-script.log 2>&1
# Install the essential stuff first
echo "Grabbing essential packages..."
apt-get -y install bzip2 zip build-essential python gettext libfcgi-dev >> cherokee-script.log 2>&1
# Ruby
echo "Installing Ruby Components"
apt-get -y install ruby ruby1.8 ruby-dev libopenssl-ruby libfcgi-ruby1.8 >> cherokee-script.log 2>&1
# Download RubyGems from Source and Install
echo "Installing RubyGems from Source..."
wget "$RUBYGEMS_SOURCE" >> cherokee-script.log 2>&1
tar xvzf "$RUBYGEMS_FILENAME" >> cherokee-script.log 2>&1
cd "$RUBYGEMS_FOLDER" >> cherokee-script.log 2>&1
ruby setup.rb --no-rdoc --no-ri >> cherokee-script.log 2>&1
cd .. >> cherokee-script.log 2>&1
ln -s /usr/bin/gem1.8 /usr/bin/gem >> cherokee-script.log 2>&1
# Install Ruby on Rails
echo "Installing Rails from RubyGems"
gem install rails --no-rdoc --no-ri >> cherokee-script.log 2>&1
# Install SQLite3
echo "Installing SQLite3..."
apt-get -y install sqlite3 libsqlite3-ruby >> cherokee-script.log 2>&1
# Install Git
echo "Installing Git..."
apt-get -y install git-core >> cherokee-script.log 2>&1
# Install Cherokee and Spawn FCGI
echo "Installing Cherokee and Spawn FCGI"
wget "$CHEROKEE_SOURCE" >> cherokee-script.log 2>&1
tar xvzf "$CHEROKEE_FILENAME" >> cherokee-script.log 2>&1
cd "$CHEROKEE_FOLDER" >> cherokee-script.log 2>&1
./configure $CHEROKEE_PARAMS >> cherokee-script.log 2>&1
make >> cherokee-script.log 2>&1
make install >> cherokee-script.log 2>&1
mv contrib/cherokee.pre /etc/init.d/ >> cherokee-script.log 2>&1
mv /etc/init.d/cherokee.pre /etc/init.d/cherokee >> cherokee-script.log 2>&1
chmod +x /etc/init.d/cherokee >> cherokee-script.log 2>&1
update-rc.d cherokee >> cherokee-script.log 2>&1
cd .. >> cherokee-script.log 2>&1
wget "$SPAWNFCGI_SOURCE" >> cherokee-script.log 2>&1
tar xvzf "$SPAWNFCGI_FILENAME" >> cherokee-script.log 2>&1
cd "$SPAWNFCGI_FOLDER" >> cherokee-script.log 2>&1
./configure >> cherokee-script.log 2>&1
make >> cherokee-script.log 2>&1
make install >> cherokee-script.log 2>&1
cd .. >> cherokee-script.log 2>&1
gem install fcgi --no-rdoc --no-ri >> cherokee-script.log 2>&1
# Clean up any files left behind
echo "Cleaning up"
rm -r "$CHEROKEE_FOLDER" "$RUBYGEMS_FOLDER" "$SPAWNFCGI_FOLDER" "$CHEROKEE_FILENAME" "$RUBYGEMS_FILENAME" "$SPAWNFCGI_FILENAME" >> cherokee-script.log 2>&1
# And finish with an outro
echo ""
echo "-------------------------------------------------------"
echo "# > Installation Completed! Now run 'cherokee-admin -b'"
echo "# > and configure your server. Remember to run "
echo "# > 'rake rails:update:generate_dispatchers' before "
echo "# > deploying your Ruby on Rails Application "
echo "# "
echo "# > A log of the output of the various commands has "
echo "# > been saved to 'cherokee-script.log'. Have a look "
echo "# > at it if you think something went wrong. Good Luck!"
echo "-------------------------------------------------------"
onexit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment