Commit 4a7fe716 authored by Franco Fichtner's avatar Franco Fichtner

system: allow selection of secondary console; closes #1091

(cherry picked from commit e10bea7d)
parent f5839826
......@@ -1897,6 +1897,15 @@ function load_thermal_module()
}
}
function system_console_types()
{
return array(
'serial' => array('value' => 'comconsole', 'name' => gettext('Serial Console')),
'video' => array('value' => 'vidconsole', 'name' => gettext('VGA Console')),
'efi' => array('value' => 'efi', 'name' => gettext('EFI Console')),
);
}
function system_console_configure()
{
global $config;
......@@ -1913,17 +1922,32 @@ function system_console_configure()
// ** console settings in /boot/loader.conf
$new_boot_config = array();
$new_boot_config['boot_multicons'] = $serial_enabled ? '"YES"' : null;
$new_boot_config['boot_serial'] = $serial_enabled ? '"YES"' : null;
if ($serial_enabled) {
$primaryconsole = !empty($config['system']['primaryconsole']) ? $config['system']['primaryconsole'] : "";
$new_boot_config['console'] = $primaryconsole == "video" ? '"vidconsole,comconsole"' : '"comconsole,vidconsole"';
} else {
$new_boot_config['comconsole_speed'] = null;
$new_boot_config['autoboot_delay'] = '"3"';
$new_boot_config['boot_multicons'] = null;
$new_boot_config['hw.usb.no_pf'] = '"1"';
$new_boot_config['boot_serial'] = null;
$new_boot_config['console'] = null;
$console_types = system_console_types();
$console_selection = array();
foreach (array('primaryconsole', 'secondaryconsole') as $console_order) {
if (!empty($config['system'][$console_order]) && isset($console_types[$config['system'][$console_order]])) {
$console_selection[] = $console_types[$config['system'][$console_order]]['value'];
}
}
$console_selection = array_unique($console_selection);
if ($serial_enabled) {
$new_boot_config['console'] = '"' . implode(',', $console_selection) . '"';
$new_boot_config['comconsole_speed'] = '"'.$serialspeed.'"';
$new_boot_config['hw.usb.no_pf'] = '"1"';
$new_boot_config['autoboot_delay'] = '"3"';
$new_boot_config['boot_serial'] = '"YES"';
if (count($console_selection) >= 2) {
$new_boot_config['boot_multicons'] = '"YES"';
}
}
$new_loader_conf = "";
// construct OPNsense config for /boot/loader.conf
......
......@@ -50,6 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['enableserial'] = isset($config['system']['enableserial']);
$pconfig['serialspeed'] = $config['system']['serialspeed'];
$pconfig['primaryconsole'] = $config['system']['primaryconsole'];
$pconfig['secondaryconsole'] = $config['system']['secondaryconsole'];
$pconfig['enablesshd'] = $config['system']['ssh']['enabled'];
$pconfig['sshport'] = $config['system']['ssh']['port'];
$pconfig['passwordauth'] = isset($config['system']['ssh']['passwordauth']);
......@@ -138,6 +139,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['primaryconsole']);
}
if (!empty($pconfig['secondaryconsole'])) {
$config['system']['secondaryconsole'] = $pconfig['secondaryconsole'];
} elseif (isset($config['system']['secondaryconsole'])) {
unset($config['system']['secondaryconsole']);
}
if ($pconfig['nodnsrebindcheck'] == "yes") {
$config['system']['webgui']['nodnsrebindcheck'] = true;
} elseif (isset($config['system']['webgui']['nodnsrebindcheck'])) {
......@@ -524,15 +530,28 @@ include("head.inc");
<td><a id="help_for_primaryconsole" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Primary Console")?></td>
<td width="78%">
<select name="primaryconsole" id="primaryconsole" class="formselect selectpicker">
<option value="serial" <?=$pconfig['primaryconsole'] == "serial" ? 'selected="selected"' : '';?>>
<?=gettext("Serial Console");?>
</option>
<option value="video" <?=$pconfig['primaryconsole'] == "video" ? 'selected="selected"' : '';?>>
<?=gettext("VGA Console");?>
</option>
<?php foreach (system_console_types() as $console_key => $console_type): ?>
<option value="<?= html_safe($console_key) ?>" <?= $pconfig['primaryconsole'] == $console_key ? 'selected="selected"' : '' ?>><?= $console_type['name'] ?></option>
<? endforeach ?>
</select>
<div class="hidden" for="help_for_primaryconsole">
<?=gettext("Select the preferred console if multiple consoles are present. The preferred console will show OPNsense boot script output. All consoles display OS boot messages, console messages, and the console menu."); ?>
<?=gettext("Select the primary console. This preferred console will show boot script output.") ?>
<?=gettext("All consoles display OS boot messages, console messages, and the console menu."); ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_secondaryconsole" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Secondary Console")?></td>
<td width="78%">
<select name="secondaryconsole" id="secondaryconsole" class="formselect selectpicker">
<option value="" <?= empty($pconfig['secondaryconsole']) ? 'selected="selected"' : '' ?>><?= gettext('None') ?></option>
<?php foreach (system_console_types() as $console_key => $console_type): ?>
<option value="<?= html_safe($console_key) ?>" <?= $pconfig['secondaryconsole'] == $console_key ? 'selected="selected"' : '' ?>><?= $console_type['name'] ?></option>
<? endforeach ?>
</select>
<div class="hidden" for="help_for_secondaryconsole">
<?=gettext("Select the secondary console if multiple consoles are present."); ?>
<?=gettext("All consoles display OS boot messages, console messages, and the console menu."); ?>
</div>
</td>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment