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