-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
97 lines (80 loc) · 2.92 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- mode: ruby -*-
# vi: set ft=ruby :
required_plugins = %w( vagrant-disksize vagrant-vbguest)
$new_plugin = false
required_plugins.each do |plugin|
# if not installed, attempt to install
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
$new_plugin = true
end
end
# restart vagrant if new plugin
if $new_plugin
exec "vagrant #{ARGV.join''}"
end
# load provision config
require './vagrant/config.rb'
################################################################################
# VM Configuration
################################################################################
def provisionFile(path, config)
if File.exist?(path)
if File.directory?(path)
config.vm.provision "shell", privileged: false, inline: "mkdir #{path}"
for file in Dir[File.expand_path(path) + "/*"]
privisionFile(file, config)
end
else
config.vm.provision "file", source: path, destination: path
end
end
end
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/ubuntu-18.04"
config.vm.hostname = $hostname
config.vm.box_download_insecure = true
config.ssh.shell = "bash"
# Enable X11 forwarding.
config.ssh.forward_x11 = true
config.ssh.forward_agent = true
# Configure the VM network settings.
if $network_bridged
if $network_ip == ""
config.vm.network "public_network"
else
config.vm.network "public_network", ip: "#{$network_ip}"
end
else
# Configure port forwarding.
config.vm.network "forwarded_port", guest: 9999, host: 9999, protocol: 'tcp'
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: 'udp'
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: 'tcp'
end
# VirtualBox-specific configuration.
config.vm.provider "virtualbox" do |v|
v.name = $vm_name
v.gui = $enable_gui_mode
v.cpus = $num_cpus
v.memory = $memory_size
config.disksize.size = '50GB'
# set video ram to something useful
v.customize ["modifyvm", :id, "--vram", "64"]
# enable usb
v.customize ["modifyvm", :id, "--usbxhci", "on"]
end
# sync folder
config.vm.synced_folder "./", "/ectf"
# configure setup ssh agent
config.vm.provision "shell", privileged: false, path: "./vagrant/ssh_agent.sh"
# provision scripts
config.vm.provision "shell", privileged: false, path: "./vagrant/system_setup.sh"
config.vm.provision "shell", path: "./vagrant/customizations.sh"
# Store the version of the Vagrant configuration used to provision the VM.
config.vm.provision "shell",
inline: "echo -n \"#{$vm_version}\" > /home/vagrant/.vm_version"
config.vm.provision "shell", path: "vagrant/install_xilinx_tools.sh"
config.vm.provision "shell", inline: "echo 'Provisioning complete, please reboot the machine now.'"
end