Update README for archival
[reddit.git] / install / travis.sh
blob06259d74e7feff536845087b0da23c20e6211594
1 #!/bin/bash
2 # The contents of this file are subject to the Common Public Attribution
3 # License Version 1.0. (the "License"); you may not use this file except in
4 # compliance with the License. You may obtain a copy of the License at
5 # http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
6 # License Version 1.1, but Sections 14 and 15 have been added to cover use of
7 # software over a computer network and provide for limited attribution for the
8 # Original Developer. In addition, Exhibit A has been modified to be consistent
9 # with Exhibit B.
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
13 # the specific language governing rights and limitations under the License.
15 # The Original Code is reddit.
17 # The Original Developer is the Initial Developer. The Initial Developer of
18 # the Original Code is reddit Inc.
20 # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
21 # Inc. All Rights Reserved.
22 ###############################################################################
24 ###############################################################################
25 # reddit travis environment installer
26 # -----------------------------------
27 # This script installs a reddit stack suitable for running on travis-ci.
28 # As such, this is a minimal build to allow for running "nosetests"
29 # and not much more.
30 ###############################################################################
32 # load configuration
33 RUNDIR=$(dirname $0)
34 source $RUNDIR/install.cfg
36 # who is running me (expects "travis" or "vagrant")
37 ENVIRONMENT=${1:-travis}
39 # the root directory to base the install in. must exist already
40 REDDIT_CODE=${2:-$REDDIT_SRC/reddit}
42 if [ ! -e $REDDIT_CODE ]; then
43 echo "Couldn't find source $REDDIT_CODE. Aborting"
44 exit 1
47 ###############################################################################
48 # Sanity Checks
49 ###############################################################################
50 if [[ $EUID -ne 0 ]]; then
51 echo "ERROR: Must be run with root privileges."
52 exit 1
55 if [[ "amd64" != $(dpkg --print-architecture) ]]; then
56 cat <<END
57 ERROR: This host is running the $(dpkg --print-architecture) architecture!
59 Because of the pre-built dependencies in our PPA, and some extra picky things
60 like ID generation in liveupdate, installing reddit is only supported on amd64
61 architectures.
62 END
63 exit 1
66 # seriously! these checks are here for a reason. the packages from the
67 # reddit ppa aren't built for anything but trusty (14.04) right now, so
68 # if you try and use this install script on another release you're gonna
69 # have a bad time.
70 source /etc/lsb-release
71 if [ "$DISTRIB_ID" != "Ubuntu" -o "$DISTRIB_RELEASE" != "14.04" ]; then
72 echo "ERROR: Only Ubuntu 14.04 is supported."
73 exit 1
76 ###############################################################################
77 # Install prerequisites
78 ###############################################################################
79 $RUNDIR/install_apt.sh
81 $RUNDIR/install_cassandra.sh
82 $RUNDIR/install_zookeeper.sh
84 ###############################################################################
85 # Install and configure the reddit code
86 ###############################################################################
88 [ -x "$(which pip)" ] || easy_install pip
89 pip install -U pip wheel setuptools coverage
90 pushd $REDDIT_CODE/r2
91 sudo python setup.py build
92 python setup.py develop
93 make
94 ln -sf example.ini test.ini
95 popd
97 ###############################################################################
98 # Install services (for local testing only!)
99 # NB: this is otherwise handled in the .travis.yml in before_script
100 ###############################################################################
101 if [ "$ENVIRONMENT" == "vagrant" ]; then
102 # install services (cassandra, postgres, etc.)
103 $RUNDIR/install_services.sh
104 # travis doesn't have mcrouter as a possible service, so we need to
105 # be able to test without that running
106 service mcrouter stop
107 # Configure PostgreSQL
108 $RUNDIR/setup_postgres.sh
109 # Configure Cassandra
110 $RUNDIR/setup_cassandra.sh
111 # Configure RabbitMQ
112 $RUNDIR/setup_rabbitmq.sh
115 ###############################################################################
116 # All done!
117 ###############################################################################
118 cat <<CONCLUSION
120 Congratulations! A base version of reddit is now installed. To run the
121 unit tests:
123 cd src/reddit/r2
124 nosetests
126 CONCLUSION