This repository has been archived by the owner on Jun 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Vagrantfile.pkg
51 lines (41 loc) · 1.68 KB
/
Vagrantfile.pkg
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
require "yaml"
def deep_merge!(target, data)
merger = proc{|key, v1, v2|
Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
target.merge! data, &merger
end
_default_config = {
"virtualbox" => {
"name" => "nooku-box",
"memory" => 1024,
"cpus" => 1
},
"nfs" => (RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/)
}
begin
deep_merge!(_default_config, YAML.load(File.open(File.join(Dir.pwd, "box.config.yaml"), File::RDONLY).read))
rescue Errno::ENOENT
# No box.config.yaml file found -- that's OK; just use the defaults.
end
CONF = _default_config
Vagrant.configure("2") do |config|
config.vm.network :private_network, ip: "33.33.33.63"
config.ssh.forward_agent = true
if CONF.has_key?('virtualbox')
parameters = Array['name', 'memory', 'cpus']
config.vm.provider :virtualbox do |v|
parameters.each { |parameter|
if (CONF['virtualbox'].has_key?(parameter) && !CONF['virtualbox'][parameter].to_s.empty?)
v.customize ["modifyvm", :id, "--" + parameter, CONF['virtualbox'][parameter]]
end
}
end
end
config.vm.synced_folder Dir.pwd, "/var/www/nooku.dev", id: "vagrant-root" , :nfs => CONF['nfs']
json = {"/var/www/nooku.dev" => Dir.pwd}.to_json.gsub(/"/, '\\\"')
paths = 'fastcgi_param BOX_SHARED_PATHS \'' + json + '\';'
shell_cmd = 'echo "' + paths + '" > /etc/nginx/fastcgi_environment && service nginx restart'
config.vm.provision :shell, :inline => shell_cmd, :run => "always"
config.vm.provision :shell, :inline =>
"if [[ ! -f /nooku-install-run ]]; then /home/vagrant/scripts/nooku install > /dev/null 2>&1 && sudo touch /nooku-install-run; fi"
end