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

HOST_DIR = File.join(File.dirname(__FILE__), 'output')
ROM_DIR  = File.join(File.dirname(__FILE__), 'rom')

Vagrant.configure("2") do |config|
  config.ssh.username = "jtv"
  config.ssh.keys_only = false
  if Vagrant.has_plugin?("vagrant-vbguest")
    config.vbguest.auto_update = false
  end

  config.vm.define "web" do |app|
    app.vm.provider "docker" do |d|
      d.image   = "nginx"
      d.ports   = ['8000:80']
      d.volumes = ["#{Dir.pwd}/output:/usr/share/nginx/html"]
    end
  end

  config.vm.define "pxe" do |app|
    app.vm.box = "sridhav/empty"
    app.vm.synced_folder ".", "/vagrant", disabled: true
    app.vm.provider :virtualbox do |extra|
      extra.check_guest_additions = false
      extra.customize ["setextradata", :id, "VBoxInternal/Devices/e1000/0/LUN#0/Config/TFTPPrefix", HOST_DIR ]
      extra.customize ['setextradata', :id, "VBoxInternal/Devices/pcbios/0/Config/LanBootRom", "#{ROM_DIR}/82540em.isarom"]
      extra.customize ["modifyvm", :id, "--uart1", "0x03f8", "4", "--uartmode1", "file", File.join(Dir.pwd, "serial.log")]
      extra.customize ["modifyvm", :id, "--audio", "none"]
      extra.customize ["modifyvm", :id, "--boot1", "net"]
      extra.customize ["modifyvm", :id, "--boot2", "net"]
      extra.customize ["modifyvm", :id, "--boot3", "none"]
      extra.customize ["modifyvm", :id, "--boot4", "none"]
      extra.customize ["modifyvm", :id, "--nattftpfile1", "boot.ipxe"]
    end
  end
end
