blob: 7153bd36081be1bf4ab316c94cac931241f23aa6 [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
Akron4d0c9ef2018-11-06 16:49:35 +010044 sudo systemctl disable kustvakt
45 sudo systemctl disable kalamar
46
Akrona7b661d2018-10-09 19:13:45 +020047 ###############################################
48 echo "Install Koral"
49 cd ~/
50 if [ -e ./Koral ] && [ -d ./Koral ]
51 then
52 cd Koral
53 git pull origin master
54 else
55 git clone https://github.com/KorAP/Koral.git Koral
56 cd Koral
57 fi
58 mvn clean install -Dhttps.protocols=TLSv1.2
59
60
61 ###############################################
62 echo "Install Krill"
63 cd ~/
64 if [ -e ./Krill ] && [ -d ./Krill ]
65 then
66 cd Krill
67 git pull origin master
68 else
69 git clone https://github.com/KorAP/Krill.git Krill
70 cd Krill
71 fi
72 mvn clean install
73
74
75 ###############################################
76 echo "Install Kustvakt"
77 cd ~/
78 if [ -e ./Kustvakt ] && [ -d ./Kustvakt ]
79 then
80 cd Kustvakt
81 git pull origin master
82 else
83 git clone https://github.com/KorAP/Kustvakt.git Kustvakt
84 cd Kustvakt
85 fi
86
87 cd ~/Kustvakt/core
88 mvn clean install
89
90 cd ~/Kustvakt/lite
91 mvn clean package
92
93
94 ###############################################
Akroncc10f9a2018-10-09 19:57:27 +020095 echo "Install NodeJS"
96 # This is required unfortunately
Akronef285652018-10-10 15:50:29 +020097 if [ ! -e ~/tmp ]; then
98 mkdir ~/tmp
99 fi
Akroncc10f9a2018-10-09 19:57:27 +0200100 npm set ca null
Akronef285652018-10-10 15:50:29 +0200101 sudo npm install -g n
102 sudo n stable
Akroncc10f9a2018-10-09 19:57:27 +0200103 sudo npm install -g sass
104 sudo npm install -g grunt-cli
105 sudo npm install grunt
106
107
108 ###############################################
Akrona7b661d2018-10-09 19:13:45 +0200109 echo "Install Perlbrew + CPANminus"
110 cd ~/
111
112 perlbrew init
113 echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc
114
115 source ~/perl5/perlbrew/etc/bashrc
116
Akrona7b661d2018-10-09 19:13:45 +0200117 perlbrew install -q perl-5.24.0
118
119 perlbrew switch perl-5.24.0
120 perlbrew install-cpanm
121
122
123 ###############################################
124 echo "Install Kalamar server-side dependencies"
125 cpanm git://github.com/Akron/Mojolicious-Plugin-Search.git
126 cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git
127 cpanm git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git
128
129
130 ###############################################
131 echo "Install Kalamar"
Akroncc10f9a2018-10-09 19:57:27 +0200132 cd ~/
Akrona7b661d2018-10-09 19:13:45 +0200133 if [ -e ./Kalamar ] && [ -d ./Kalamar ]
134 then
135 cd Kalamar
136 git pull origin master
137 else
138 git clone git://github.com/KorAP/Kalamar.git Kalamar
139 cd Kalamar
140 fi
141
142 cpanm --installdeps .
143
144 ###############################################
145 # echo "Install Kalamar client-side dependencies"
Akroncc10f9a2018-10-09 19:57:27 +0200146 npm install
147 grunt
Akrona7b661d2018-10-09 19:13:45 +0200148
Akronef285652018-10-10 15:50:29 +0200149
150 ###############################################
151 echo "Prepare Kustvakt"
152 cd ~/
153
154 if [ ! -e ./Built ]; then
155 mkdir Built
156 fi
157
158 # Copy the jar file to the built folder
159 # This will do so for all files - but the last one will be kept
160 find ~/Kustvakt/lite/target/Kustvakt-lite-*.jar -exec mv {} ~/Built/Kustvakt-lite.jar ';'
161
162 # Rewrite the configuration file
163 sed -e 's#^krill\.indexDir\s*=\s*.*$#krill.indexDir=../Kustvakt/sample-index#gm' \
164 -e 's#^server\.port\s*=\s*.*$#server.port=5556#gm' \
165 ~/Kustvakt/lite/src/main/resources/kustvakt-lite.conf \
166 > ~/Built/kustvakt-lite.conf
167
168 # Start the server
169 cd ~/Built
170
171 # Kill Kustvakt before restarting
172 if [ -f ./kustvakt.pid ]
173 then
174 echo 'Shudown Kustvakt server'
175 kill -9 `cat ./kustvakt.pid`
176 fi
177
Akronef285652018-10-10 15:50:29 +0200178 ###############################################
Akron4d0c9ef2018-11-06 16:49:35 +0100179 echo "Configure Kalamar"
Akronef285652018-10-10 15:50:29 +0200180 cd ~/
181 cd Kalamar
182
183 # Add new configuration
184 echo "{hypnotoad=>{listen=>['http://*:5555']}}" \
185 > kalamar.vagrant.conf
186
187 echo "not really secret" > kalamar.secret
188
Akronb66814e2018-10-17 16:51:11 +0200189 ###############################################
190 echo "Establish systemd"
191
Akron4d0c9ef2018-11-06 16:49:35 +0100192 echo '[Unit]
Akronb66814e2018-10-17 16:51:11 +0200193Description=Kustvakt
194After=network.target
195
196[Service]
197User=root
198Type=forking
Akron4d0c9ef2018-11-06 16:49:35 +0100199ExecStart=/bin/su - vagrant -c \'cd /home/vagrant/Built ; nohup java -jar Kustvakt-lite.jar & echo $! > kustvakt.pid\'
Akronb66814e2018-10-17 16:51:11 +0200200PIDFile=/home/vagrant/Built/kustvakt.pid
201KillMode=process
202
203[Install]
Akron4d0c9ef2018-11-06 16:49:35 +0100204WantedBy=multi-user.target' | sudo tee /lib/systemd/system/kustvakt.service
Akronb66814e2018-10-17 16:51:11 +0200205
206 echo "[Unit]
207Description=Kalamar
208After=network.target
209
210[Service]
211User=root
212Type=forking
213PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid
214ExecStart=/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'
215ExecStop=/bin/su - vagrant -c 'MOJO_MODE=vagrant /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad -s /home/vagrant/Kalamar/script/kalamar'
216ExecReload=/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'
217killMode=process
218
219[Install]
220WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service
221
222 sudo systemctl enable kustvakt
223 sudo systemctl enable kalamar
224
Akron4d0c9ef2018-11-06 16:49:35 +0100225 # echo "Start Kustvakt"
226 sudo systemctl start kustvakt
227
228 # echo "Start Kalamar"
229 sudo systemctl start kalamar
230
Akrona7b661d2018-10-09 19:13:45 +0200231 SHELL
Akron228cfa12018-10-01 16:14:41 +0200232end