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 ###############################################################################
25 if [[ $EUID -ne 0 ]]; then
26 echo "ERROR: Must be run with root privileges."
32 SCRIPTDIR
="$RUNDIR/install"
34 # the canonical source of all installers
35 GITREPO
="https://raw.github.com/reddit/reddit/master/install"
39 "install_cassandra.sh"
41 "install_zookeeper.sh"
51 for item
in ${NEEDED[*]}; do
52 if [ ! -x $SCRIPTDIR/$item ]; then
58 if [ ! -e $SCRIPTDIR/install.cfg
]; then
59 NEEDED
+=("install.cfg")
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."
74 pushd $SCRIPTDIR > /dev
/null
75 for item
in ${NEEDED[*]}; do
76 echo "Grabbing '${item}'..."
77 wget
-q $GITREPO/$item
85 echo "#######################################################################"
86 echo "# Base configuration:"
87 echo "#######################################################################"
88 source $SCRIPTDIR/install.cfg
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)."
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."
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."
103 read -er -n1 -p "proceed? [Y/n]" response
104 if [[ $response =~ ^
[Yy
]$ ||
$response == "" ]]; then
105 echo "Excellent. Here we go!"