Postgres + REE + Nginx + Passenger

by mocra
240 deployments · 18 still active · last rev. 6 years ago

Installs Postgres, Ruby Enterprise edition, and Nginx with Passenger. It also adds REE to the system-wide $PATH

Compatible with: No distros currently supported
						#!/bin/bash
# 
# Installs Postgres, Ruby Enterprise edition, and Nginx with Passenger. 
# It also adds REE to the system-wide $PATH
#
# <UDF name="ree_version" Label="Ruby Enterprise Edition Version" default="1.8.7-2010.01" example="1.8.7-2010.01" />
# <UDF name="install_prefix" Label="Install Prefix for REE and Passenger" default="/opt/local" example="/opt/local will install REE to /opt/local/ree" />
# <UDF name="rr_env" Label="Rails/Rack environment to run" default="production" />

source <ssinclude StackScriptID=44> # Enable Universe

# Set up some necessary ENV variables
  # Should be set from UDF if run through Linode
  if [ ! -n "$REE_VERSION" ]; then
    REE_VERSION="1.8.7-2010.01"
  fi
  if [ ! -n "$INSTALL_PREFIX" ]; then
    INSTALL_PREFIX="/usr/local"
  fi
  if [ ! -n "$RR_ENV" ]; then
    RR_ENV="production"
  fi
  if [ ! -n "$TMPDIR" ]; then
    TMPDIR="/var/tmp"
  fi

  REE_NAME="ruby-enterprise-$REE_VERSION"
  REE_FILENAME="$REE_NAME.tar.gz"
  REE_DOWNLOAD="http://rubyforge.org/frs/download.php/68719/$REE_FILENAME"
  WORKING_DIR="$TMPDIR/flux-setup"

  mkdir -p "$WORKING_DIR"

# Set up PostgreSQL
  apt-get -y install postgresql libpq-dev

# Set up Ruby Enterprise Edition
  # Dependencies
  apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev

  # Download
  cd       "$WORKING_DIR"
  wget     "$REE_DOWNLOAD" -O "$REE_FILENAME"
  tar xzf  "$REE_FILENAME"
  cd       "$REE_NAME"
  
  # Install
  ./installer --auto="$INSTALL_PREFIX/$REE_NAME"
  ln -s "$INSTALL_PREFIX/$REE_NAME" "$INSTALL_PREFIX/ree"

  # Add REE to the PATH
  PATH="$INSTALL_PREFIX/ree/bin:$PATH"

# Set up Nginx and Passenger
  passenger-install-nginx-module --auto --auto-download --prefix="$INSTALL_PREFIX/nginx"

# Set up environment
  # Global environment variables
  cat > /etc/environment << EOF
PATH="$PATH"
RAILS_ENV="$RR_ENV"
RACK_ENV="$RR_ENV"
EOF

# Clean up
  rm -rf "$WORKING_DIR"