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. |
| 11 | config.vm.box = "ubuntu/trusty64" |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 12 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 13 | config.vm.provider "virtualbox" do |vb| |
| 14 | vb.customize ["modifyvm", :id, "--memory", "1024"] |
| 15 | end |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame^] | 16 | |
| 17 | config.vm.network "forwarded_port", guest: 5555, host: 5555 |
| 18 | config.vm.network "forwarded_port", guest: 5556, host: 5556 |
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 | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 43 | # Workaround for https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/1396760 |
| 44 | sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 45 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 46 | ############################################### |
| 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 | ############################################### |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 94 | echo "Install NodeJS" |
| 95 | # This is required unfortunately |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame^] | 96 | if [ ! -e ~/tmp ]; then |
| 97 | mkdir ~/tmp |
| 98 | fi |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 99 | npm set ca null |
Akron | ef28565 | 2018-10-10 15:50:29 +0200 | [diff] [blame^] | 100 | sudo npm install -g n |
| 101 | sudo n stable |
Akron | cc10f9a | 2018-10-09 19:57:27 +0200 | [diff] [blame] | 102 | sudo npm install -g sass |
| 103 | sudo npm install -g grunt-cli |
| 104 | sudo npm install grunt |
| 105 | |
| 106 | |
| 107 | ############################################### |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 108 | 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" |
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 | |
| 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 | |
Akron | a7b661d | 2018-10-09 19:13:45 +0200 | [diff] [blame] | 198 | SHELL |
Akron | 228cfa1 | 2018-10-01 16:14:41 +0200 | [diff] [blame] | 199 | end |