summaryrefslogtreecommitdiffstats
path: root/src/etc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-12-11 07:29:26 -0200
committerRenato Botelho <renato@netgate.com>2015-12-11 07:29:26 -0200
commit5db366dc2aad7ec06cb788ce0d95c68f73e4418d (patch)
tree8910b823a27fe74d4888852f9630e16a413bef4e /src/etc
parent59b75375c83bf56cee58295b2ee755343a83c418 (diff)
parentb49e6c0113f107f5a9ff61fe8e8798de8cca0953 (diff)
downloadpfsense-5db366dc2aad7ec06cb788ce0d95c68f73e4418d.zip
pfsense-5db366dc2aad7ec06cb788ce0d95c68f73e4418d.tar.gz
Merge pull request #2185 from phil-davis/factory-default-interfaces-20151208
Diffstat (limited to 'src/etc')
-rw-r--r--src/etc/inc/config.console.inc59
-rwxr-xr-xsrc/etc/rc.bootup4
2 files changed, 63 insertions, 0 deletions
diff --git a/src/etc/inc/config.console.inc b/src/etc/inc/config.console.inc
index 36cd694..f719591 100644
--- a/src/etc/inc/config.console.inc
+++ b/src/etc/inc/config.console.inc
@@ -548,4 +548,63 @@ function vlan_setup() {
}
}
+function check_for_alternate_interfaces() {
+ global $config;
+
+ // If the WAN and/or LAN devices in the factory default config do not exist,
+ // then look for alternate devices.
+ // This lets many systems boot a factory default config without being
+ // forced to do interface assignment on the console.
+
+ $specplatform = system_identify_specific_platform();
+ $default_device = array();
+
+ // If we recognise the platform, then specify the devices directly.
+ switch ($specplatform['name']) {
+ case 'alix':
+ $default_device['wan'] = "vr1";
+ $default_device['lan'] = "vr0";
+ break;
+ case 'APU':
+ $default_device['wan'] = "re1";
+ $default_device['lan'] = "re2";
+ break;
+ case 'RCC-VE':
+ $default_device['wan'] = "igb0";
+ $default_device['lan'] = "igb1";
+ break;
+ default:
+ $default_device['wan'] = "";
+ $default_device['lan'] = "";
+ break;
+ }
+
+ // Other common device names can be put here and will be looked for
+ // if the system was not one of the known platforms.
+ $other_devices_arr['wan'] = array("vr1", "re1", "igb0", "em0");
+ $other_devices_arr['lan'] = array("vr0", "re2", "igb1", "em1");
+ $interface_assignment_changed = false;
+
+ foreach ($other_devices_arr as $ifname => $other_devices) {
+ if (!does_interface_exist($config['interfaces'][$ifname]['if'])) {
+ if (does_interface_exist($default_device[$ifname])) {
+ $config['interfaces'][$ifname]['if'] = $default_device[$ifname];
+ $interface_assignment_changed = true;
+ } else {
+ foreach ($other_devices as $other_device) {
+ if (does_interface_exist($other_device)) {
+ $config['interfaces'][$ifname]['if'] = $other_device;
+ $interface_assignment_changed = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if ($interface_assignment_changed) {
+ write_config("Factory default boot detected WAN " . $config['interfaces']['wan']['if'] . " and LAN " . $config['interfaces']['lan']['if']);
+ }
+}
+
?>
diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup
index 78f9a39..df434f2 100755
--- a/src/etc/rc.bootup
+++ b/src/etc/rc.bootup
@@ -158,6 +158,10 @@ echo "done.\n";
/* run any early shell commands specified in config.xml */
system_do_shell_commands(1);
+if (file_exists("/conf/trigger_initial_wizard")) {
+ check_for_alternate_interfaces();
+}
+
/*
* Determine if we need to throw a interface exception
* and ask the user to reassign interfaces. This will
OpenPOWER on IntegriCloud