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