-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
129 lines (102 loc) · 4.36 KB
/
setup.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
set -e
>&2 echo "*** Installing apt dependencies"
sudo apt-get update -q
sudo apt-get install -qy git unrtf rabbitmq-server python-pip python-dev libxml2-dev libxslt-dev lib32z1-dev postgresql postgresql-server-dev-9.3 postgresql-contrib-9.3 python-virtualenv frog frogdata ucto
# Install elasticsearch first to give it time to start up
if ! type "java" > /dev/null 2>&1; then
>&2 echo "*** Installing java"
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get -qq update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
# even with -qq it keeps outputting stupid progress dots. I blame Oracle.
sudo apt-get install -qqy oracle-java8-installer
fi
sudo rm -f /var/log/elasticsearch/elasticsearch.log
if [ ! -d "/usr/share/elasticsearch" ]; then
>&2 echo "*** Install elastic"
cd /tmp
# Download and install elasticsearch
wget -q "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb"
sudo dpkg -i elasticsearch-1.3.2.deb
# Install plugins
cd /usr/share/elasticsearch
sudo bin/plugin -s -install elasticsearch/elasticsearch-lang-python/2.3.0
sudo bin/plugin -s -install elasticsearch/elasticsearch-analysis-icu/2.3.0
sudo bin/plugin -s -install mobz/elasticsearch-head
sudo wget -q http://hmbastiaan.nl/martijn/amcat/hitcount.jar
# Allow dynamic scripting
echo -e "\nscript.disable_dynamic: false" | sudo tee -a /etc/elasticsearch/elasticsearch.yml
# Monkey-patch startup file to add hit count
sudo sed -i 's/^\(ES_HOME.*\)$/\1\nES_CLASSPATH=$ES_HOME\/hitcount.jar\nexport ES_CLASSPATH/' /etc/init.d/elasticsearch
sudo sed -i 's/\(DAEMON_OPTS=.*\)"$/\1 -Des.index.similarity.default.type=nl.vu.amcat.HitCountSimilarityProvider"/' /etc/init.d/elasticsearch
fi
sudo service elasticsearch restart
function provision_git {
if [ ! -d "/vagrant/$2" ]; then
>&2 echo "*** Cloning $2"
git clone https://github.com/$1/$2.git /vagrant/$2
else
>&2 echo "*** Pulling $2"
cd /vagrant/$2
git pull
fi
}
provision_git amcat amcat
provision_git vanatteveldt saf
provision_git vanatteveldt xtas
cd /vagrant/xtas
git checkout child_corenlp
if [ ! -d "/home/vagrant/amcat-env" ]; then
>&2 echo "*** Installing python virtual environment"
virtualenv ~/amcat-env
fi
>&2 echo "*** Installing pip modules"
. ~/amcat-env/bin/activate
pip install -r /vagrant/amcat/requirements.txt
# xtas pip req
pip install toolz nltk
>&2 echo "*** Getting static files (javascript) via bower"
if ! type "bower" > /dev/null 2>&1; then
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -qy nodejs
sudo npm install -g bower
fi
cd /vagrant/amcat
bower install -s
if ! psql amcat -c '\q' 2>&1; then
>&2 echo "*** Setup database"
sudo -u postgres createuser -s $USER
createdb amcat
fi
if [ ! -d "/home/vagrant/Alpino" ]; then
>&2 echo "*** Download alpino"
cd /home/vagrant
curl -s http://www.let.rug.nl/vannoord/alp/Alpino/binary/versions/Alpino-x86_64-linux-glibc2.5-20563-sicstus.tar.gz | tar xvz
fi
export PYTHONPATH=/vagrant/amcat:/vagrant/saf:/vagrant/xtas
export ALPINO_HOME=/home/vagrant/Alpino
export DJANGO_SETTINGS_MODULE=settings
while ! grep -q "started$" /var/log/elasticsearch/elasticsearch.log; do
>&2 echo "*** Waiting for elastic"
sleep 5
done
>&2 echo "*** django syncdb"
python -m amcat.manage syncdb
>&2 echo "*** starting runserver on port 8001 in screen process"
screen -S runserver -X quit || true
screen -S runserver -d -m python -m amcat.manage runserver 0.0.0.0:8001
>&2 echo "*** starting celery worker in screen process"
screen -S amcat_celery -X quit || true
screen -S amcat_celery -d -m celery -A amcat.amcatcelery worker -l info -Q amcat
>&2 echo "*** starting xtas worker in screen process"
screen -S xtas_celery -X quit || true
screen -S xtas_celery -d -m celery -A xtas -l INFO worker -Q xtas --concurrency 1
>&2 echo "*** starting frog in screen process"
screen -S frog -X quit || true
screen -S frog -d -m frog -S 9887 --skip=p
>&2 echo "*** Done!"
>&2 echo "Use vagrant ssh, screen -list, and screen -r to connect to background processes"
>&2 echo "Elastic head is listening on http://localhost:9201/_plugin/head"
>&2 echo "AmCAT should be reachable on http://localhost:8001 (it might take a minute)."
>&2 echo "You can login on using username amcat, password amcat"