This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
82 lines (63 loc) · 2.94 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
# (C) 2014-2016 Gunnar Andersson
# License: Your choice of CC-BY-4.0, MPLv2, GPLv2/3+
# License text for MPLv2 provided in root directory.
# -*- mode: ruby -*-
# vim: set ft=ruby sw=4 ts=4 tw=0 et:
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# Apparently this needs to be specified if Vagrant has alternative options
# (try other Vagrant providers at your own risk)
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Set defaults, if not defined by environment variables
hostname = ENV['VMNAME']
hostname = 'zoom-linux-box' if hostname == nil
# Getting user real name from host, let's assume we want the same in guest
user = `whoami`
realname = `getent passwd user`.split(/:/)[4]
puts "Got real name: #{realname}"
box = ENV['BOX']
box = "trusty32" if box == nil
box_url = ENV['BOX_URL']
box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box" if box_url == nil
config.vm.box = box
config.vm.hostname = hostname
config.vm.box_url = box_url
# Set a unique tag
vmname = config.vm.hostname + "-" + Time.now.strftime("%Y%m%d%H%M")
config.vm.provider :virtualbox do |vb|
vb.gui = false
vb.customize [ "modifyvm", :id, "--name", vmname ]
vb.customize [ "modifyvm", :id, "--memory", "2048" ]
vb.customize [ "modifyvm", :id, "--vram", "128" ]
vb.customize [ "modifyvm", :id, "--clipboard" , "bidirectional" ]
vb.customize [ "modifyvm", :id, "--cpus", 2 ]
end
# Folder shared with host
# Note that VirtualBox Guest Extensions must be installed.
# There is a vagrant plugin to automate this
# Although this is now set up only for Virtualbox, the following command
# is a more portable abstraction (Vagrant will choose appropriate shared
# folder setting depending on specified type).
# Alternatively something like: ', type: "virtualbox"' could be
# added to force type
config.vm.synced_folder "~/vmshare-zoom", "/home/vagrant/vmshare-zoom"
# Auto-mount it also inside VM:
config.vm.provision :shell, inline:
'echo "vmshare-zoom /home/vagrant/vmshare-zoom vboxsf defaults 0 0" >>/etc/fstab'
# PROVISIONING
config.vm.provision :shell, inline:
'echo "***************************************************************"
echo "Starting provisioning. "
echo "***************************************************************"'
# Run final installation script, if it exists, and fix ownership of
# root-created files.
config.vm.provision :shell, inline:
" [ -f /vagrant/script.sh ] && /vagrant/script.sh
echo #{vmname} >/vagrant/VMNAME
sudo chown -R vagrant:vagrant /home/vagrant
"
config.vm.provision :shell, inline:
"echo \"Setting your real name to #{realname} (copied from host user #{user})\"
sudo chfn -f \"#{realname}\" vagrant"
end