@@ -10,12 +10,19 @@ def Homestead.configure(config, settings, hostsupdater)
10
10
config . ssh . shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
11
11
12
12
# Configure The Box
13
- config . vm . box = "laravel/homestead"
14
- config . vm . hostname = "homestead"
13
+ config . vm . box = settings [ "box" ] ||= "laravel/homestead"
14
+ config . vm . hostname = settings [ "hostname" ] ||= "homestead"
15
15
16
16
# Configure A Private Network IP
17
17
config . vm . network :private_network , ip : settings [ "ip" ] ||= "192.168.10.10"
18
18
19
+ # Configure Additional Networks
20
+ if settings . has_key? ( "networks" )
21
+ settings [ "networks" ] . each do |network |
22
+ config . vm . network network [ "type" ] , ip : network [ "ip" ] , bridge : network [ "bridge" ] ||= nil
23
+ end
24
+ end
25
+
19
26
# Configure A Few VirtualBox Settings
20
27
config . vm . provider "virtualbox" do |vb |
21
28
vb . name = 'homestead-oracle'
@@ -29,13 +36,21 @@ def Homestead.configure(config, settings, hostsupdater)
29
36
# Configure A Few VMware Settings
30
37
[ "vmware_fusion" , "vmware_workstation" ] . each do |vmware |
31
38
config . vm . provider vmware do |v |
32
- v . vmx [ "displayName" ] = "homestead"
39
+ v . vmx [ "displayName" ] = "homestead-oracle "
33
40
v . vmx [ "memsize" ] = settings [ "memory" ] ||= 2048
34
41
v . vmx [ "numvcpus" ] = settings [ "cpus" ] ||= 1
35
42
v . vmx [ "guestOS" ] = "ubuntu-64"
36
43
end
37
44
end
38
45
46
+ # Configure A Few Parallels Settings
47
+ config . vm . provider "parallels" do |v |
48
+ v . update_guest_tools = true
49
+ v . optimize_power_consumption = false
50
+ v . memory = settings [ "memory" ] ||= 2048
51
+ v . cpus = settings [ "cpus" ] ||= 1
52
+ end
53
+
39
54
# enable/disable vbguest update
40
55
config . vbguest . auto_update = false
41
56
@@ -58,17 +73,37 @@ def Homestead.configure(config, settings, hostsupdater)
58
73
s . path = "./scripts/install-oci8.sh"
59
74
end
60
75
61
- # Configure Port Forwarding To The Box
62
- config . vm . network "forwarded_port" , guest : 80 , host : 8000
63
- config . vm . network "forwarded_port" , guest : 443 , host : 44300
64
- config . vm . network "forwarded_port" , guest : 3306 , host : 33060
65
- config . vm . network "forwarded_port" , guest : 5432 , host : 54320
66
- config . vm . network "forwarded_port" , guest : 1521 , host : 1521
76
+ # Standardize Ports Naming Schema
77
+ if ( settings . has_key? ( "ports" ) )
78
+ settings [ "ports" ] . each do |port |
79
+ port [ "guest" ] ||= port [ "to" ]
80
+ port [ "host" ] ||= port [ "send" ]
81
+ port [ "protocol" ] ||= "tcp"
82
+ end
83
+ else
84
+ settings [ "ports" ] = [ ]
85
+ end
86
+
87
+ # Default Port Forwarding
88
+ default_ports = {
89
+ 80 => 8000 ,
90
+ 443 => 44300 ,
91
+ 3306 => 33060 ,
92
+ 5432 => 54320 ,
93
+ 1521 => 1521
94
+ }
95
+
96
+ # Use Default Port Forwarding Unless Overridden
97
+ default_ports . each do |guest , host |
98
+ unless settings [ "ports" ] . any? { |mapping | mapping [ "guest" ] == guest }
99
+ config . vm . network "forwarded_port" , guest : guest , host : host , auto_correct : true
100
+ end
101
+ end
67
102
68
103
# Add Custom Ports From Configuration
69
104
if settings . has_key? ( "ports" )
70
105
settings [ "ports" ] . each do |port |
71
- config . vm . network "forwarded_port" , guest : port [ "guest" ] || port [ "to" ] , host : port [ "host" ] || port [ "send" ] , protocol : port [ "protocol" ] ||= "tcp"
106
+ config . vm . network "forwarded_port" , guest : port [ "guest" ] , host : port [ "host" ] , protocol : port [ "protocol" ] , auto_correct : true
72
107
end
73
108
end
74
109
@@ -94,39 +129,55 @@ def Homestead.configure(config, settings, hostsupdater)
94
129
# Register All Of The Configured Shared Folders
95
130
if settings . include? 'folders'
96
131
settings [ "folders" ] . each do |folder |
97
- mount_opts = folder [ "type" ] == "nfs" ? [ 'actimeo=1' ] : [ ]
132
+ mount_opts = [ ]
133
+
134
+ if ( folder [ "type" ] == "nfs" )
135
+ mount_opts = folder [ "mount_opts" ] ? folder [ "mount_opts" ] : [ 'actimeo=1' ]
136
+ end
137
+
98
138
config . vm . synced_folder folder [ "map" ] , folder [ "to" ] , type : folder [ "type" ] ||= nil , mount_options : mount_opts
99
139
end
100
140
end
101
141
102
142
# Install All The Configured Nginx Sites
143
+ config . vm . provision "shell" do |s |
144
+ s . path = scriptDir + "/clear-nginx.sh"
145
+ end
146
+
103
147
settings [ "sites" ] . each do |site |
104
- config . vm . provision "shell" do |s |
105
- if ( site . has_key? ( "hhvm" ) && site [ "hhvm" ] )
106
- s . path = scriptDir + "/serve-hhvm.sh"
107
- s . args = [ site [ "map" ] , site [ "to" ] , site [ "port" ] ||= "80" , site [ "ssl" ] ||= "443" ]
108
- else
109
- s . path = scriptDir + "/serve.sh"
110
- s . args = [ site [ "map" ] , site [ "to" ] , site [ "port" ] ||= "80" , site [ "ssl" ] ||= "443" ]
111
- end
148
+ type = site [ "type" ] ||= "laravel"
149
+
150
+ if ( site . has_key? ( "hhvm" ) && site [ "hhvm" ] )
151
+ type = "hhvm"
112
152
end
113
- end
114
153
115
- # Configure All Of The Configured Databases
116
- settings [ "databases" ] . each do |db |
117
- config . vm . provision "shell" do |s |
118
- s . path = scriptDir + "/create-mysql.sh"
119
- s . args = [ db ]
154
+ if ( type == "symfony" )
155
+ type = "symfony2"
120
156
end
121
157
122
158
config . vm . provision "shell" do |s |
123
- s . path = scriptDir + "/create-postgres .sh"
124
- s . args = [ db ]
159
+ s . path = scriptDir + "/serve- #{ type } .sh"
160
+ s . args = [ site [ "map" ] , site [ "to" ] , site [ "port" ] ||= "80" , site [ "ssl" ] ||= "443" ]
125
161
end
162
+ end
126
163
127
- config . vm . provision "shell" do |s |
128
- s . path = scriptDir + "/create-oracle.sh"
129
- s . args = [ db ]
164
+ # Configure All Of The Configured Databases
165
+ if settings . has_key? ( "databases" )
166
+ settings [ "databases" ] . each do |db |
167
+ config . vm . provision "shell" do |s |
168
+ s . path = scriptDir + "/create-mysql.sh"
169
+ s . args = [ db ]
170
+ end
171
+
172
+ config . vm . provision "shell" do |s |
173
+ s . path = scriptDir + "/create-postgres.sh"
174
+ s . args = [ db ]
175
+ end
176
+
177
+ config . vm . provision "shell" do |s |
178
+ s . path = scriptDir + "/create-oracle.sh"
179
+ s . args = [ db ]
180
+ end
130
181
end
131
182
end
132
183
@@ -140,6 +191,10 @@ def Homestead.configure(config, settings, hostsupdater)
140
191
end
141
192
142
193
# Configure All Of The Server Environment Variables
194
+ config . vm . provision "shell" do |s |
195
+ s . path = scriptDir + "/clear-variables.sh"
196
+ end
197
+
143
198
if settings . has_key? ( "variables" )
144
199
settings [ "variables" ] . each do |var |
145
200
config . vm . provision "shell" do |s |
@@ -148,7 +203,7 @@ def Homestead.configure(config, settings, hostsupdater)
148
203
end
149
204
150
205
config . vm . provision "shell" do |s |
151
- s . inline = "echo \" \n #Set Homestead environment variable \n export $1=$2\" >> /home/vagrant/.profile"
206
+ s . inline = "echo \" \n # Set Homestead Environment Variable \n export $1=$2\" >> /home/vagrant/.profile"
152
207
s . args = [ var [ "key" ] , var [ "value" ] ]
153
208
end
154
209
end
0 commit comments