Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 1 | # -*- mode: ruby -*- |
| 2 | # vi: set ft=ruby : |
| 3 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 4 | # The "2" in Vagrant.configure configures the configuration version. |
| 5 | # Please don't change it unless you know what you're doing. |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 6 | Vagrant.configure(2) do |config| |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 7 | |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 8 | # https://docs.vagrantup.com. |
| 9 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 10 | # More at https://vagrantcloud.com/search. |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 11 | config.vm.box = "ubuntu/xenial64" |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 12 | |
Akron | 3c9cb42 | 2018-10-19 13:21:39 +0200 | [diff] [blame] | 13 | # Memory size is set for installation of Krill |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 14 | config.vm.provider "virtualbox" do |vb| |
| 15 | vb.customize ["modifyvm", :id, "--memory", "1024"] |
| 16 | end |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 17 | |
| 18 | config.vm.network "forwarded_port", guest: 5555, host: 5555 |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 19 | |
| 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 |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 24 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 25 | ############################################### |
| 26 | echo "Install Packages" |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 27 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 28 | # Add repository for OpenJDK |
| 29 | sudo add-apt-repository ppa:openjdk-r/ppa |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 30 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 31 | sudo apt-get update |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 32 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 33 | 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 |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 39 | sudo apt-get install -qq nodejs |
| 40 | sudo apt-get install -qq npm |
| 41 | sudo apt-get install -qq ruby |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 42 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 43 | |
| 44 | ############################################### |
| 45 | echo "Stop the server" |
| 46 | |
| 47 | sudo systemctl stop kalamar |
| 48 | |
| 49 | # Kill Kustvakt before restarting |
| 50 | if [ -f /home/vagrant/Built/kustvakt.pid ] |
| 51 | then |
| 52 | echo 'Shutdown Kustvakt server' |
| 53 | sudo kill -9 `cat /home/vagrant/Built/kustvakt.pid` |
| 54 | fi |
| 55 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 56 | sudo systemctl disable kustvakt |
| 57 | sudo systemctl disable kalamar |
| 58 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 59 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 60 | ############################################### |
Akron | e048617 | 2018-12-06 16:44:32 +0100 | [diff] [blame] | 61 | echo "Configure Git" |
| 62 | cd ~/ |
| 63 | git config --global user.email "korap+vagrant@ids-mannheim.de" |
| 64 | git config --global user.name "Vagrant" |
| 65 | sudo chown vagrant:vagrant .config |
| 66 | |
| 67 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 68 | echo "Install Koral" |
| 69 | cd ~/ |
| 70 | if [ -e ./Koral ] && [ -d ./Koral ] |
| 71 | then |
| 72 | cd Koral |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 73 | git checkout master |
| 74 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 75 | else |
| 76 | git clone https://github.com/KorAP/Koral.git Koral |
| 77 | cd Koral |
| 78 | fi |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 79 | |
| 80 | # Checkout a specific version |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 81 | git checkout tags/v0.35 |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 82 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 83 | mvn clean install -Dhttps.protocols=TLSv1.2 |
| 84 | |
| 85 | |
| 86 | ############################################### |
| 87 | echo "Install Krill" |
| 88 | cd ~/ |
| 89 | if [ -e ./Krill ] && [ -d ./Krill ] |
| 90 | then |
| 91 | cd Krill |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 92 | git checkout master |
| 93 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 94 | else |
| 95 | git clone https://github.com/KorAP/Krill.git Krill |
| 96 | cd Krill |
| 97 | fi |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 98 | |
| 99 | # Checkout a specific version |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 100 | git checkout tags/v0.59 |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 101 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 102 | mvn clean install |
| 103 | |
| 104 | |
| 105 | ############################################### |
| 106 | echo "Install Kustvakt" |
| 107 | cd ~/ |
| 108 | if [ -e ./Kustvakt ] && [ -d ./Kustvakt ] |
| 109 | then |
| 110 | cd Kustvakt |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 111 | git checkout master |
| 112 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 113 | else |
| 114 | git clone https://github.com/KorAP/Kustvakt.git Kustvakt |
| 115 | cd Kustvakt |
| 116 | fi |
| 117 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 118 | # Checkout a specific version |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 119 | git checkout tags/v0.62.3-release |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 120 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 121 | cd ~/Kustvakt/core |
| 122 | mvn clean install |
| 123 | |
| 124 | cd ~/Kustvakt/lite |
| 125 | mvn clean package |
| 126 | |
| 127 | |
| 128 | ############################################### |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 129 | echo "Install NodeJS" |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 130 | cd ~/ |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 131 | # This is required unfortunately |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 132 | if [ ! -e ~/tmp ]; then |
| 133 | mkdir ~/tmp |
| 134 | fi |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 135 | npm set ca null |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 136 | sudo npm install -g n |
| 137 | sudo n stable |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 138 | sudo npm install -g sass |
| 139 | sudo npm install -g grunt-cli |
| 140 | sudo npm install grunt |
| 141 | |
| 142 | |
| 143 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 144 | echo "Install Perlbrew + CPANminus" |
| 145 | cd ~/ |
| 146 | |
| 147 | perlbrew init |
| 148 | echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc |
| 149 | |
| 150 | source ~/perl5/perlbrew/etc/bashrc |
| 151 | |
Akron | 6778d09 | 2020-01-16 13:08:27 +0100 | [diff] [blame] | 152 | perlbrew install -q perl-5.30.1 |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 153 | |
Akron | 6778d09 | 2020-01-16 13:08:27 +0100 | [diff] [blame] | 154 | perlbrew switch perl-5.30.1 |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 155 | perlbrew install-cpanm |
| 156 | |
| 157 | |
| 158 | ############################################### |
| 159 | echo "Install Kalamar server-side dependencies" |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 160 | cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git |
| 161 | cpanm git://github.com/Akron/Mojolicious-Plugin-TagHelpers-ContentBlock.git |
| 162 | |
Akron | 6778d09 | 2020-01-16 13:08:27 +0100 | [diff] [blame] | 163 | # Install Date::Parse ignoring any problems, as this is only |
| 164 | # used for testing purposes in CHI. |
| 165 | cpanm -f Date::Parse |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 166 | |
| 167 | ############################################### |
| 168 | echo "Install Kalamar" |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 169 | cd ~/ |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 170 | if [ -e ./Kalamar ] && [ -d ./Kalamar ] |
| 171 | then |
| 172 | cd Kalamar |
Akron | 7fb904e | 2019-09-25 13:24:10 +0200 | [diff] [blame] | 173 | git stash |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 174 | git checkout master |
| 175 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 176 | else |
| 177 | git clone git://github.com/KorAP/Kalamar.git Kalamar |
| 178 | cd Kalamar |
| 179 | fi |
| 180 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 181 | # Checkout a specific version |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 182 | git checkout tags/v0.37 |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 183 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 184 | cpanm --installdeps . |
| 185 | |
| 186 | ############################################### |
Akron | 92ff359 | 2019-01-30 20:03:16 +0100 | [diff] [blame] | 187 | # echo "Configure Kalamar for asset building" |
| 188 | |
| 189 | echo "KorAP.Conf = KorAP.Conf || {};\ |
| 190 | require([\ |
| 191 | \'hint/foundries/base\',\ |
| 192 | \'hint/foundries/corenlp\',\ |
| 193 | \'hint/foundries/dereko\',\ |
| 194 | \'hint/foundries/malt\',\ |
| 195 | \'hint/foundries/marmot\',\ |
| 196 | \'hint/foundries/opennlp\',\ |
| 197 | \'hint/foundries/treetagger\'\ |
| 198 | ]);" > kalamar.conf.js |
| 199 | |
| 200 | |
| 201 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 202 | # echo "Install Kalamar client-side dependencies" |
Akron | 6778d09 | 2020-01-16 13:08:27 +0100 | [diff] [blame] | 203 | rm -rf node_modules |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 204 | npm install |
| 205 | grunt |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 206 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 207 | |
| 208 | ############################################### |
| 209 | echo "Prepare Kustvakt" |
| 210 | cd ~/ |
| 211 | |
| 212 | if [ ! -e ./Built ]; then |
| 213 | mkdir Built |
| 214 | fi |
| 215 | |
| 216 | # Copy the jar file to the built folder |
| 217 | # This will do so for all files - but the last one will be kept |
| 218 | find ~/Kustvakt/lite/target/Kustvakt-lite-*.jar -exec mv {} ~/Built/Kustvakt-lite.jar ';' |
| 219 | |
| 220 | # Rewrite the configuration file |
| 221 | sed -e 's#^krill\.indexDir\s*=\s*.*$#krill.indexDir=../Kustvakt/sample-index#gm' \ |
| 222 | -e 's#^server\.port\s*=\s*.*$#server.port=5556#gm' \ |
| 223 | ~/Kustvakt/lite/src/main/resources/kustvakt-lite.conf \ |
| 224 | > ~/Built/kustvakt-lite.conf |
| 225 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 226 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 227 | ############################################### |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 228 | echo "Configure Kalamar" |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 229 | cd ~/ |
| 230 | cd Kalamar |
| 231 | |
| 232 | # Add new configuration |
Akron | ef026dc | 2020-01-21 18:00:48 +0100 | [diff] [blame^] | 233 | echo "{hypnotoad=>{listen=>['http://*:5555']},\ |
| 234 | Kalamar=>{experimental_proxy => 1}}"\ |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 235 | > kalamar.vagrant.conf |
| 236 | |
| 237 | echo "not really secret" > kalamar.secret |
| 238 | |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 239 | ############################################### |
| 240 | echo "Establish systemd" |
| 241 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 242 | echo "[Unit] |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 243 | Description=Kustvakt |
| 244 | After=network.target |
| 245 | |
| 246 | [Service] |
Akron | 01e3c1a | 2019-12-18 10:00:43 +0100 | [diff] [blame] | 247 | User=vagrant |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 248 | Type=forking |
Akron | 01e3c1a | 2019-12-18 10:00:43 +0100 | [diff] [blame] | 249 | ExecStart=/bin/bash -l -c 'cd /home/vagrant/Built ; nohup java -jar Kustvakt-lite.jar & echo" '$!' " > kustvakt.pid' |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 250 | PIDFile=/home/vagrant/Built/kustvakt.pid |
| 251 | KillMode=process |
| 252 | |
| 253 | [Install] |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 254 | WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kustvakt.service |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 255 | |
| 256 | echo "[Unit] |
| 257 | Description=Kalamar |
| 258 | After=network.target |
| 259 | |
| 260 | [Service] |
Akron | 01e3c1a | 2019-12-18 10:00:43 +0100 | [diff] [blame] | 261 | User=vagrant |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 262 | Type=forking |
| 263 | PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid |
Akron | 6778d09 | 2020-01-16 13:08:27 +0100 | [diff] [blame] | 264 | ExecStart=/bin/bash -l -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" " `dirname \\`which perl\\``"/hypnotoad /home/vagrant/Kalamar/script/kalamar' |
| 265 | ExecStop=/bin/bash -l -c 'MOJO_MODE=vagrant " `dirname \\`which perl\\``"/hypnotoad -s /home/vagrant/Kalamar/script/kalamar' |
| 266 | ExecReload=/bin/bash -l -c 'MOJO_MODE=vagrant KALAMAR_API=\"http://localhost:5556/api/\" " `dirname \\`which perl\\``"/hypnotoad /home/vagrant/Kalamar/script/kalamar' |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 267 | killMode=process |
| 268 | |
| 269 | [Install] |
| 270 | WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service |
| 271 | |
| 272 | sudo systemctl enable kustvakt |
| 273 | sudo systemctl enable kalamar |
| 274 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 275 | # echo "Start Kustvakt" |
| 276 | sudo systemctl start kustvakt |
| 277 | |
| 278 | # echo "Start Kalamar" |
| 279 | sudo systemctl start kalamar |
| 280 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 281 | SHELL |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 282 | end |