LinkJsonTemplate: fixups
[reddit.git] / install-reddit.sh
blob6ca5e40b42d39d4d21a3730054ba49a85a4d9a0c
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 if [[ $EUID -ne 0 ]]; then
26 echo "ERROR: Must be run with root privileges."
27 exit 1
30 # load configuration
31 RUNDIR=$(dirname $0)
32 SCRIPTDIR="$RUNDIR/install"
34 # the canonical source of all installers
35 GITREPO="https://raw.github.com/reddit/reddit/master/install"
36 NEEDED=(
37 "done.sh"
38 "install_apt.sh"
39 "install_cassandra.sh"
40 "install_services.sh"
41 "install_zookeeper.sh"
42 "reddit.sh"
43 "setup_cassandra.sh"
44 "setup_mcrouter.sh"
45 "setup_postgres.sh"
46 "setup_rabbitmq.sh"
47 "travis.sh"
50 MISSING=""
51 for item in ${NEEDED[*]}; do
52 if [ ! -x $SCRIPTDIR/$item ]; then
53 MISSING="1"
54 break
56 done
58 if [ ! -e $SCRIPTDIR/install.cfg ]; then
59 NEEDED+=("install.cfg")
60 MISSING="1"
64 function important() {
65 echo -e "\033[31m${1}\033[0m"
68 if [ "$MISSING" != "" ]; then
69 important "It looks like you're installing without a local repo. No problem!"
70 important "We're going to grab the scripts we need and show you where you can"
71 important "edit the config to suit your environment."
73 mkdir -p $SCRIPTDIR
74 pushd $SCRIPTDIR > /dev/null
75 for item in ${NEEDED[*]}; do
76 echo "Grabbing '${item}'..."
77 wget -q $GITREPO/$item
78 chmod +x $item
79 done
80 popd > /dev/null
82 echo "Done!"
85 echo "#######################################################################"
86 echo "# Base configuration:"
87 echo "#######################################################################"
88 source $SCRIPTDIR/install.cfg
89 set +x
91 echo
92 important "Before proceeding, make sure that these look reasonable. If not,"
93 important "you can either edit install/install.cfg or set overrides when running"
94 important "(they will be respected)."
95 echo
96 important "Seriously, if this is your first time installing, stop here and read"
97 important "the script (install/reddit.sh) and that config. It's got some helpful"
98 important "information that can prevent common issues."
99 echo
100 important "Resolving to the appropriate domain name is beyond the scope of this document,"
101 important "but the easiest thing is probably editing /etc/hosts on the host machine."
102 echo
103 read -er -n1 -p "proceed? [Y/n]" response
104 if [[ $response =~ ^[Yy]$ || $response == "" ]]; then
105 echo "Excellent. Here we go!"
106 $SCRIPTDIR/reddit.sh