# run this script on a fresh Ubuntu server installation as non-root user


# version numbers for various packages
NGINX_VERSION=1.0.8

# copy public ssh key to server's authorized_keys keychain for simple ssh logins
#mkdir -p ~/.ssh
#echo -e '<your ssh public key here>' > ~/.ssh/authorized_keys


# setup .gemrc
echo -e '---
:verbose: true 
:bulk_threshold: 1000 
:sources:
- http://rubygems.org
- http://gems.github.com
gem: --no-ri --no-rdoc
:benchmark: false
:update_sources: true 
:backtrace: false' > ~/.gemrc


# install aptitude
sudo apt-get install aptitude


# update ubuntu repos
sudo aptitude update
sudo aptitude -y dist-upgrade


# setup rvm / postgresql / nginx pre-requisites + useful libraries
sudo aptitude -y install build-essential git curl vim rdate htop python-software-properties


# install recommended dependencies as suggested by `rvm notes`
sudo aptitude -y install bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev sqlite3 libsqlite3-0 libxml2-dev libxslt-dev autoconf subversion libcurl4-openssl-dev


# install + configure sshguard
sudo aptitude install sshguard
sudo iptables -N sshguard # for regular IPv4 support
sudo ip6tables -N sshguard # for IPv6 support as well
sudo iptables -A INPUT -j sshguard # block any IPv4 traffic from abusers
sudo ip6tables -A INPUT -j sshguard # block any IPv6 traffic from abusers
sudo iptables-save # save updated iptables configuration


# install PostgreSQL
sudo add-apt-repository ppa:pitti/postgresql # install PostgreSQL PPA ((P)ersonal (P)ackage (A)rchive)
sudo aptitude update
sudo aptitude -y install postgresql libpq-dev


# download + unzip nginx source
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -O- | tar xz


# setup new group "wheel" for sudo users
echo Refer to http://articles.slicehost.com/2010/10/18/ubuntu-maverick-setup-part-1#newuser
echo to setup new "wheel" group + sudo users.