/
provision.sh
83 lines (63 loc) · 2.77 KB
/
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
#!/bin/bash
WAGTAIL_ROOT=/vagrant/wagtail
BAKERYDEMO_ROOT=/vagrant/bakerydemo
LIBS_ROOT=/vagrant/libs
VIRTUALENV_DIR=/home/vagrant/.virtualenvs/bakerydemo
PYTHON=$VIRTUALENV_DIR/bin/python
PIP=$VIRTUALENV_DIR/bin/pip
# silence "dpkg-preconfigure: unable to re-open stdin" warnings
export DEBIAN_FRONTEND=noninteractive
# Update APT database
apt-get update -y
# useful tools
apt-get install -y vim git curl gettext build-essential
# Python 3
apt-get install -y python3 python3-dev python3-pip python3-venv
# PIL dependencies
apt-get install -y libjpeg-dev libtiff-dev zlib1g-dev libfreetype6-dev liblcms2-dev
# Redis and PostgreSQL
apt-get install -y redis-server postgresql libpq-dev
# libenchant (spellcheck library for docs)
apt-get install -y libenchant-dev
# Java for Elasticsearch
apt-get install -y openjdk-8-jre-headless
# Create pgsql superuser
su - postgres -c "createuser -s vagrant"
pip3 install -U pip
pip install virtualenvwrapper
# Set up virtualenvwrapper in .bashrc
cat << EOF >> /home/vagrant/.bashrc
export WORKON_HOME=/home/vagrant/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=python3
source /usr/local/bin/virtualenvwrapper.sh
EOF
# bring up a PostgreSQL-enabled bakerydemo instance using the current release version of wagtail
PROJECT_DIR=$BAKERYDEMO_ROOT DEV_USER=vagrant USE_POSTGRESQL=1 $BAKERYDEMO_ROOT/vagrant/provision.sh bakerydemo
# install additional dependencies (including developer-specific ones)
# of wagtail master
su - vagrant -c "cd $WAGTAIL_ROOT && $PIP install -e .[testing,docs] -U"
# install optional packages (so that the full test suite runs)
su - vagrant -c "$PIP install embedly \"elasticsearch>=5.0,<6.0\" django-sendfile"
# install Node.js (for front-end asset building)
# as per instructions on https://github.com/nodesource/distributions
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
# set up our local checkouts of django-modelcluster and Willow
su - vagrant -c "cd $LIBS_ROOT/django-modelcluster && $PYTHON setup.py develop"
su - vagrant -c "cd $LIBS_ROOT/Willow && $PYTHON setup.py develop"
# Install node.js tooling
echo "Installing node.js tooling..."
su - vagrant -c "cd $WAGTAIL_ROOT && npm install && npm run build"
# run additional migrations in wagtail master
su - vagrant -c "$PYTHON $BAKERYDEMO_ROOT/manage.py migrate --noinput"
# Elasticsearch (disabled by default, as it's a resource hog)
echo "Downloading Elasticsearch..."
wget -q https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.3.deb
dpkg -i elasticsearch-5.3.3.deb
rm elasticsearch-5.3.3.deb
# reduce JVM heap size from 2g to 512m
sed -i 's/^\(-Xm[sx]\)2g$/\1512m/g' /etc/elasticsearch/jvm.options
# to enable:
# systemctl enable elasticsearch
# systemctl start elasticsearch
echo "Vagrant setup complete. You can now log in with: vagrant ssh"