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