blob: a4d9e5da1f9cad10a80409aa8dd3da637c758c7e [file] [log] [blame]
Akron228cfa12018-10-01 16:14:41 +02001# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
Akrona7b661d2018-10-09 19:13:45 +02004# The "2" in Vagrant.configure configures the configuration version.
5# Please don't change it unless you know what you're doing.
Akron228cfa12018-10-01 16:14:41 +02006Vagrant.configure(2) do |config|
Akroncc10f9a2018-10-09 19:57:27 +02007
Akron228cfa12018-10-01 16:14:41 +02008 # https://docs.vagrantup.com.
9
Akrona7b661d2018-10-09 19:13:45 +020010 # More at https://vagrantcloud.com/search.
Akronb66814e2018-10-17 16:51:11 +020011 config.vm.box = "ubuntu/xenial64"
Akron228cfa12018-10-01 16:14:41 +020012
Akron3c9cb422018-10-19 13:21:39 +020013 # Memory size is set for installation of Krill
Akrona7b661d2018-10-09 19:13:45 +020014 config.vm.provider "virtualbox" do |vb|
15 vb.customize ["modifyvm", :id, "--memory", "1024"]
16 end
Akronef285652018-10-10 15:50:29 +020017
18 config.vm.network "forwarded_port", guest: 5555, host: 5555
Akrona7b661d2018-10-09 19:13:45 +020019
20 config.vm.box_download_insecure = true
21
22 # Provisioning of KorAP with a Shell script
23 config.vm.provision "shell", privileged: false, inline: <<-SHELL
Akron228cfa12018-10-01 16:14:41 +020024
Akrona7b661d2018-10-09 19:13:45 +020025 ###############################################
26 echo "Install Packages"
Akron228cfa12018-10-01 16:14:41 +020027
Akrona7b661d2018-10-09 19:13:45 +020028 # Add repository for OpenJDK
29 sudo add-apt-repository ppa:openjdk-r/ppa
Akron228cfa12018-10-01 16:14:41 +020030
Akrona7b661d2018-10-09 19:13:45 +020031 sudo apt-get update
Akron228cfa12018-10-01 16:14:41 +020032
Akrona7b661d2018-10-09 19:13:45 +020033 echo "Install dependencies"
34 sudo apt-get install -qq git
35 sudo apt-get install -qq openjdk-8-jdk
36 sudo apt-get install -qq perlbrew
37 sudo apt-get install -qq emacs
38 sudo apt-get install -qq maven
Akroncc10f9a2018-10-09 19:57:27 +020039 sudo apt-get install -qq nodejs
40 sudo apt-get install -qq npm
41 sudo apt-get install -qq ruby
Akron228cfa12018-10-01 16:14:41 +020042
Akronb9406112018-11-15 19:34:32 +010043
44 ###############################################
45 echo "Stop the server"
46
47 sudo systemctl stop kalamar
48
49 # Kill Kustvakt before restarting
50 if [ -f /home/vagrant/Built/kustvakt.pid ]
51 then
52 echo 'Shutdown Kustvakt server'
53 sudo kill -9 `cat /home/vagrant/Built/kustvakt.pid`
54 fi
55
Akron4d0c9ef2018-11-06 16:49:35 +010056 sudo systemctl disable kustvakt
57 sudo systemctl disable kalamar
58
Akronb9406112018-11-15 19:34:32 +010059
Akrona7b661d2018-10-09 19:13:45 +020060 ###############################################
Akrone0486172018-12-06 16:44:32 +010061 echo "Configure Git"
62 cd ~/
63 git config --global user.email "korap+vagrant@ids-mannheim.de"
64 git config --global user.name "Vagrant"
65 sudo chown vagrant:vagrant .config
66
67 ###############################################
Akrona7b661d2018-10-09 19:13:45 +020068 echo "Install Koral"
69 cd ~/
70 if [ -e ./Koral ] && [ -d ./Koral ]
71 then
72 cd Koral
Akronb9406112018-11-15 19:34:32 +010073 git checkout master
74 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +020075 else
76 git clone https://github.com/KorAP/Koral.git Koral
77 cd Koral
78 fi
Akronb9406112018-11-15 19:34:32 +010079
80 # Checkout a specific version
Akron7fb904e2019-09-25 13:24:10 +020081 git checkout tags/v0.34
Akronb9406112018-11-15 19:34:32 +010082
Akrona7b661d2018-10-09 19:13:45 +020083 mvn clean install -Dhttps.protocols=TLSv1.2
84
85
86 ###############################################
87 echo "Install Krill"
88 cd ~/
89 if [ -e ./Krill ] && [ -d ./Krill ]
90 then
91 cd Krill
Akronb9406112018-11-15 19:34:32 +010092 git checkout master
93 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +020094 else
95 git clone https://github.com/KorAP/Krill.git Krill
96 cd Krill
97 fi
Akronb9406112018-11-15 19:34:32 +010098
99 # Checkout a specific version
Akron7fb904e2019-09-25 13:24:10 +0200100 git checkout tags/v0.58.7
Akronb9406112018-11-15 19:34:32 +0100101
Akrona7b661d2018-10-09 19:13:45 +0200102 mvn clean install
103
104
105 ###############################################
106 echo "Install Kustvakt"
107 cd ~/
108 if [ -e ./Kustvakt ] && [ -d ./Kustvakt ]
109 then
110 cd Kustvakt
Akronb9406112018-11-15 19:34:32 +0100111 git checkout master
112 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +0200113 else
114 git clone https://github.com/KorAP/Kustvakt.git Kustvakt
115 cd Kustvakt
116 fi
117
Akronb9406112018-11-15 19:34:32 +0100118 # Checkout a specific version
Akron7fb904e2019-09-25 13:24:10 +0200119 git checkout tags/v0.62.1-release
Akronb9406112018-11-15 19:34:32 +0100120
Akrona7b661d2018-10-09 19:13:45 +0200121 cd ~/Kustvakt/core
122 mvn clean install
123
124 cd ~/Kustvakt/lite
125 mvn clean package
126
127
128 ###############################################
Akroncc10f9a2018-10-09 19:57:27 +0200129 echo "Install NodeJS"
130 # This is required unfortunately
Akronef285652018-10-10 15:50:29 +0200131 if [ ! -e ~/tmp ]; then
132 mkdir ~/tmp
133 fi
Akroncc10f9a2018-10-09 19:57:27 +0200134 npm set ca null
Akronef285652018-10-10 15:50:29 +0200135 sudo npm install -g n
136 sudo n stable
Akroncc10f9a2018-10-09 19:57:27 +0200137 sudo npm install -g sass
138 sudo npm install -g grunt-cli
139 sudo npm install grunt
140
141
142 ###############################################
Akrona7b661d2018-10-09 19:13:45 +0200143 echo "Install Perlbrew + CPANminus"
144 cd ~/
145
146 perlbrew init
147 echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
148
149 source ~/perl5/perlbrew/etc/bashrc
150
Akrona7b661d2018-10-09 19:13:45 +0200151 perlbrew install -q perl-5.24.0
152
153 perlbrew switch perl-5.24.0
154 perlbrew install-cpanm
155
156
157 ###############################################
158 echo "Install Kalamar server-side dependencies"
Akrona7b661d2018-10-09 19:13:45 +0200159 cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git
160 cpanm git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git
161
162
163 ###############################################
164 echo "Install Kalamar"
Akroncc10f9a2018-10-09 19:57:27 +0200165 cd ~/
Akrona7b661d2018-10-09 19:13:45 +0200166 if [ -e ./Kalamar ] && [ -d ./Kalamar ]
167 then
168 cd Kalamar
Akron7fb904e2019-09-25 13:24:10 +0200169 git stash
Akronb9406112018-11-15 19:34:32 +0100170 git checkout master
171 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +0200172 else
173 git clone git://github.com/KorAP/Kalamar.git Kalamar
174 cd Kalamar
175 fi
176
Akronb9406112018-11-15 19:34:32 +0100177 # Checkout a specific version
Akron7fb904e2019-09-25 13:24:10 +0200178 git checkout tags/v0.36
Akronb9406112018-11-15 19:34:32 +0100179
Akrona7b661d2018-10-09 19:13:45 +0200180 cpanm --installdeps .
181
182 ###############################################
Akron92ff3592019-01-30 20:03:16 +0100183 # echo "Configure Kalamar for asset building"
184
185 echo "KorAP.Conf = KorAP.Conf || {};\
186 require([\
187 \'hint/foundries/base\',\
188 \'hint/foundries/corenlp\',\
189 \'hint/foundries/dereko\',\
190 \'hint/foundries/malt\',\
191 \'hint/foundries/marmot\',\
192 \'hint/foundries/opennlp\',\
193 \'hint/foundries/treetagger\'\
194 ]);" > kalamar.conf.js
195
196
197 ###############################################
Akrona7b661d2018-10-09 19:13:45 +0200198 # echo "Install Kalamar client-side dependencies"
Akroncc10f9a2018-10-09 19:57:27 +0200199 npm install
200 grunt
Akrona7b661d2018-10-09 19:13:45 +0200201
Akronef285652018-10-10 15:50:29 +0200202
203 ###############################################
204 echo "Prepare Kustvakt"
205 cd ~/
206
207 if [ ! -e ./Built ]; then
208 mkdir Built
209 fi
210
211 # Copy the jar file to the built folder
212 # This will do so for all files - but the last one will be kept
213 find ~/Kustvakt/lite/target/Kustvakt-lite-*.jar -exec mv {} ~/Built/Kustvakt-lite.jar ';'
214
215 # Rewrite the configuration file
216 sed -e 's#^krill\.indexDir\s*=\s*.*$#krill.indexDir=../Kustvakt/sample-index#gm' \
217 -e 's#^server\.port\s*=\s*.*$#server.port=5556#gm' \
218 ~/Kustvakt/lite/src/main/resources/kustvakt-lite.conf \
219 > ~/Built/kustvakt-lite.conf
220
Akronef285652018-10-10 15:50:29 +0200221
Akronef285652018-10-10 15:50:29 +0200222 ###############################################
Akron4d0c9ef2018-11-06 16:49:35 +0100223 echo "Configure Kalamar"
Akronef285652018-10-10 15:50:29 +0200224 cd ~/
225 cd Kalamar
226
227 # Add new configuration
228 echo "{hypnotoad=>{listen=>['http://*:5555']}}" \
229 > kalamar.vagrant.conf
230
231 echo "not really secret" > kalamar.secret
232
Akronb66814e2018-10-17 16:51:11 +0200233 ###############################################
234 echo "Establish systemd"
235
Akronb9406112018-11-15 19:34:32 +0100236 echo "[Unit]
Akronb66814e2018-10-17 16:51:11 +0200237Description=Kustvakt
238After=network.target
239
240[Service]
Akron01e3c1a2019-12-18 10:00:43 +0100241User=vagrant
Akronb66814e2018-10-17 16:51:11 +0200242Type=forking
Akron01e3c1a2019-12-18 10:00:43 +0100243ExecStart=/bin/bash -l -c 'cd /home/vagrant/Built ; nohup java -jar Kustvakt-lite.jar & echo" '$!' " > kustvakt.pid'
Akronb66814e2018-10-17 16:51:11 +0200244PIDFile=/home/vagrant/Built/kustvakt.pid
245KillMode=process
246
247[Install]
Akronb9406112018-11-15 19:34:32 +0100248WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kustvakt.service
Akronb66814e2018-10-17 16:51:11 +0200249
250 echo "[Unit]
251Description=Kalamar
252After=network.target
253
254[Service]
Akron01e3c1a2019-12-18 10:00:43 +0100255User=vagrant
Akronb66814e2018-10-17 16:51:11 +0200256Type=forking
257PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid
Akron01e3c1a2019-12-18 10:00:43 +0100258ExecStart=/bin/bash -l -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad /home/vagrant/Kalamar/script/kalamar'
259ExecStop=/bin/bash -l -c 'MOJO_MODE=vagrant /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad -s /home/vagrant/Kalamar/script/kalamar'
260ExecReload=/bin/bash -l -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad /home/vagrant/Kalamar/script/kalamar'
Akronb66814e2018-10-17 16:51:11 +0200261killMode=process
262
263[Install]
264WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service
265
266 sudo systemctl enable kustvakt
267 sudo systemctl enable kalamar
268
Akron4d0c9ef2018-11-06 16:49:35 +0100269 # echo "Start Kustvakt"
270 sudo systemctl start kustvakt
271
272 # echo "Start Kalamar"
273 sudo systemctl start kalamar
274
Akrona7b661d2018-10-09 19:13:45 +0200275 SHELL
Akron228cfa12018-10-01 16:14:41 +0200276end