質問編集履歴

2

vagrantfileの表記訂正

2019/08/14 03:25

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
 
70
70
 
71
- #homestead->vagrant.file
71
+ #homestead->vagrantfile
72
72
 
73
73
  ```ここに言語を入力
74
74
 

1

vagrant.file2点追加

2019/08/14 03:25

投稿

Ms.yy
Ms.yy

スコア83

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,245 @@
65
65
 
66
66
 
67
67
  ```
68
+
69
+
70
+
71
+ #homestead->vagrant.file
72
+
73
+ ```ここに言語を入力
74
+
75
+ # -*- mode: ruby -*-
76
+
77
+ # vi: set ft=ruby :
78
+
79
+
80
+
81
+ require 'json'
82
+
83
+ require 'yaml'
84
+
85
+
86
+
87
+ VAGRANTFILE_API_VERSION ||= "2"
88
+
89
+ confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))
90
+
91
+
92
+
93
+ homesteadYamlPath = confDir + "/Homestead.yaml"
94
+
95
+ homesteadJsonPath = confDir + "/Homestead.json"
96
+
97
+ afterScriptPath = confDir + "/after.sh"
98
+
99
+ customizationScriptPath = confDir + "/user-customizations.sh"
100
+
101
+ aliasesPath = confDir + "/aliases"
102
+
103
+
104
+
105
+ require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
106
+
107
+
108
+
109
+ Vagrant.require_version '>= 2.2.4'
110
+
111
+
112
+
113
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
114
+
115
+ if File.exist? aliasesPath then
116
+
117
+ config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
118
+
119
+ config.vm.provision "shell" do |s|
120
+
121
+ s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
122
+
123
+ end
124
+
125
+ end
126
+
127
+
128
+
129
+ if File.exist? homesteadYamlPath then
130
+
131
+ settings = YAML::load(File.read(homesteadYamlPath))
132
+
133
+ elsif File.exist? homesteadJsonPath then
134
+
135
+ settings = JSON::parse(File.read(homesteadJsonPath))
136
+
137
+ else
138
+
139
+ abort "Homestead settings file not found in #{confDir}"
140
+
141
+ end
142
+
143
+
144
+
145
+ Homestead.configure(config, settings)
146
+
147
+
148
+
149
+ if File.exist? afterScriptPath then
150
+
151
+ config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
152
+
153
+ end
154
+
155
+
156
+
157
+ if File.exist? customizationScriptPath then
158
+
159
+ config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
160
+
161
+ end
162
+
163
+
164
+
165
+ if Vagrant.has_plugin?('vagrant-hostsupdater')
166
+
167
+ config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
168
+
169
+ elsif Vagrant.has_plugin?('vagrant-hostmanager')
170
+
171
+ config.hostmanager.enabled = true
172
+
173
+ config.hostmanager.manage_host = true
174
+
175
+ config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
176
+
177
+ end
178
+
179
+
180
+
181
+ if Vagrant.has_plugin?('vagrant-notify-forwarder')
182
+
183
+ config.notify_forwarder.enable = true
184
+
185
+ end
186
+
187
+ end
188
+
189
+
190
+
191
+ ```
192
+
193
+
194
+
195
+
196
+
197
+ ### homestead->resources->localized->vagrantfile
198
+
199
+ ```ここに言語を入力
200
+
201
+ # -*- mode: ruby -*-
202
+
203
+ # vi: set ft=ruby :
204
+
205
+
206
+
207
+ require 'json'
208
+
209
+ require 'yaml'
210
+
211
+
212
+
213
+ VAGRANTFILE_API_VERSION ||= "2"
214
+
215
+ confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))
216
+
217
+
218
+
219
+ homesteadYamlPath = File.expand_path("Homestead.yaml", File.dirname(__FILE__))
220
+
221
+ homesteadJsonPath = File.expand_path("Homestead.json", File.dirname(__FILE__))
222
+
223
+ afterScriptPath = "after.sh"
224
+
225
+ customizationScriptPath = "user-customizations.sh"
226
+
227
+ aliasesPath = "aliases"
228
+
229
+
230
+
231
+ require File.expand_path(confDir + '/scripts/homestead.rb')
232
+
233
+
234
+
235
+ Vagrant.require_version '>= 2.2.4'
236
+
237
+
238
+
239
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
240
+
241
+ if File.exist? aliasesPath then
242
+
243
+ config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
244
+
245
+ config.vm.provision "shell" do |s|
246
+
247
+ s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
248
+
249
+ end
250
+
251
+ end
252
+
253
+
254
+
255
+ if File.exist? homesteadYamlPath then
256
+
257
+ settings = YAML::load(File.read(homesteadYamlPath))
258
+
259
+ elsif File.exist? homesteadJsonPath then
260
+
261
+ settings = JSON::parse(File.read(homesteadJsonPath))
262
+
263
+ else
264
+
265
+ abort "Homestead settings file not found in " + File.dirname(__FILE__)
266
+
267
+ end
268
+
269
+
270
+
271
+ Homestead.configure(config, settings)
272
+
273
+
274
+
275
+ if File.exist? afterScriptPath then
276
+
277
+ config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
278
+
279
+ end
280
+
281
+
282
+
283
+ if File.exist? customizationScriptPath then
284
+
285
+ config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
286
+
287
+ end
288
+
289
+
290
+
291
+ if Vagrant.has_plugin?('vagrant-hostsupdater')
292
+
293
+ config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
294
+
295
+ elsif Vagrant.has_plugin?('vagrant-hostmanager')
296
+
297
+ config.hostmanager.enabled = true
298
+
299
+ config.hostmanager.manage_host = true
300
+
301
+ config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
302
+
303
+ end
304
+
305
+ end
306
+
307
+
308
+
309
+ ```