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 | 228cfa1 | 2018-10-01 16:14:41 +0200 | [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 |
| 19 | config.vm.network "forwarded_port", guest: 5556, host: 5556 |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 20 | |
| 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 |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 25 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 26 | ############################################### |
| 27 | echo "Install Packages" |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 28 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 29 | # Add repository for OpenJDK |
| 30 | sudo add-apt-repository ppa:openjdk-r/ppa |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 31 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 32 | sudo apt-get update |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 33 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 34 | 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 |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 40 | sudo apt-get install -qq nodejs |
| 41 | sudo apt-get install -qq npm |
| 42 | sudo apt-get install -qq ruby |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 43 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 44 | |
| 45 | ############################################### |
| 46 | echo "Stop the server" |
| 47 | |
| 48 | sudo systemctl stop kalamar |
| 49 | |
| 50 | # Kill Kustvakt before restarting |
| 51 | if [ -f /home/vagrant/Built/kustvakt.pid ] |
| 52 | then |
| 53 | echo 'Shutdown Kustvakt server' |
| 54 | sudo kill -9 `cat /home/vagrant/Built/kustvakt.pid` |
| 55 | fi |
| 56 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 57 | sudo systemctl disable kustvakt |
| 58 | sudo systemctl disable kalamar |
| 59 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 60 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 61 | ############################################### |
Akron | e048617 | 2018-12-06 16:44:32 +0100 | [diff] [blame^] | 62 | echo "Configure Git" |
| 63 | cd ~/ |
| 64 | git config --global user.email "korap+vagrant@ids-mannheim.de" |
| 65 | git config --global user.name "Vagrant" |
| 66 | sudo chown vagrant:vagrant .config |
| 67 | |
| 68 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 69 | echo "Install Koral" |
| 70 | cd ~/ |
| 71 | if [ -e ./Koral ] && [ -d ./Koral ] |
| 72 | then |
| 73 | cd Koral |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 74 | git checkout master |
| 75 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 76 | else |
| 77 | git clone https://github.com/KorAP/Koral.git Koral |
| 78 | cd Koral |
| 79 | fi |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 80 | |
| 81 | # Checkout a specific version |
| 82 | git checkout tags/v0.31 |
| 83 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 84 | mvn clean install -Dhttps.protocols=TLSv1.2 |
| 85 | |
| 86 | |
| 87 | ############################################### |
| 88 | echo "Install Krill" |
| 89 | cd ~/ |
| 90 | if [ -e ./Krill ] && [ -d ./Krill ] |
| 91 | then |
| 92 | cd Krill |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 93 | git checkout master |
| 94 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 95 | else |
| 96 | git clone https://github.com/KorAP/Krill.git Krill |
| 97 | cd Krill |
| 98 | fi |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 99 | |
| 100 | # Checkout a specific version |
Akron | e048617 | 2018-12-06 16:44:32 +0100 | [diff] [blame^] | 101 | git checkout tags/v0.58.2 |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 102 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 103 | mvn clean install |
| 104 | |
| 105 | |
| 106 | ############################################### |
| 107 | echo "Install Kustvakt" |
| 108 | cd ~/ |
| 109 | if [ -e ./Kustvakt ] && [ -d ./Kustvakt ] |
| 110 | then |
| 111 | cd Kustvakt |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 112 | git checkout master |
| 113 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 114 | else |
| 115 | git clone https://github.com/KorAP/Kustvakt.git Kustvakt |
| 116 | cd Kustvakt |
| 117 | fi |
| 118 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 119 | # Checkout a specific version |
Akron | e048617 | 2018-12-06 16:44:32 +0100 | [diff] [blame^] | 120 | git checkout tags/v0.61.4-release |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 121 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 122 | cd ~/Kustvakt/core |
| 123 | mvn clean install |
| 124 | |
| 125 | cd ~/Kustvakt/lite |
| 126 | mvn clean package |
| 127 | |
| 128 | |
| 129 | ############################################### |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 130 | echo "Install NodeJS" |
| 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 | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 152 | perlbrew install -q perl-5.24.0 |
| 153 | |
| 154 | perlbrew switch perl-5.24.0 |
| 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 | |
| 163 | |
| 164 | ############################################### |
| 165 | echo "Install Kalamar" |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 166 | cd ~/ |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 167 | if [ -e ./Kalamar ] && [ -d ./Kalamar ] |
| 168 | then |
| 169 | cd Kalamar |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 170 | git checkout master |
| 171 | git fetch --tags |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 172 | else |
| 173 | git clone git://github.com/KorAP/Kalamar.git Kalamar |
| 174 | cd Kalamar |
| 175 | fi |
| 176 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 177 | # Checkout a specific version |
Akron | e048617 | 2018-12-06 16:44:32 +0100 | [diff] [blame^] | 178 | git checkout tags/v0.31 |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 179 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 180 | cpanm --installdeps . |
| 181 | |
| 182 | ############################################### |
| 183 | # echo "Install Kalamar client-side dependencies" |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 184 | npm install |
| 185 | grunt |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 186 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 187 | |
| 188 | ############################################### |
| 189 | echo "Prepare Kustvakt" |
| 190 | cd ~/ |
| 191 | |
| 192 | if [ ! -e ./Built ]; then |
| 193 | mkdir Built |
| 194 | fi |
| 195 | |
| 196 | # Copy the jar file to the built folder |
| 197 | # This will do so for all files - but the last one will be kept |
| 198 | find ~/Kustvakt/lite/target/Kustvakt-lite-*.jar -exec mv {} ~/Built/Kustvakt-lite.jar ';' |
| 199 | |
| 200 | # Rewrite the configuration file |
| 201 | sed -e 's#^krill\.indexDir\s*=\s*.*$#krill.indexDir=../Kustvakt/sample-index#gm' \ |
| 202 | -e 's#^server\.port\s*=\s*.*$#server.port=5556#gm' \ |
| 203 | ~/Kustvakt/lite/src/main/resources/kustvakt-lite.conf \ |
| 204 | > ~/Built/kustvakt-lite.conf |
| 205 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 206 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 207 | ############################################### |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 208 | echo "Configure Kalamar" |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 209 | cd ~/ |
| 210 | cd Kalamar |
| 211 | |
| 212 | # Add new configuration |
| 213 | echo "{hypnotoad=>{listen=>['http://*:5555']}}" \ |
| 214 | > kalamar.vagrant.conf |
| 215 | |
| 216 | echo "not really secret" > kalamar.secret |
| 217 | |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 218 | ############################################### |
| 219 | echo "Establish systemd" |
| 220 | |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 221 | echo "[Unit] |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 222 | Description=Kustvakt |
| 223 | After=network.target |
| 224 | |
| 225 | [Service] |
| 226 | User=root |
| 227 | Type=forking |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 228 | ExecStart=/bin/su - vagrant -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] | 229 | PIDFile=/home/vagrant/Built/kustvakt.pid |
| 230 | KillMode=process |
| 231 | |
| 232 | [Install] |
Akron | b940611 | 2018-11-15 19:34:32 +0100 | [diff] [blame] | 233 | WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kustvakt.service |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 234 | |
| 235 | echo "[Unit] |
| 236 | Description=Kalamar |
| 237 | After=network.target |
| 238 | |
| 239 | [Service] |
| 240 | User=root |
| 241 | Type=forking |
| 242 | PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid |
| 243 | ExecStart=/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' |
| 244 | ExecStop=/bin/su - vagrant -c 'MOJO_MODE=vagrant /home/vagrant/perl5/perlbrew/perls/perl-5.24.0/bin/hypnotoad -s /home/vagrant/Kalamar/script/kalamar' |
| 245 | ExecReload=/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' |
| 246 | killMode=process |
| 247 | |
| 248 | [Install] |
| 249 | WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service |
| 250 | |
| 251 | sudo systemctl enable kustvakt |
| 252 | sudo systemctl enable kalamar |
| 253 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame] | 254 | # echo "Start Kustvakt" |
| 255 | sudo systemctl start kustvakt |
| 256 | |
| 257 | # echo "Start Kalamar" |
| 258 | sudo systemctl start kalamar |
| 259 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 260 | SHELL |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 261 | end |