#!/bin/bash -e # The contents of this file are subject to the Common Public Attribution # License Version 1.0. (the "License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://code.reddit.com/LICENSE. The License is based on the Mozilla Public # License Version 1.1, but Sections 14 and 15 have been added to cover use of # software over a computer network and provide for limited attribution for the # Original Developer. In addition, Exhibit A has been modified to be consistent # with Exhibit B. # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for # the specific language governing rights and limitations under the License. # # The Original Code is reddit. # # The Original Developer is the Initial Developer. The Initial Developer of # the Original Code is reddit Inc. # # All portions of the code written by reddit are Copyright (c) 2006-2013 reddit # Inc. All Rights Reserved. ############################################################################### ############################################################################### # 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 # the domain that you will connect to your reddit install with. # MUST contain a . in it somewhere as browsers won't do cookies for dotless # domains. an IP address will suffice if nothing else is available. REDDIT_DOMAIN=${REDDIT_DOMAIN:-reddit.local} ############################################################################### # 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 precise (12.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" != "12.04" ]; then echo "ERROR: Only Ubuntu 12.04 is supported." exit 1 fi ############################################################################### # Install prerequisites ############################################################################### set -x # create the user if non-existent if ! id $REDDIT_USER &> /dev/null; then adduser --system $REDDIT_USER fi # aptitude configuration APTITUDE_OPTIONS="-y" # limit bandwidth: -o Acquire::http::Dl-Limit=100" export DEBIAN_FRONTEND=noninteractive # run an aptitude update to make sure python-software-properties # dependencies are found apt-get update # add the reddit ppa for some custom packages apt-get install $APTITUDE_OPTIONS python-software-properties apt-add-repository -y 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; then echo "create keyspace reddit;" | cassandra-cli -h localhost -B fi cat < development.update < production.update < $BACKUP_HAPROXY fi # make sure haproxy is enabled cat > /etc/default/haproxy < /etc/haproxy/haproxy.cfg < /etc/default/reddit < $CONSUMER_CONFIG_ROOT/$1 fi } set_consumer_count log_q 0 set_consumer_count cloudsearch_q 0 set_consumer_count scraper_q 0 set_consumer_count commentstree_q 1 set_consumer_count newcomments_q 1 set_consumer_count vote_link_q 1 set_consumer_count vote_comment_q 1 initctl emit reddit-start ############################################################################### # Cron Jobs ############################################################################### if [ ! -f /etc/cron.d/reddit ]; then cat > /etc/cron.d/reddit <