-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathsetup.rb
68 lines (58 loc) · 2.5 KB
/
setup.rb
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
class Build
def Build.configure(config, settings)
# Configure The Box
config.vm.box = "ncaro/php7-debian8-apache-nginx-mysql"
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.7.7"
if settings['networking'][0]['public']
config.vm.network "public_network", type: "dhcp"
end
# Configure A Few VirtualBox Settings
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--ostype", "Debian_64"]
vb.customize ["modifyvm", :id, "--audio", "none", "--usb", "off", "--usbehci", "off"]
end
# Configure Port Forwarding To The Box
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.network "forwarded_port", guest: 443, host: 44300
config.vm.network "forwarded_port", guest: 3306, host: 33060
# Add Custom Ports From Configuration
if settings.has_key?("ports")
settings["ports"].each do |port|
config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"] ||= "tcp"
end
end
# Register All Of The Configured Shared Folders
if settings['folders'].kind_of?(Array)
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil
end
end
# Turn on PHP-FPM for nginx, or enable the right module for Apache
if settings["php"] == 7
if settings["nginx"] ||= false
config.vm.provision "shell", inline: "sudo service php5-fpm stop && sudo service php7-fpm restart"
else
config.vm.provision "shell", inline: "sudo a2dismod php5 && sudo a2enmod php7"
end
else
if settings["nginx"] ||= false
config.vm.provision "shell", inline: "sudo service php7-fpm stop && sudo service php5-fpm restart"
else
config.vm.provision "shell", inline: "sudo a2dismod php7 && sudo a2enmod php5"
end
end
# Turn on the proper server
config.vm.provision "shell" do |s|
if settings["nginx"] ||= false
s.inline = "sudo apachectl stop && sudo service nginx restart"
else
s.inline = "sudo service nginx stop && sudo apachectl restart"
end
end
end
end