# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  # config.vm.box = "ubuntu/trusty64"
  # config.vm.box = "ubuntu/jammy64"
  # config.vm.box = "alvistack/ubuntu-24.04"

  # https://app.vagrantup.com/caspermeijn/boxes/ubuntu-desktop-24.04
  # GitHub: https://github.com/caspermeijn/vagrant-ubuntu-desktop/tree/main/ubuntu-desktop-24.04
  # Here, the ubuntu-desktop works without usses
  config.vm.box = "caspermeijn/ubuntu-desktop-24.04"

  config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
  config.vm.network :forwarded_port, guest: 9000, host: 9000, auto_correct: true
  config.vm.network :forwarded_port, guest: 5000, host: 5000, auto_correct: true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "C:/TEMP/JabRef", "/tmp/jabref"

  config.vm.provider "virtualbox" do |v|
    v.name = "jabref-ubuntu"
    v.gui = true
    v.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "2"]
  end

  # Update package index
  config.vm.provision "shell", inline: "sudo apt-get update"
  config.vm.provision "shell", inline: "sudo apt-get upgrade -y"

  # Install latest development build of JabRef
  config.vm.provision "shell", inline: "sudo snap install --edge jabref"

  # Enable LibreOffice connection
  config.vm.provision "shell", inline: "sudo apt-get install -y libreoffice-java-common"
  config.vm.provision "shell", inline: "sudo mkdir -p /usr/lib/mozilla/native-messaging-hosts"
  config.vm.provision "shell", inline: "snap connect jabref:hostfs-mozilla-native-messaging-jabref"

  config.ssh.forward_x11 = true
end
