blob: 33f2ce3f571893db7d69ccc1a31103a5008e54c9 [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.
11 config.vm.box = "ubuntu/trusty64"
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
116 perlbrew self-upgrade
117 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
178 echo "Start Kustvakt"
179 nohup java -jar ./Kustvakt-lite.jar & echo $! > ./kustvakt.pid
180
181
182 ###############################################
183 echo "Start Kalamar"
184 cd ~/
185 cd Kalamar
186
187 # Add new configuration
188 echo "{hypnotoad=>{listen=>['http://*:5555']}}" \
189 > kalamar.vagrant.conf
190
191 echo "not really secret" > kalamar.secret
192
193 # Start the server
194 KALAMAR_API="http://localhost:5556/api/" \
195 MOJO_MODE=vagrant \
196 hypnotoad script/kalamar
197
Akrona7b661d2018-10-09 19:13:45 +0200198 SHELL
Akron228cfa12018-10-01 16:14:41 +0200199end