#!/bin/bash -e ############################################################################### # The reddit installer # -------------------- # This script installs a reddit stack suitable for development. DO NOT run # this on a system that you use for other purposes as it may accidentally # an important file. # # You can run this script as is, in which case a user "reddit" will be created # and the code will be placed in its home directory. The various reddit-code # components of the stack will run as this user. # # To change aspects of the install, modify the variables in the "Configuration" # section below. ############################################################################### set -e ############################################################################### # Configuration ############################################################################### # which user should run the reddit code REDDIT_USER=reddit # the group to run reddit code as REDDIT_GROUP=nogroup # the root directory in which to install the reddit code REDDIT_HOME=/home/$REDDIT_USER # which user should own the installed reddit files # NOTE: if you change this option, you should move the mako template # cache directory by changing the "cache_dir" option in the [app:main] # section of the update files as $REDDIT_HOME will most likely # not be writable by the reddit user. REDDIT_OWNER=reddit ############################################################################### # Sanity Checks ############################################################################### if [[ $EUID -ne 0 ]]; then echo "ERROR: Must be run with root privileges." exit 1 fi # seriously! these checks aren't here for no reason. the packages from the # reddit ppa aren't built for anything but natty (11.04) right now, so # if you try and use this install script on another release you're gonna # have a bad time. source /etc/lsb-release if [ "$DISTRIB_ID" != "Ubuntu" -o "$DISTRIB_RELEASE" != "11.04" ]; then echo "ERROR: Only Ubuntu 11.04 is supported." exit 1 fi ############################################################################### # Install prerequisites ############################################################################### set -x # create the user if non-existent if ! id $REDDIT_USER > /dev/null 2>&1; then adduser --system $REDDIT_USER fi # aptitude configuration APTITUDE_OPTIONS="-y" # limit bandwidth: -o Acquire::http::Dl-Limit=100" export DEBIAN_FRONTEND=noninteractive # add the reddit ppa for some custom packages apt-get install $APTITUDE_OPTIONS python-software-properties apt-add-repository ppa:reddit/ppa # pin the ppa -- packages present in the ppa will take precedence over # ones in other repositories (unless further pinning is done) cat < /etc/apt/preferences.d/reddit Package: * Pin: release o=LP-PPA-reddit Pin-Priority: 600 HERE # grab the new ppas' package listings apt-get update # install prerequisites cat < /dev/null 2>&1; then echo "create keyspace reddit;" | cassandra-cli -h localhost -B fi cat < development.update < production.update < $BACKUP_HAPROXY fi cat > /etc/haproxy/haproxy.cfg < /etc/default/reddit < $REDDIT_HOME/consumer-counts < /etc/cron.d/reddit <