blob: 88fa69be1c1d2bb5916b6fec05f7550836b229dc [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
19 config.vm.network "forwarded_port", guest: 5556, host: 5556
Akrona7b661d2018-10-09 19:13:45 +020020
21 config.vm.box_download_insecure = true
22
23 # Provisioning of KorAP with a Shell script
24 config.vm.provision "shell", privileged: false, inline: <<-SHELL
Akron228cfa12018-10-01 16:14:41 +020025
Akrona7b661d2018-10-09 19:13:45 +020026 ###############################################
27 echo "Install Packages"
Akron228cfa12018-10-01 16:14:41 +020028
Akrona7b661d2018-10-09 19:13:45 +020029 # Add repository for OpenJDK
30 sudo add-apt-repository ppa:openjdk-r/ppa
Akron228cfa12018-10-01 16:14:41 +020031
Akrona7b661d2018-10-09 19:13:45 +020032 sudo apt-get update
Akron228cfa12018-10-01 16:14:41 +020033
Akrona7b661d2018-10-09 19:13:45 +020034 echo "Install dependencies"
35 sudo apt-get install -qq git
36 sudo apt-get install -qq openjdk-8-jdk
37 sudo apt-get install -qq perlbrew
38 sudo apt-get install -qq emacs
39 sudo apt-get install -qq maven
Akroncc10f9a2018-10-09 19:57:27 +020040 sudo apt-get install -qq nodejs
41 sudo apt-get install -qq npm
42 sudo apt-get install -qq ruby
Akron228cfa12018-10-01 16:14:41 +020043
Akronb9406112018-11-15 19:34:32 +010044
45 ###############################################
46 echo "Stop the server"
47
48 sudo systemctl stop kalamar
49
50 # Kill Kustvakt before restarting
51 if [ -f /home/vagrant/Built/kustvakt.pid ]
52 then
53 echo 'Shutdown Kustvakt server'
54 sudo kill -9 `cat /home/vagrant/Built/kustvakt.pid`
55 fi
56
Akron4d0c9ef2018-11-06 16:49:35 +010057 sudo systemctl disable kustvakt
58 sudo systemctl disable kalamar
59
Akronb9406112018-11-15 19:34:32 +010060
Akrona7b661d2018-10-09 19:13:45 +020061 ###############################################
62 echo "Install Koral"
63 cd ~/
64 if [ -e ./Koral ] && [ -d ./Koral ]
65 then
66 cd Koral
Akronb9406112018-11-15 19:34:32 +010067 git checkout master
68 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +020069 else
70 git clone https://github.com/KorAP/Koral.git Koral
71 cd Koral
72 fi
Akronb9406112018-11-15 19:34:32 +010073
74 # Checkout a specific version
75 git checkout tags/v0.31
76
Akrona7b661d2018-10-09 19:13:45 +020077 mvn clean install -Dhttps.protocols=TLSv1.2
78
79
80 ###############################################
81 echo "Install Krill"
82 cd ~/
83 if [ -e ./Krill ] && [ -d ./Krill ]
84 then
85 cd Krill
Akronb9406112018-11-15 19:34:32 +010086 git checkout master
87 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +020088 else
89 git clone https://github.com/KorAP/Krill.git Krill
90 cd Krill
91 fi
Akronb9406112018-11-15 19:34:32 +010092
93 # Checkout a specific version
94 git checkout tags/v0.58.1
95
Akrona7b661d2018-10-09 19:13:45 +020096 mvn clean install
97
98
99 ###############################################
100 echo "Install Kustvakt"
101 cd ~/
102 if [ -e ./Kustvakt ] && [ -d ./Kustvakt ]
103 then
104 cd Kustvakt
Akronb9406112018-11-15 19:34:32 +0100105 git checkout master
106 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +0200107 else
108 git clone https://github.com/KorAP/Kustvakt.git Kustvakt
109 cd Kustvakt
110 fi
111
Akronb9406112018-11-15 19:34:32 +0100112 # Checkout a specific version
113 git checkout tags/v0.61.3-release
114
Akrona7b661d2018-10-09 19:13:45 +0200115 cd ~/Kustvakt/core
116 mvn clean install
117
118 cd ~/Kustvakt/lite
119 mvn clean package
120
121
122 ###############################################
Akroncc10f9a2018-10-09 19:57:27 +0200123 echo "Install NodeJS"
124 # This is required unfortunately
Akronef285652018-10-10 15:50:29 +0200125 if [ ! -e ~/tmp ]; then
126 mkdir ~/tmp
127 fi
Akroncc10f9a2018-10-09 19:57:27 +0200128 npm set ca null
Akronef285652018-10-10 15:50:29 +0200129 sudo npm install -g n
130 sudo n stable
Akroncc10f9a2018-10-09 19:57:27 +0200131 sudo npm install -g sass
132 sudo npm install -g grunt-cli
133 sudo npm install grunt
134
135
136 ###############################################
Akrona7b661d2018-10-09 19:13:45 +0200137 echo "Install Perlbrew + CPANminus"
138 cd ~/
139
140 perlbrew init
141 echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
142
143 source ~/perl5/perlbrew/etc/bashrc
144
Akrona7b661d2018-10-09 19:13:45 +0200145 perlbrew install -q perl-5.24.0
146
147 perlbrew switch perl-5.24.0
148 perlbrew install-cpanm
149
150
151 ###############################################
152 echo "Install Kalamar server-side dependencies"
Akrona7b661d2018-10-09 19:13:45 +0200153 cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git
154 cpanm git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git
155
156
157 ###############################################
158 echo "Install Kalamar"
Akroncc10f9a2018-10-09 19:57:27 +0200159 cd ~/
Akrona7b661d2018-10-09 19:13:45 +0200160 if [ -e ./Kalamar ] && [ -d ./Kalamar ]
161 then
162 cd Kalamar
Akronb9406112018-11-15 19:34:32 +0100163 git checkout master
164 git fetch --tags
Akrona7b661d2018-10-09 19:13:45 +0200165 else
166 git clone git://github.com/KorAP/Kalamar.git Kalamar
167 cd Kalamar
168 fi
169
Akronb9406112018-11-15 19:34:32 +0100170 # Checkout a specific version
171 git checkout tags/v0.30
172
Akrona7b661d2018-10-09 19:13:45 +0200173 cpanm --installdeps .
174
175 ###############################################
176 # echo "Install Kalamar client-side dependencies"
Akroncc10f9a2018-10-09 19:57:27 +0200177 npm install
178 grunt
Akrona7b661d2018-10-09 19:13:45 +0200179
Akronef285652018-10-10 15:50:29 +0200180
181 ###############################################
182 echo "Prepare Kustvakt"
183 cd ~/
184
185 if [ ! -e ./Built ]; then
186 mkdir Built
187 fi
188
189 # Copy the jar file to the built folder
190 # This will do so for all files - but the last one will be kept
191 find ~/Kustvakt/lite/target/Kustvakt-lite-*.jar -exec mv {} ~/Built/Kustvakt-lite.jar ';'
192
193 # Rewrite the configuration file
194 sed -e 's#^krill\.indexDir\s*=\s*.*$#krill.indexDir=../Kustvakt/sample-index#gm' \
195 -e 's#^server\.port\s*=\s*.*$#server.port=5556#gm' \
196 ~/Kustvakt/lite/src/main/resources/kustvakt-lite.conf \
197 > ~/Built/kustvakt-lite.conf
198
Akronef285652018-10-10 15:50:29 +0200199
Akronef285652018-10-10 15:50:29 +0200200 ###############################################
Akron4d0c9ef2018-11-06 16:49:35 +0100201 echo "Configure Kalamar"
Akronef285652018-10-10 15:50:29 +0200202 cd ~/
203 cd Kalamar
204
205 # Add new configuration
206 echo "{hypnotoad=>{listen=>['http://*:5555']}}" \
207 > kalamar.vagrant.conf
208
209 echo "not really secret" > kalamar.secret
210
Akronb66814e2018-10-17 16:51:11 +0200211 ###############################################
212 echo "Establish systemd"
213
Akronb9406112018-11-15 19:34:32 +0100214 echo "[Unit]
Akronb66814e2018-10-17 16:51:11 +0200215Description=Kustvakt
216After=network.target
217
218[Service]
219User=root
220Type=forking
Akronb9406112018-11-15 19:34:32 +0100221ExecStart=/bin/su - vagrant -c 'cd /home/vagrant/Built ; nohup java -jar Kustvakt-lite.jar & echo" '$!' " > kustvakt.pid'
Akronb66814e2018-10-17 16:51:11 +0200222PIDFile=/home/vagrant/Built/kustvakt.pid
223KillMode=process
224
225[Install]
Akronb9406112018-11-15 19:34:32 +0100226WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kustvakt.service
Akronb66814e2018-10-17 16:51:11 +0200227
228 echo "[Unit]
229Description=Kalamar
230After=network.target
231
232[Service]
233User=root
234Type=forking
235PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid
236ExecStart=/bin/su - vagrant -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'
237ExecStop=/bin/su - vagrant -c 'MOJO_MODE=vagrant /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad -s /home/vagrant/Kalamar/script/kalamar'
238ExecReload=/bin/su - vagrant -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'
239killMode=process
240
241[Install]
242WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service
243
244 sudo systemctl enable kustvakt
245 sudo systemctl enable kalamar
246
Akron4d0c9ef2018-11-06 16:49:35 +0100247 # echo "Start Kustvakt"
248 sudo systemctl start kustvakt
249
250 # echo "Start Kalamar"
251 sudo systemctl start kalamar
252
Akrona7b661d2018-10-09 19:13:45 +0200253 SHELL
Akron228cfa12018-10-01 16:14:41 +0200254end