1
|
<?php
|
2
|
/*
|
3
|
* config.console.inc
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* originally part of m0n0wall (http://m0n0.ch/wall)
|
10
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14
|
* you may not use this file except in compliance with the License.
|
15
|
* You may obtain a copy of the License at
|
16
|
*
|
17
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18
|
*
|
19
|
* Unless required by applicable law or agreed to in writing, software
|
20
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22
|
* See the License for the specific language governing permissions and
|
23
|
* limitations under the License.
|
24
|
*/
|
25
|
|
26
|
function set_networking_interfaces_ports() {
|
27
|
global $noreboot;
|
28
|
global $config;
|
29
|
global $g;
|
30
|
global $fp;
|
31
|
|
32
|
$fp = fopen('php://stdin', 'r');
|
33
|
|
34
|
$memory = get_memory();
|
35
|
$physmem = $memory[0];
|
36
|
$realmem = $memory[1];
|
37
|
|
38
|
if ($physmem < $g['minimum_ram_warning']) {
|
39
|
echo "\n\n\n";
|
40
|
echo gettext("DANGER! WARNING! ACHTUNG!") . "\n\n";
|
41
|
printf(gettext('%1$s requires *AT LEAST* %2$s RAM to function correctly.%3$s'), $g['product_name'], $g['minimum_ram_warning_text'], "\n");
|
42
|
printf(gettext('Only (%1$s) MB RAM has been detected, with (%2$s) available to %3$s.%4$s'), $realmem, $physmem, $g['product_name'], "\n");
|
43
|
echo "\n" . gettext("Press ENTER to continue.") . " ";
|
44
|
fgets($fp);
|
45
|
echo "\n";
|
46
|
}
|
47
|
|
48
|
$iflist = get_interface_list();
|
49
|
|
50
|
/* Function flow is based on $key or the lack thereof */
|
51
|
$key = null;
|
52
|
|
53
|
echo <<<EOD
|
54
|
|
55
|
Valid interfaces are:
|
56
|
|
57
|
|
58
|
EOD;
|
59
|
|
60
|
if (!is_array($iflist)) {
|
61
|
echo gettext("No interfaces found!") . "\n";
|
62
|
$iflist = array();
|
63
|
} else {
|
64
|
// ifsmallist is kept with spaces at the beginning and end to assist with str_replace() operations
|
65
|
$ifsmallist = " ";
|
66
|
foreach ($iflist as $iface => $ifa) {
|
67
|
$friendly = convert_real_interface_to_friendly_interface_name($iface);
|
68
|
$ifstatus = pfSense_get_interface_addresses($config['interfaces'][$friendly]['if']);
|
69
|
if (is_array($ifstatus) && $ifstatus['linkstateup'])
|
70
|
$status = " (up)";
|
71
|
else
|
72
|
$status = "(down)";
|
73
|
$ifsmallist = $ifsmallist . $iface. " ";
|
74
|
echo sprintf("% -7s%s %s %s\n", $iface, $ifa['mac'],
|
75
|
$status, substr($ifa['dmesg'], 0, 48));
|
76
|
}
|
77
|
}
|
78
|
|
79
|
echo "\n" . gettext("Do VLANs need to be set up first?");
|
80
|
echo "\n" .
|
81
|
gettext(
|
82
|
"If VLANs will not be used, or only for optional interfaces, it is typical to\n" .
|
83
|
"say no here and use the webConfigurator to configure VLANs later, if required.") .
|
84
|
"\n";
|
85
|
echo "\n" . gettext("Should VLANs be set up now [y|n]?") . " ";
|
86
|
|
87
|
$key = chop(fgets($fp));
|
88
|
|
89
|
//Manually assign interfaces
|
90
|
if (in_array($key, array('y', 'Y'))) {
|
91
|
vlan_setup();
|
92
|
}
|
93
|
|
94
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
95
|
|
96
|
echo "\n\n" . gettext("VLAN interfaces:") . "\n\n";
|
97
|
foreach ($config['vlans']['vlan'] as $vlan) {
|
98
|
|
99
|
echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}",
|
100
|
"VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}");
|
101
|
|
102
|
$iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array();
|
103
|
$ifsmallist = $ifsmallist . $vlan['if'] . '_vlan' . $vlan['tag'] . " ";
|
104
|
}
|
105
|
}
|
106
|
|
107
|
echo <<<EOD
|
108
|
|
109
|
If the names of the interfaces are not known, auto-detection can
|
110
|
be used instead. To use auto-detection, please disconnect all
|
111
|
interfaces before pressing 'a' to begin the process.
|
112
|
|
113
|
EOD;
|
114
|
|
115
|
do {
|
116
|
echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection") . " ";
|
117
|
printf(gettext('%1$s(%2$s or a): '), "\n", trim($ifsmallist));
|
118
|
$wanif = chop(fgets($fp));
|
119
|
if ($wanif === "") {
|
120
|
return;
|
121
|
}
|
122
|
if ($wanif === "a") {
|
123
|
$wanif = autodetect_interface("WAN", $fp);
|
124
|
} else if (!array_key_exists($wanif, $iflist)) {
|
125
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $wanif, "\n");
|
126
|
unset($wanif);
|
127
|
continue;
|
128
|
}
|
129
|
$ifsmallist = str_replace(" " . $wanif . " ", " ", $ifsmallist);
|
130
|
} while (!$wanif);
|
131
|
|
132
|
do {
|
133
|
printf(gettext('%1$sEnter the LAN interface name or \'a\' for auto-detection %2$s' .
|
134
|
'NOTE: this enables full Firewalling/NAT mode.%3$s' .
|
135
|
'(%4$s a or nothing if finished):%5$s'), "\n", "\n", "\n", trim($ifsmallist), " ");
|
136
|
|
137
|
$lanif = chop(fgets($fp));
|
138
|
|
139
|
if ($lanif == "exit") {
|
140
|
exit;
|
141
|
}
|
142
|
|
143
|
if ($lanif == "") {
|
144
|
/* It is OK to have just a WAN, without a LAN so break if the user does not want LAN. */
|
145
|
break;
|
146
|
}
|
147
|
|
148
|
if ($lanif === "a") {
|
149
|
$lanif = autodetect_interface("LAN", $fp);
|
150
|
} else if (!array_key_exists($lanif, $iflist)) {
|
151
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $lanif, "\n");
|
152
|
unset($lanif);
|
153
|
continue;
|
154
|
}
|
155
|
$ifsmallist = str_replace(" " . $lanif . " ", " ", $ifsmallist);
|
156
|
} while (!$lanif);
|
157
|
|
158
|
/* optional interfaces */
|
159
|
$i = 0;
|
160
|
$optif = array();
|
161
|
|
162
|
if ($lanif <> "") {
|
163
|
while (1) {
|
164
|
if ($optif[$i]) {
|
165
|
$i++;
|
166
|
}
|
167
|
$io = $i + 1;
|
168
|
|
169
|
if ($config['interfaces']['opt' . $io]['descr']) {
|
170
|
printf(gettext('%1$sOptional interface %2$s description found: %3$s'), "\n", $io, $config['interfaces']['opt' . $io]['descr']);
|
171
|
}
|
172
|
|
173
|
printf(gettext('%1$sEnter the Optional %2$s interface name or \'a\' for auto-detection%3$s' .
|
174
|
'(%4$s a or nothing if finished):%5$s'), "\n", $io, "\n", trim($ifsmallist), " ");
|
175
|
|
176
|
$optif[$i] = chop(fgets($fp));
|
177
|
|
178
|
if ($optif[$i]) {
|
179
|
if ($optif[$i] === "a") {
|
180
|
$ad = autodetect_interface(gettext("Optional") . " " . $io, $fp);
|
181
|
if ($ad) {
|
182
|
$optif[$i] = $ad;
|
183
|
} else {
|
184
|
unset($optif[$i]);
|
185
|
}
|
186
|
} else if (!array_key_exists($optif[$i], $iflist)) {
|
187
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $optif[$i], "\n");
|
188
|
unset($optif[$i]);
|
189
|
continue;
|
190
|
}
|
191
|
$ifsmallist = str_replace(" " . $optif[$i] . " ", " ", $ifsmallist);
|
192
|
} else {
|
193
|
unset($optif[$i]);
|
194
|
break;
|
195
|
}
|
196
|
}
|
197
|
}
|
198
|
|
199
|
/* check for double assignments */
|
200
|
$ifarr = array_merge(array($lanif, $wanif), $optif);
|
201
|
|
202
|
for ($i = 0; $i < (count($ifarr)-1); $i++) {
|
203
|
for ($j = ($i+1); $j < count($ifarr); $j++) {
|
204
|
if ($ifarr[$i] == $ifarr[$j]) {
|
205
|
echo <<<EOD
|
206
|
|
207
|
Error: The same interface name cannot be assigned twice!
|
208
|
|
209
|
EOD;
|
210
|
fclose($fp);
|
211
|
return;
|
212
|
}
|
213
|
}
|
214
|
}
|
215
|
|
216
|
echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n";
|
217
|
|
218
|
echo "WAN -> " . $wanif . "\n";
|
219
|
if ($lanif != "") {
|
220
|
echo "LAN -> " . $lanif . "\n";
|
221
|
}
|
222
|
for ($i = 0; $i < count($optif); $i++) {
|
223
|
echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n";
|
224
|
}
|
225
|
|
226
|
echo "\n" . gettext("Do you want to proceed [y|n]?") . " ";
|
227
|
$key = chop(fgets($fp));
|
228
|
|
229
|
if (in_array($key, array('y', 'Y'))) {
|
230
|
if ($lanif) {
|
231
|
if (is_array($config['interfaces']['lan'])) {
|
232
|
$upints = pfSense_interface_listget(IFF_UP);
|
233
|
if (in_array($config['interfaces']['lan']['if'], $upints))
|
234
|
interface_bring_down('lan', true);
|
235
|
}
|
236
|
if (!is_array($config['interfaces']['lan'])) {
|
237
|
$config['interfaces']['lan'] = array();
|
238
|
}
|
239
|
$config['interfaces']['lan']['if'] = $lanif;
|
240
|
$config['interfaces']['lan']['enable'] = true;
|
241
|
} elseif (!platform_booting()) {
|
242
|
|
243
|
echo "\n" . gettext("You have chosen to remove the LAN interface.") . "\n";
|
244
|
echo "\n" . gettext("Would you like to remove the LAN IP address and \nunload the interface now [y|n]?") . " ";
|
245
|
|
246
|
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
|
247
|
if (isset($config['interfaces']['lan']) && $config['interfaces']['lan']['if']) {
|
248
|
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
|
249
|
}
|
250
|
}
|
251
|
if (isset($config['interfaces']['lan'])) {
|
252
|
unset($config['interfaces']['lan']);
|
253
|
}
|
254
|
if (isset($config['dhcpd']['lan'])) {
|
255
|
unset($config['dhcpd']['lan']);
|
256
|
}
|
257
|
if (isset($config['dhcpdv6']['lan'])) {
|
258
|
unset($config['dhcpdv6']['lan']);
|
259
|
}
|
260
|
if (isset($config['interfaces']['lan']['if'])) {
|
261
|
unset($config['interfaces']['lan']['if']);
|
262
|
}
|
263
|
if (isset($config['interfaces']['wan']['blockpriv'])) {
|
264
|
unset($config['interfaces']['wan']['blockpriv']);
|
265
|
}
|
266
|
if (isset($config['shaper'])) {
|
267
|
unset($config['shaper']);
|
268
|
}
|
269
|
if (isset($config['ezshaper'])) {
|
270
|
unset($config['ezshaper']);
|
271
|
}
|
272
|
if (isset($config['nat'])) {
|
273
|
unset($config['nat']);
|
274
|
}
|
275
|
} else {
|
276
|
if (isset($config['interfaces']['lan']['if'])) {
|
277
|
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
|
278
|
}
|
279
|
if (isset($config['interfaces']['lan'])) {
|
280
|
unset($config['interfaces']['lan']);
|
281
|
}
|
282
|
if (isset($config['dhcpd']['lan'])) {
|
283
|
unset($config['dhcpd']['lan']);
|
284
|
}
|
285
|
if (isset($config['interfaces']['lan']['if'])) {
|
286
|
unset($config['interfaces']['lan']['if']);
|
287
|
}
|
288
|
if (isset($config['interfaces']['wan']['blockpriv'])) {
|
289
|
unset($config['interfaces']['wan']['blockpriv']);
|
290
|
}
|
291
|
if (isset($config['shaper'])) {
|
292
|
unset($config['shaper']);
|
293
|
}
|
294
|
if (isset($config['ezshaper'])) {
|
295
|
unset($config['ezshaper']);
|
296
|
}
|
297
|
if (isset($config['nat'])) {
|
298
|
unset($config['nat']);
|
299
|
}
|
300
|
}
|
301
|
if (preg_match($g['wireless_regex'], $lanif)) {
|
302
|
if (is_array($config['interfaces']['lan']) &&
|
303
|
!is_array($config['interfaces']['lan']['wireless'])) {
|
304
|
$config['interfaces']['lan']['wireless'] = array();
|
305
|
}
|
306
|
} else {
|
307
|
if (isset($config['interfaces']['lan'])) {
|
308
|
unset($config['interfaces']['lan']['wireless']);
|
309
|
}
|
310
|
}
|
311
|
|
312
|
if (is_array($config['interfaces']['wan'])) {
|
313
|
$upints = pfSense_interface_listget(IFF_UP);
|
314
|
if (in_array($config['interfaces']['wan']['if'], $upints))
|
315
|
interface_bring_down('wan', true);
|
316
|
}
|
317
|
if (!is_array($config['interfaces']['wan'])) {
|
318
|
$config['interfaces']['wan'] = array();
|
319
|
}
|
320
|
$config['interfaces']['wan']['if'] = $wanif;
|
321
|
$config['interfaces']['wan']['enable'] = true;
|
322
|
if (preg_match($g['wireless_regex'], $wanif)) {
|
323
|
if (is_array($config['interfaces']['wan']) &&
|
324
|
!is_array($config['interfaces']['wan']['wireless'])) {
|
325
|
$config['interfaces']['wan']['wireless'] = array();
|
326
|
}
|
327
|
} else {
|
328
|
if (isset($config['interfaces']['wan'])) {
|
329
|
unset($config['interfaces']['wan']['wireless']);
|
330
|
}
|
331
|
}
|
332
|
|
333
|
for ($i = 0; $i < count($optif); $i++) {
|
334
|
if (is_array($config['interfaces']['opt' . ($i+1)])) {
|
335
|
$upints = pfSense_interface_listget(IFF_UP);
|
336
|
if (in_array($config['interfaces']['opt' . ($i+1)]['if'], $upints))
|
337
|
interface_bring_down('opt' . ($i+1), true);
|
338
|
}
|
339
|
if (!is_array($config['interfaces']['opt' . ($i+1)])) {
|
340
|
$config['interfaces']['opt' . ($i+1)] = array();
|
341
|
}
|
342
|
|
343
|
$config['interfaces']['opt' . ($i+1)]['if'] = $optif[$i];
|
344
|
|
345
|
/* wireless interface? */
|
346
|
if (preg_match($g['wireless_regex'], $optif[$i])) {
|
347
|
if (!is_array($config['interfaces']['opt' . ($i+1)]['wireless'])) {
|
348
|
$config['interfaces']['opt' . ($i+1)]['wireless'] = array();
|
349
|
}
|
350
|
} else {
|
351
|
unset($config['interfaces']['opt' . ($i+1)]['wireless']);
|
352
|
}
|
353
|
|
354
|
if (empty($config['interfaces']['opt' . ($i+1)]['descr'])) {
|
355
|
$config['interfaces']['opt' . ($i+1)]['descr'] = "OPT" . ($i+1);
|
356
|
unset($config['interfaces']['opt' . ($i+1)]['enable']);
|
357
|
}
|
358
|
}
|
359
|
|
360
|
/* remove all other (old) optional interfaces */
|
361
|
for (; isset($config['interfaces']['opt' . ($i+1)]); $i++) {
|
362
|
unset($config['interfaces']['opt' . ($i+1)]);
|
363
|
}
|
364
|
|
365
|
printf(gettext("%sWriting configuration..."), "\n");
|
366
|
write_config(gettext("Console assignment of interfaces"));
|
367
|
printf(gettext("done.%s"), "\n");
|
368
|
|
369
|
fclose($fp);
|
370
|
|
371
|
if (platform_booting()) {
|
372
|
return;
|
373
|
}
|
374
|
|
375
|
echo gettext("One moment while the settings are reloading...");
|
376
|
echo gettext(" done!") . "\n";
|
377
|
|
378
|
touch("{$g['tmp_path']}/assign_complete");
|
379
|
|
380
|
}
|
381
|
}
|
382
|
|
383
|
function autodetect_interface($ifname, $fp) {
|
384
|
$iflist_prev = get_interface_list("media");
|
385
|
echo <<<EOD
|
386
|
|
387
|
Connect the {$ifname} interface now and make sure that the link is up.
|
388
|
Then press ENTER to continue.
|
389
|
|
390
|
EOD;
|
391
|
fgets($fp);
|
392
|
$iflist = get_interface_list("media");
|
393
|
|
394
|
foreach ($iflist_prev as $ifn => $ifa) {
|
395
|
if (!$ifa['up'] && $iflist[$ifn]['up']) {
|
396
|
printf(gettext('Detected link-up on interface %1$s.%2$s'), $ifn, "\n");
|
397
|
return $ifn;
|
398
|
}
|
399
|
}
|
400
|
|
401
|
printf(gettext("No link-up detected.%s"), "\n");
|
402
|
|
403
|
return null;
|
404
|
}
|
405
|
|
406
|
function interfaces_setup() {
|
407
|
global $iflist, $config, $g, $fp;
|
408
|
|
409
|
$iflist = get_interface_list();
|
410
|
}
|
411
|
|
412
|
function vlan_setup() {
|
413
|
global $iflist, $config, $g, $fp;
|
414
|
|
415
|
$iflist = get_interface_list();
|
416
|
|
417
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
418
|
echo "\n" . gettext("WARNING: all existing VLANs will be cleared if you proceed!") . "\n";
|
419
|
echo "\n" . gettext("Do you want to proceed [y|n]?") . " ";
|
420
|
|
421
|
if (strcasecmp(chop(fgets($fp)), "y") != 0) {
|
422
|
return;
|
423
|
}
|
424
|
}
|
425
|
|
426
|
$config['vlans']['vlan'] = array();
|
427
|
echo "\n";
|
428
|
|
429
|
$vlanif = 0;
|
430
|
|
431
|
while (1) {
|
432
|
$vlan = array();
|
433
|
|
434
|
echo "\n\n" . gettext("VLAN Capable interfaces:") . "\n\n";
|
435
|
if (!is_array($iflist)) {
|
436
|
echo gettext("No interfaces found!") . "\n";
|
437
|
} else {
|
438
|
$vlan_capable = 0;
|
439
|
foreach ($iflist as $iface => $ifa) {
|
440
|
if (is_jumbo_capable($iface)) {
|
441
|
echo sprintf("% -8s%s%s\n", $iface, $ifa['mac'],
|
442
|
$ifa['up'] ? " (up)" : "");
|
443
|
$vlan_capable++;
|
444
|
}
|
445
|
}
|
446
|
}
|
447
|
|
448
|
if ($vlan_capable == 0) {
|
449
|
echo gettext("No VLAN capable interfaces detected.") . "\n";
|
450
|
return;
|
451
|
}
|
452
|
|
453
|
echo "\n" . gettext("Enter the parent interface name for the new VLAN (or nothing if finished):") . " ";
|
454
|
$vlan['if'] = chop(fgets($fp));
|
455
|
|
456
|
if ($vlan['if']) {
|
457
|
if (!array_key_exists($vlan['if'], $iflist) ||
|
458
|
!is_jumbo_capable($vlan['if'])) {
|
459
|
printf(gettext('%1$sInvalid interface name \'%2$s\'%3$s'), "\n", $vlan['if'], "\n");
|
460
|
continue;
|
461
|
}
|
462
|
} else {
|
463
|
break;
|
464
|
}
|
465
|
|
466
|
echo gettext("Enter the VLAN tag (1-4094):") . " ";
|
467
|
$vlan['tag'] = chop(fgets($fp));
|
468
|
$vlan['vlanif'] = "{$vlan['if']}_vlan{$vlan['tag']}";
|
469
|
if (!is_numericint($vlan['tag']) || ($vlan['tag'] < 1) || ($vlan['tag'] > 4094)) {
|
470
|
printf(gettext('%1$sInvalid VLAN tag \'%2$s\'%3$s'), "\n", $vlan['tag'], "\n");
|
471
|
continue;
|
472
|
}
|
473
|
|
474
|
if (is_array($config['vlans']['vlan'])) {
|
475
|
foreach ($config['vlans']['vlan'] as $existingvlan) {
|
476
|
if ($vlan['if'] == $existingvlan['if'] && $vlan['tag'] == $existingvlan['tag']) {
|
477
|
printf("\n\n" . gettext("This parent interface and VLAN already created."));
|
478
|
continue 2;
|
479
|
}
|
480
|
}
|
481
|
}
|
482
|
$config['vlans']['vlan'][] = $vlan;
|
483
|
$vlanif++;
|
484
|
}
|
485
|
}
|
486
|
|
487
|
function check_for_alternate_interfaces() {
|
488
|
global $config;
|
489
|
|
490
|
// If the WAN and/or LAN devices in the factory default config do not exist,
|
491
|
// then look for alternate devices.
|
492
|
// This lets many systems boot a factory default config without being
|
493
|
// forced to do interface assignment on the console.
|
494
|
|
495
|
$specplatform = system_identify_specific_platform();
|
496
|
$default_device = array();
|
497
|
|
498
|
// If we recognise the platform, then specify the devices directly.
|
499
|
switch ($specplatform['name']) {
|
500
|
case 'alix':
|
501
|
$default_device['wan'] = "vr1";
|
502
|
$default_device['lan'] = "vr0";
|
503
|
break;
|
504
|
case 'APU':
|
505
|
$default_device['wan'] = "re1";
|
506
|
$default_device['lan'] = "re2";
|
507
|
break;
|
508
|
case 'RCC-VE':
|
509
|
/* SG-4860 or SG-8860 */
|
510
|
if (does_interface_exist('igb4')) {
|
511
|
$config['interfaces']['wan']['if'] = 'igb1';
|
512
|
$config['interfaces']['lan']['if'] = 'igb0';
|
513
|
} else {
|
514
|
$config['interfaces']['wan']['if'] = 'igb0';
|
515
|
$config['interfaces']['lan']['if'] = 'igb1';
|
516
|
}
|
517
|
break;
|
518
|
default:
|
519
|
$default_device['wan'] = "";
|
520
|
$default_device['lan'] = "";
|
521
|
break;
|
522
|
}
|
523
|
|
524
|
// Other common device names can be put here and will be looked for
|
525
|
// if the system was not one of the known platforms.
|
526
|
$other_devices_arr['wan'] = array("vr1", "re1", "igb0", "em0");
|
527
|
$other_devices_arr['lan'] = array("vr0", "re2", "igb1", "em1");
|
528
|
$interface_assignment_changed = false;
|
529
|
|
530
|
foreach ($other_devices_arr as $ifname => $other_devices) {
|
531
|
if (!does_interface_exist($config['interfaces'][$ifname]['if'])) {
|
532
|
if (does_interface_exist($default_device[$ifname])) {
|
533
|
$config['interfaces'][$ifname]['if'] = $default_device[$ifname];
|
534
|
$interface_assignment_changed = true;
|
535
|
} else {
|
536
|
foreach ($other_devices as $other_device) {
|
537
|
if (does_interface_exist($other_device)) {
|
538
|
$config['interfaces'][$ifname]['if'] = $other_device;
|
539
|
$interface_assignment_changed = true;
|
540
|
break;
|
541
|
}
|
542
|
}
|
543
|
}
|
544
|
}
|
545
|
}
|
546
|
|
547
|
if ($interface_assignment_changed) {
|
548
|
write_config("Factory default boot detected WAN " . $config['interfaces']['wan']['if'] . " and LAN " . $config['interfaces']['lan']['if']);
|
549
|
}
|
550
|
}
|
551
|
|
552
|
?>
|