Skip to content

Instantly share code, notes, and snippets.

@addame
addame / deploy.rb
Created January 25, 2009 02:55 — forked from tbalthazar/deploy.rb
# use the ubuntu machine gem
require 'capistrano/ext/ubuntu-machine'
# #######################################
# HOSTING PROVIDER CONFIGURATION
# Those tasks have been tested with severa hosting providers
# and sometimes tasks are specific to those providers
set :hosting_provider, "slicehost" # currently supported : ovh-rps, ovh-dedie, slicehost
RE="ruby-enterprise-1.8.6-20081215"
PREFIX=/opt/$RE
VERSION=2.0.6
GEM_PATH="$PREFIX/lib/ruby/gems/1.8/gems/passenger-$VERSION"
DOMAIN=odpiralnicasi.com
APP_ROOT=/srv/oc
# install Apache2
apt-get install -qq apache2 apache2-prefork-dev
#!/bin/bash
# Unattended REE/Passenger installation
# Source: http://weblog.brightlight-ict.nl/2008/12/unattended-passenger-ruby-enterprise-installation-on-ubuntu-8/
# 15/03/09 Updated to use latest r.e.e. and passenger 2.1 and rewrote bits thanks to the comments left on my blog. Thanks guys
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
# alternative Block execution on empty Enumerable
# see : http://blog.sponagl.de/2009/1/23/alternative-block-execution-on-empty-enumerable
# 1.
ary = []
ary.each do |i|
puts i
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
# This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
mkdir -p /usr/local/src ; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.bz2
tar -xjvf ruby-1.8.7-p160.tar.bz2
cd ruby-1.8.7-p160
./configure --prefix=/usr --program-suffix=18 --enable-shared
make && sudo make all install
cd /usr/local/src
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# a dirty method to write all installed gems in a file as commands ready ... for installation
# useful when upgrading (even if rvm is a killer ;-) )
require "date"
def list_installed_gems
gems = `gem list`
all_gems = gems.chomp!.split(/\n/)
@f = File.open("gem_list_install_#{Date.parse(Time.now.to_s).to_s}.sh", "w")
# create install commande