diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/config.console.inc | 98 | ||||
-rw-r--r-- | src/etc/inc/config.lib.inc | 8 | ||||
-rwxr-xr-x | src/etc/rc.bootup | 4 | ||||
-rwxr-xr-x | src/etc/rc.initial.defaults | 19 | ||||
-rwxr-xr-x | src/etc/rc.initial.halt | 16 | ||||
-rwxr-xr-x | src/etc/rc.initial.reboot | 16 |
6 files changed, 92 insertions, 69 deletions
diff --git a/src/etc/inc/config.console.inc b/src/etc/inc/config.console.inc index 33194bf..f719591 100644 --- a/src/etc/inc/config.console.inc +++ b/src/etc/inc/config.console.inc @@ -101,15 +101,13 @@ BEGIN MANUAL CONFIGURATION OR WE WILL PROCEED WITH AUTO CONFIGURATION. EOD; } - echo <<<EOD - -Do you want to set up VLANs first? - -If you are not going to use VLANs, or only for optional interfaces, you should -say no here and use the webConfigurator to configure VLANs later, if required. - -Do you want to set up VLANs now [y|n]? -EOD; + echo "\n" . gettext("Do you want to set up VLANs first?"); + echo "\n" . + gettext( + "If you are not going to use VLANs, or only for optional interfaces, you should\n" . + "say no here and use the webConfigurator to configure VLANs later, if required.") . + "\n"; + echo "\n" . gettext("Do you want to set up VLANs now [y|n]?") . " "; if ($auto_assign) { $key = timeout(); @@ -314,10 +312,7 @@ EOD; echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n"; } - echo <<<EOD - -Do you want to proceed [y|n]? -EOD; + echo "\n" . gettext("Do you want to proceed [y|n]?") . " "; $key = chop(fgets($fp)); } @@ -330,13 +325,8 @@ EOD; $config['interfaces']['lan']['enable'] = true; } elseif (!platform_booting() && !$auto_assign) { -echo <<<EODD - -You have chosen to remove the LAN interface. - -Would you like to remove the LAN IP address and -unload the interface now? [y|n]? -EODD; + echo "\n" . gettext("You have chosen to remove the LAN interface.") . "\n"; + echo "\n" . gettext("Would you like to remove the LAN IP address and \nunload the interface now [y|n]?") . " "; if (strcasecmp(chop(fgets($fp)), "y") == 0) { if (isset($config['interfaces']['lan']) && $config['interfaces']['lan']['if']) { @@ -497,13 +487,8 @@ function vlan_setup() { $iflist = get_interface_list(); if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { - - echo <<<EOD - -WARNING: all existing VLANs will be cleared if you proceed! - -Do you want to proceed [y|n]? -EOD; + echo "\n" . gettext("WARNING: all existing VLANs will be cleared if you proceed!") . "\n"; + echo "\n" . gettext("Do you want to proceed [y|n]?") . " "; if (strcasecmp(chop(fgets($fp)), "y") != 0) { return; @@ -563,4 +548,63 @@ EOD; } } +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/inc/config.lib.inc b/src/etc/inc/config.lib.inc index 0ea97b3..9eef685 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -515,7 +515,7 @@ function safe_write_file($file, $content, $force_binary) { * null ******/ /* save the system configuration */ -function write_config($desc="Unknown", $backup = true) { +function write_config($desc="Unknown", $backup = true, $write_config_only = false) { global $config, $g; if (!empty($_SERVER['REMOTE_ADDR'])) { @@ -580,6 +580,12 @@ function write_config($desc="Unknown", $backup = true) { unlock($lockkey); + if ($write_config_only) { + /* tell kernel to sync fs data */ + conf_mount_ro(); + return $config; + } + unlink_if_exists("/usr/local/pkg/pf/carp_sync_client.php"); /* tell kernel to sync fs data */ 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 diff --git a/src/etc/rc.initial.defaults b/src/etc/rc.initial.defaults index 40ceaf9..c80a18d 100755 --- a/src/etc/rc.initial.defaults +++ b/src/etc/rc.initial.defaults @@ -36,24 +36,13 @@ $fp = fopen('php://stdin', 'r'); - echo <<<EOD - -You are about to reset the firewall to factory defaults. -The firewall will reboot after resetting the configuration. - -Do you want to proceed [y|n]? -EOD; + echo "\n" . gettext("You are about to reset the firewall to factory defaults."); + echo "\n" . gettext("The firewall will reboot after resetting the configuration."); + echo "\n" . gettext("Do you want to proceed [y|n]?") . " "; if (strcasecmp(chop(fgets($fp)), "y") == 0) { - reset_factory_defaults(); - - echo <<<EOD - -{$g['product_name']} is rebooting now. - -EOD; - + echo "\n" . sprintf(gettext("%s is rebooting now."), $g['product_name']) . "\n"; system_reboot_sync(); } diff --git a/src/etc/rc.initial.halt b/src/etc/rc.initial.halt index df91ded..27377b5 100755 --- a/src/etc/rc.initial.halt +++ b/src/etc/rc.initial.halt @@ -37,21 +37,11 @@ $fp = fopen('php://stdin', 'r'); - echo <<<EOD - -{$g['product_name']} will shutdown and halt system. This may take a few minutes, depending on your hardware. - -Do you want to proceed [y|n]? -EOD; + echo "\n" . sprintf(gettext("%s will shutdown and halt system. This may take a few minutes, depending on your hardware."), $g['product_name']) . "\n"; + echo gettext("Do you want to proceed [y|n]?") . " "; if (strcasecmp(chop(fgets($fp)), "y") == 0) { - - echo <<<EOD - -{$g['product_name']} will shutdown and halt system now. - -EOD; - + echo "\n" . sprintf(gettext("%s will shutdown and halt system now."), $g['product_name']) . "\n"; system_halt(); } diff --git a/src/etc/rc.initial.reboot b/src/etc/rc.initial.reboot index 6f70407..fdcc480 100755 --- a/src/etc/rc.initial.reboot +++ b/src/etc/rc.initial.reboot @@ -37,21 +37,11 @@ $fp = fopen('php://stdin', 'r'); - echo <<<EOD - -{$g['product_name']} will reboot. This may take a few minutes, depending on your hardware. - -Do you want to proceed [y|n]? -EOD; + echo "\n" . sprintf(gettext("%s will reboot. This may take a few minutes, depending on your hardware."), $g['product_name']) . "\n"; + echo gettext("Do you want to proceed [y|n]?") . " "; if (strcasecmp(chop(fgets($fp)), "y") == 0) { - - echo <<<EOD - -{$g['product_name']} is rebooting now. - -EOD; - + echo "\n" . sprintf(gettext("%s is rebooting now."), $g['product_name']) . "\n"; system_reboot_sync(); } |