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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "hashicorp/precise64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  config.vm.provision :file, source: "~/.gitconfig", destination: ".gitconfig"
  # maybe should have a separate key for Vagrant
  config.vm.provision :file, source: "~/.ssh/id_rsa", destination: ".ssh/id_rsa"
  config.vm.provision :file, source: "~/.ssh/id_rsa.pub", destination: ".ssh/id_rsa.pub"
  config.vm.provision :file, source: "~/.ssh/known_hosts", destination: ".ssh/known_hosts"
  config.vm.provision :file, source: "~/.ssh/config", destination: ".ssh/config"

  # Simple script configuration
  config.vm.provision :shell, path: "bootstrap.sh"
  config.vm.provision :shell do |shell|
    shell.path = "iotivity-setup.sh"
    user = ENV['USER']
    if (user.empty?)
      user = ENV['USERNAME']
    end
    shell.args = "#{user}"
    shell.privileged = false
  end
end
