forked from mozilla/dxr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vagrant_provision.sh
131 lines (112 loc) · 5.02 KB
/
vagrant_provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
# Shell script to provision the vagrant box
#
# This is idempotent, even though I'm not sure the shell provisioner requires
# it to be.
set -e
set -x
# Elasticsearch isn't in Debian proper yet, so we get it from
# elasticsearch.org's repo.
wget -qO - https://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -
echo 'deb http://packages.elasticsearch.org/elasticsearch/1.4/debian stable main' > /etc/apt/sources.list.d/elasticsearch.list
apt-get update
# clean out redundant packages from vagrant base image
apt-get autoremove -y
# Configure locales:
apt-get install -y language-pack-en
# node and npm:
apt-get install -y npm
# Homogenize binary name with production RHEL:
ln -sf /usr/bin/nodejs /usr/local/bin/node
# For building docs:
apt-get install -y graphviz
# Python:
apt-get install -y libapache2-mod-wsgi python-pip python-virtualenv python2.7-dev
# Build a virtualenv, and install requirements:
VENV=/home/vagrant/venv
sudo -H -u vagrant -s -- <<THEEND
virtualenv $VENV
source $VENV/bin/activate
cd ~vagrant/dxr
./peep.py install -r requirements.txt
python setup.py develop
pip install pdbpp nose-progressive Sphinx==1.3.1
THEEND
# Activate the virtualenv all the time:
grep /bin/activate .bashrc > /dev/null || echo ". $VENV/bin/activate" >> /home/vagrant/.bashrc
if [ ! -e ~vagrant/.pdbrc.py ]; then
cat >~vagrant/.pdbrc.py <<THEEND
from pdb import DefaultConfig
class Config(DefaultConfig):
#highlight = False
current_line_color = 43
sticky_by_default = True
bg = 'light'
THEEND
fi
# Apache:
apt-get install -y apache2-dev apache2
mkdir -p /etc/apache2/sites-enabled
if [ ! -e /etc/apache2/sites-enabled/dxr.conf ]; then
cat >/etc/apache2/sites-enabled/dxr.conf <<THEEND
# This is an example of serving a DXR target directory with Apache. To try it
# out, go into tests/test_basic and run "make". Everything but a few static
# files is delegated to a WSGI process.
#
# This should be adaptable to serve at non-root positions in the URL hierarchy.
<VirtualHost *:80>
# Serve static resources, like CSS and images, with plain Apache:
Alias /static/ /home/vagrant/dxr/dxr/static/
# We used to make special efforts to also serve the static pages of
# HTML-formatted source code from the tree via plain Apache, but that
# tangle of RewriteRules saved us only about 20ms per request. You can do
# it if you're on a woefully underpowered machine, but I'm not maintaining
# it.
# Tell this instance of DXR where its target folder is:
SetEnv DXR_FOLDER /home/vagrant/dxr/tests/test_basic/target/
# On a production machine, you'd typically do "python setup.py install"
# rather than "python setup.py develop", so this would point inside your
# site-packages directory.
WSGIScriptAlias / /home/vagrant/dxr/dxr/dxr.wsgi
</VirtualHost>
THEEND
chmod 0644 /etc/apache2/sites-enabled/dxr.conf
fi
a2enmod rewrite
a2enmod proxy
a2enmod wsgi
a2dissite 000-default
# mercurial
apt-get install -y mercurial
# DXR itself:
# pkg-config is so (trilite's?) make clean works.
apt-get install -y git llvm-3.5 libclang-3.5-dev clang-3.5 pkg-config
# --force overrides any older-version LLVM alternative lying around, letting
# us upgrade by provisioning rather than destroying the whole box:
update-alternatives --force --install /usr/local/bin/llvm-config llvm-config /usr/bin/llvm-config-3.5 0
# There is no clang++ until we do this:
update-alternatives --force --install /usr/local/bin/clang++ clang++ /usr/bin/clang++-3.5 0
# And we might as well make a clang link so we can compile mozilla-central:
update-alternatives --force --install /usr/local/bin/clang clang /usr/bin/clang-3.5 0
# Elasticsearch:
apt-get install -y openjdk-7-jdk elasticsearch
# Make it keep to itself, rather than forming a cluster with everything on the
# subnet:
sed -i 's/#\(discovery\.zen\.ping\.multicast\.enabled: false\)/\1/' /etc/elasticsearch/elasticsearch.yml
sed -i 's/#network\.bind_host: 192\.168\.0\.1/network.bind_host: 127.0.0.1/' /etc/elasticsearch/elasticsearch.yml
# Cut RAM so it doesn't take up the whole VM. This should be MUCH bigger for
# production.
sed -i 's/#ES_HEAP_SIZE=2g/ES_HEAP_SIZE=128m/' /etc/init.d/elasticsearch
# And don't swap:
sed -i 's/#\(bootstrap\.mlockall: true\)/\1/' /etc/elasticsearch/elasticsearch.yml
# And let us use JS in request payloads:
grep 'script.disable_dynamic: false' /etc/elasticsearch/elasticsearch.yml > /dev/null || echo 'script.disable_dynamic: false' >> /etc/elasticsearch/elasticsearch.yml
# Come up on startup:
update-rc.d elasticsearch defaults 95 10
[ ! -d /usr/share/elasticsearch/plugins/lang-javascript ] && /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-lang-javascript/2.4.1
/etc/init.d/elasticsearch start
# Install Rust in /usr/local:
curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly --date=2015-06-14 --yes
# Following the Nightly channel gives us early warning of changes that would
# break DXR. But if this happens often enough that it's disruptive to the goal
# of testing DXR itself, pin this to a known-working --revision.