Embeds: Add missing window.r object
[reddit.git] / install-reddit.sh
blob2df45c731a05ec9af5a472ee9f98ac4bb288087f
1 #!/bin/bash
2 ###############################################################################
3 # reddit dev environment installer
4 # --------------------------------
5 # This script installs a reddit stack suitable for development. DO NOT run this
6 # on a system that you use for other purposes as it might delete important
7 # files, truncate your databases, and otherwise do mean things to you.
9 # By default, this script will install the reddit code in the current user's
10 # home directory and all of its dependencies (including libraries and database
11 # servers) at the system level. The installed reddit will expect to be visited
12 # on the domain "reddit.local" unless specified otherwise. Configuring name
13 # resolution for the domain is expected to be done outside the installed
14 # environment (e.g. in your host machine's /etc/hosts file) and is not
15 # something this script handles.
17 # Several configuration options (listed in the "Configuration" section below)
18 # are overridable with environment variables. e.g.
20 # sudo REDDIT_DOMAIN=example.com ./install/reddit.sh
22 ###############################################################################
23 set -e
25 # load configuration
26 RUNDIR=$(dirname $0)
27 SCRIPTDIR="$RUNDIR/install"
29 # the canonical source of all installers
30 GITREPO="https://raw.github.com/reddit/reddit/master/install"
31 NEEDED=(
32 "install.cfg"
33 "done.sh"
34 "install_apt.sh"
35 "install_cassandra.sh"
36 "install_services.sh"
37 "reddit.sh"
38 "setup_cassandra.sh"
39 "setup_mcrouter.sh"
40 "setup_postgres.sh"
41 "setup_rabbitmq.sh"
42 "travis.sh"
45 MISSING=""
46 for item in ${NEEDED[*]}; do
47 if [ ! -x $SCRIPTDIR/$item ]; then
48 MISSING="1"
49 break
51 done
53 function important() {
54 echo -e "\033[31m${1}\033[0m"
57 if [ "$MISSING" != "" ]; then
58 important "It looks like you're installing without a local repo. No problem!"
59 important "We're going to grab the scripts we need and show you where you can"
60 important "edit the config to suit your environment."
62 mkdir -p $SCRIPTDIR
63 pushd $SCRIPTDIR > /dev/null
64 for item in ${NEEDED[*]}; do
65 echo "Grabbing '${item}'..."
66 wget -q $GITREPO/$item
67 chmod +x $item
68 done
69 popd > /dev/null
71 echo "Done!"
74 echo "#######################################################################"
75 echo "# Base configuration:"
76 echo "#######################################################################"
77 source $SCRIPTDIR/install.cfg
78 set +x
80 echo
81 important "Before proceeding, make sure that these look reasonable. If not,"
82 important "you can either edit install/install.cfg or set overrides when running"
83 important "(they will be respected)."
84 echo
85 important "Seriously, if this is your first time installing, stop here and read"
86 important "the script (install/reddit.sh) and that config. It's got some helpful"
87 important "information that can prevent common issues."
88 echo
89 important "Resolving to the appropriate domain name is beyond the scope of this document,"
90 important "but the easiest thing is probably editing /etc/hosts on the host machine."
91 echo
92 read -er -n1 -p "proceed? [Y/n]" response
93 if [[ $response =~ ^[Yy]$ || $response == "" ]]; then
94 echo "Excellent. Here we go. We're going to need sudo for this one:"
95 sudo $SCRIPTDIR/reddit.sh