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 | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 44 | sudo systemctl disable kustvakt |
| 45 | sudo systemctl disable kalamar |
| 46 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 47 | ############################################### |
| 48 | echo "Install Koral" |
| 49 | cd ~/ |
| 50 | if [ -e ./Koral ] && [ -d ./Koral ] |
| 51 | then |
| 52 | cd Koral |
| 53 | git pull origin master |
| 54 | else |
| 55 | git clone https://github.com/KorAP/Koral.git Koral |
| 56 | cd Koral |
| 57 | fi |
| 58 | mvn clean install -Dhttps.protocols=TLSv1.2 |
| 59 | |
| 60 | |
| 61 | ############################################### |
| 62 | echo "Install Krill" |
| 63 | cd ~/ |
| 64 | if [ -e ./Krill ] && [ -d ./Krill ] |
| 65 | then |
| 66 | cd Krill |
| 67 | git pull origin master |
| 68 | else |
| 69 | git clone https://github.com/KorAP/Krill.git Krill |
| 70 | cd Krill |
| 71 | fi |
| 72 | mvn clean install |
| 73 | |
| 74 | |
| 75 | ############################################### |
| 76 | echo "Install Kustvakt" |
| 77 | cd ~/ |
| 78 | if [ -e ./Kustvakt ] && [ -d ./Kustvakt ] |
| 79 | then |
| 80 | cd Kustvakt |
| 81 | git pull origin master |
| 82 | else |
| 83 | git clone https://github.com/KorAP/Kustvakt.git Kustvakt |
| 84 | cd Kustvakt |
| 85 | fi |
| 86 | |
| 87 | cd ~/Kustvakt/core |
| 88 | mvn clean install |
| 89 | |
| 90 | cd ~/Kustvakt/lite |
| 91 | mvn clean package |
| 92 | |
| 93 | |
| 94 | ############################################### |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 95 | echo "Install NodeJS" |
| 96 | # This is required unfortunately |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 97 | if [ ! -e ~/tmp ]; then |
| 98 | mkdir ~/tmp |
| 99 | fi |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 100 | npm set ca null |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 101 | sudo npm install -g n |
| 102 | sudo n stable |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 103 | sudo npm install -g sass |
| 104 | sudo npm install -g grunt-cli |
| 105 | sudo npm install grunt |
| 106 | |
| 107 | |
| 108 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 109 | echo "Install Perlbrew + CPANminus" |
| 110 | cd ~/ |
| 111 | |
| 112 | perlbrew init |
| 113 | echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc |
| 114 | |
| 115 | source ~/perl5/perlbrew/etc/bashrc |
| 116 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 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" |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 132 | cd ~/ |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 133 | 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" |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 146 | npm install |
| 147 | grunt |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 148 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 149 | |
| 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 | |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 178 | ############################################### |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 179 | echo "Configure Kalamar" |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame] | 180 | cd ~/ |
| 181 | cd Kalamar |
| 182 | |
| 183 | # Add new configuration |
| 184 | echo "{hypnotoad=>{listen=>['http://*:5555']}}" \ |
| 185 | > kalamar.vagrant.conf |
| 186 | |
| 187 | echo "not really secret" > kalamar.secret |
| 188 | |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 189 | ############################################### |
| 190 | echo "Establish systemd" |
| 191 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 192 | echo '[Unit] |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 193 | Description=Kustvakt |
| 194 | After=network.target |
| 195 | |
| 196 | [Service] |
| 197 | User=root |
| 198 | Type=forking |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 199 | 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] | 200 | PIDFile=/home/vagrant/Built/kustvakt.pid |
| 201 | KillMode=process |
| 202 | |
| 203 | [Install] |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 204 | WantedBy=multi-user.target' | sudo tee /lib/systemd/system/kustvakt.service |
Akron | b66814e | 2018-10-17 16:51:11 +0200 | [diff] [blame] | 205 | |
| 206 | echo "[Unit] |
| 207 | Description=Kalamar |
| 208 | After=network.target |
| 209 | |
| 210 | [Service] |
| 211 | User=root |
| 212 | Type=forking |
| 213 | PIDFile=/home/vagrant/Kalamar/script/hypnotoad.pid |
| 214 | 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' |
| 215 | 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' |
| 216 | 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' |
| 217 | killMode=process |
| 218 | |
| 219 | [Install] |
| 220 | WantedBy=multi-user.target" | sudo tee /lib/systemd/system/kalamar.service |
| 221 | |
| 222 | sudo systemctl enable kustvakt |
| 223 | sudo systemctl enable kalamar |
| 224 | |
Akron | 4d0c9ef | 2018-11-06 16:49:35 +0100 | [diff] [blame^] | 225 | # echo "Start Kustvakt" |
| 226 | sudo systemctl start kustvakt |
| 227 | |
| 228 | # echo "Start Kalamar" |
| 229 | sudo systemctl start kalamar |
| 230 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 231 | SHELL |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 232 | end |