summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc/inc/pfsense-utils.inc')
-rw-r--r--src/etc/inc/pfsense-utils.inc152
1 files changed, 75 insertions, 77 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index 236d02c..c258f1f 100644
--- a/src/etc/inc/pfsense-utils.inc
+++ b/src/etc/inc/pfsense-utils.inc
@@ -1083,92 +1083,90 @@ function setup_serial_port($when = "save", $path = "") {
}
$serialspeed = (is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : "115200";
- if ($g['platform'] != "cdrom") {
- $serial_only = false;
+ $serial_only = false;
- if (($g['platform'] == "nanobsd") && isset($g['enableserial_force'])) {
+ if (($g['platform'] == "nanobsd") && isset($g['enableserial_force'])) {
+ $serial_only = true;
+ } else {
+ $specific_platform = system_identify_specific_platform();
+ if ($specific_platform['name'] == 'RCC-VE' ||
+ $specific_platform['name'] == 'RCC' ||
+ $specific_platform['name'] == 'RCC-DFF') {
$serial_only = true;
- } else {
- $specific_platform = system_identify_specific_platform();
- if ($specific_platform['name'] == 'RCC-VE' ||
- $specific_platform['name'] == 'RCC' ||
- $specific_platform['name'] == 'RCC-DFF') {
- $serial_only = true;
- }
}
+ }
- $boot_config_split = explode("\n", $boot_config);
- $fd = fopen($boot_config_file, "w");
- if ($fd) {
- foreach ($boot_config_split as $bcs) {
- if (stristr($bcs, "-D") || stristr($bcs, "-h")) {
- /* DONT WRITE OUT, WE'LL DO IT LATER */
- } else {
- if ($bcs <> "") {
- fwrite($fd, "{$bcs}\n");
- }
- }
- }
- if ($serial_only === true) {
- fwrite($fd, "-S{$serialspeed} -h");
- } else if (is_serial_enabled()) {
- fwrite($fd, "-S{$serialspeed} -D");
- }
- fclose($fd);
- }
-
- /* serial console - write out /boot/loader.conf */
- if ($when == "upgrade") {
- system("echo \"Reading {$loader_conf_file}...\" >> /conf/upgrade_log.txt");
- }
- $boot_config = file_get_contents($loader_conf_file);
- $boot_config_split = explode("\n", $boot_config);
- if (count($boot_config_split) > 0) {
- $new_boot_config = array();
- // Loop through and only add lines that are not empty, and which
- // do not contain a console directive.
- foreach ($boot_config_split as $bcs) {
- if (!empty($bcs) &&
- (stripos($bcs, "console") === false) &&
- (stripos($bcs, "boot_multicons") === false) &&
- (stripos($bcs, "boot_serial") === false) &&
- (stripos($bcs, "hw.usb.no_pf") === false) &&
- (stripos($bcs, "hint.uart.0.flags") === false) &&
- (stripos($bcs, "hint.uart.1.flags") === false)) {
- $new_boot_config[] = $bcs;
- }
- }
-
- if ($serial_only === true) {
- $new_boot_config[] = 'boot_serial="YES"';
- $new_boot_config[] = 'console="comconsole"';
- } else if (is_serial_enabled()) {
- $new_boot_config[] = 'boot_multicons="YES"';
- $new_boot_config[] = 'boot_serial="YES"';
- $primaryconsole = isset($g['primaryconsole_force']) ? $g['primaryconsole_force'] : $config['system']['primaryconsole'];
- switch ($primaryconsole) {
- case "video":
- $new_boot_config[] = 'console="vidconsole,comconsole"';
- break;
- case "serial":
- default:
- $new_boot_config[] = 'console="comconsole,vidconsole"';
+ $boot_config_split = explode("\n", $boot_config);
+ $fd = fopen($boot_config_file, "w");
+ if ($fd) {
+ foreach ($boot_config_split as $bcs) {
+ if (stristr($bcs, "-D") || stristr($bcs, "-h")) {
+ /* DONT WRITE OUT, WE'LL DO IT LATER */
+ } else {
+ if ($bcs <> "") {
+ fwrite($fd, "{$bcs}\n");
}
}
- $new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"';
+ }
+ if ($serial_only === true) {
+ fwrite($fd, "-S{$serialspeed} -h");
+ } else if (is_serial_enabled()) {
+ fwrite($fd, "-S{$serialspeed} -D");
+ }
+ fclose($fd);
+ }
- $specplatform = system_identify_specific_platform();
- if ($specplatform['name'] == 'RCC-VE' ||
- $specplatform['name'] == 'RCC' ||
- $specplatform['name'] == 'RCC-DFF') {
- $new_boot_config[] = 'comconsole_port="0x2F8"';
- $new_boot_config[] = 'hint.uart.0.flags="0x00"';
- $new_boot_config[] = 'hint.uart.1.flags="0x10"';
+ /* serial console - write out /boot/loader.conf */
+ if ($when == "upgrade") {
+ system("echo \"Reading {$loader_conf_file}...\" >> /conf/upgrade_log.txt");
+ }
+ $boot_config = file_get_contents($loader_conf_file);
+ $boot_config_split = explode("\n", $boot_config);
+ if (count($boot_config_split) > 0) {
+ $new_boot_config = array();
+ // Loop through and only add lines that are not empty, and which
+ // do not contain a console directive.
+ foreach ($boot_config_split as $bcs) {
+ if (!empty($bcs) &&
+ (stripos($bcs, "console") === false) &&
+ (stripos($bcs, "boot_multicons") === false) &&
+ (stripos($bcs, "boot_serial") === false) &&
+ (stripos($bcs, "hw.usb.no_pf") === false) &&
+ (stripos($bcs, "hint.uart.0.flags") === false) &&
+ (stripos($bcs, "hint.uart.1.flags") === false)) {
+ $new_boot_config[] = $bcs;
+ }
+ }
+
+ if ($serial_only === true) {
+ $new_boot_config[] = 'boot_serial="YES"';
+ $new_boot_config[] = 'console="comconsole"';
+ } else if (is_serial_enabled()) {
+ $new_boot_config[] = 'boot_multicons="YES"';
+ $new_boot_config[] = 'boot_serial="YES"';
+ $primaryconsole = isset($g['primaryconsole_force']) ? $g['primaryconsole_force'] : $config['system']['primaryconsole'];
+ switch ($primaryconsole) {
+ case "video":
+ $new_boot_config[] = 'console="vidconsole,comconsole"';
+ break;
+ case "serial":
+ default:
+ $new_boot_config[] = 'console="comconsole,vidconsole"';
}
- $new_boot_config[] = 'hw.usb.no_pf="1"';
+ }
+ $new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"';
- file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n");
+ $specplatform = system_identify_specific_platform();
+ if ($specplatform['name'] == 'RCC-VE' ||
+ $specplatform['name'] == 'RCC' ||
+ $specplatform['name'] == 'RCC-DFF') {
+ $new_boot_config[] = 'comconsole_port="0x2F8"';
+ $new_boot_config[] = 'hint.uart.0.flags="0x00"';
+ $new_boot_config[] = 'hint.uart.1.flags="0x10"';
}
+ $new_boot_config[] = 'hw.usb.no_pf="1"';
+
+ file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n");
}
$ttys = file_get_contents($ttys_file);
$ttys_split = explode("\n", $ttys);
@@ -1208,7 +1206,7 @@ function is_serial_enabled() {
if (!isset($g['enableserial_force']) &&
!isset($config['system']['enableserial']) &&
- ($g['platform'] == $g['product_name'] || $g['platform'] == "cdrom")) {
+ ($g['platform'] == $g['product_name'])) {
return false;
}
OpenPOWER on IntegriCloud