Skip to content

Instantly share code, notes, and snippets.

@rickmark
Created June 1, 2010 20:45
Show Gist options
  • Save rickmark/421465 to your computer and use it in GitHub Desktop.
Save rickmark/421465 to your computer and use it in GitHub Desktop.
USER_NAME='username'
USER_PASSWORD='Password'
USER_FULLNAME='Full Name'
# Initial server configuration template
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Check if the wheel group exists
grep -w "wheel" /etc/group >/dev/null
if [ $? != 0 ]; then
addgroup wheel
fi
# Check if my user exists and if it doesn't create it
grep -w "penwellr" /etc/shadow >/dev/null
if [ $? != 0 ]; then
useradd -c "$USER_FULLNAME" $USER_NAME
passwd $USER_NAME $USER_PASSWORD
usermod -G wheel $USER_NAME
fi
apt-get update
apt-get upgrade -y
# Install packages related to core Ruby on Rails stack
export DEBIAN_FRONTEND=noninteractive
apt-get install ruby-full nginx git-core mysql-server libmysqlclient-dev build-essential libxml2-dev libsqlite3-dev libxslt-dev -y
# Install RubyGems from source as the version in Ubuntu is out of date
which gem >/dev/null
if [ $? != 0 ]; then
cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz
tar xzf rubygems-1.3.6.tgz
cd rubygems-1.3.6
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem
fi
# Install basic gems that are expected on the system
if [ ! -f /usr/bin/bundle]; then
gem install bundler
fi
if [ ! -f /usr/bin/thin ]; then
gem install thin
fi
if [ ! -f /usr/bin/rake ]; then
gem install rake
fi
# Setup the thin webserver to launch on startup
if [ ! -f /etc/init.d/thin ]; then
thin install
/usr/sbin/update-rc.d -f thin defaults
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment