Commit 85e62204 authored by Franco Fichtner's avatar Franco Fichtner

system: deprecate 'enableserial' and refactor a bit

We don't need the flag anymore, it must be set through primary or
secondary console explicitly.
parent 2601843e
...@@ -58,7 +58,7 @@ function set_networking_interfaces_ports($probe = false) ...@@ -58,7 +58,7 @@ function set_networking_interfaces_ports($probe = false)
$key = null; $key = null;
/* kernel messages clobber stty probing on ifconfig up */ /* kernel messages clobber stty probing on ifconfig up */
mute_kernel_msgs(); system_console_mute();
$iflist = get_interface_list(false, true); $iflist = get_interface_list(false, true);
...@@ -290,7 +290,7 @@ EOD; ...@@ -290,7 +290,7 @@ EOD;
} }
if (!in_array($key, array('y', 'Y'))) { if (!in_array($key, array('y', 'Y'))) {
unmute_kernel_msgs(); system_console_unmute();
fclose($fp); fclose($fp);
return false; return false;
} }
...@@ -420,7 +420,7 @@ EOD; ...@@ -420,7 +420,7 @@ EOD;
write_config("Console assignment of interfaces"); write_config("Console assignment of interfaces");
printf(gettext("done.%s"), "\n"); printf(gettext("done.%s"), "\n");
unmute_kernel_msgs(); system_console_unmute();
fclose($fp); fclose($fp);
return true; return true;
......
...@@ -1764,7 +1764,6 @@ function interfaces_carp_setup() ...@@ -1764,7 +1764,6 @@ function interfaces_carp_setup()
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
echo gettext("Configuring CARP settings..."); echo gettext("Configuring CARP settings...");
mute_kernel_msgs();
} }
set_single_sysctl("net.inet.carp.preempt", "1"); set_single_sysctl("net.inet.carp.preempt", "1");
...@@ -1786,7 +1785,6 @@ function interfaces_carp_setup() ...@@ -1786,7 +1785,6 @@ function interfaces_carp_setup()
} }
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
unmute_kernel_msgs();
echo gettext("done.") . "\n"; echo gettext("done.") . "\n";
} }
} }
......
...@@ -1546,6 +1546,31 @@ function system_cron_configure($verbose = false) ...@@ -1546,6 +1546,31 @@ function system_cron_configure($verbose = false)
} }
} }
function system_console_mutable()
{
/* this function name is a pun :) */
global $config;
return isset($config['system']['primaryconsole']) &&
($config['system']['primaryconsole'] == 'serial' ||
$config['system']['primaryconsole'] == 'null');
}
function system_console_mute()
{
if (system_console_mutable()) {
exec('/sbin/conscontrol mute on');
}
}
function system_console_unmute()
{
if (system_console_mutable()) {
exec('/sbin/conscontrol mute off');
}
}
function system_console_types() function system_console_types()
{ {
return array( return array(
...@@ -1563,7 +1588,7 @@ function system_login_configure() ...@@ -1563,7 +1588,7 @@ function system_login_configure()
configd_run('template reload OPNsense/Auth'); configd_run('template reload OPNsense/Auth');
$serialspeed = (!empty($config['system']['serialspeed']) && is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : '115200'; $serialspeed = (!empty($config['system']['serialspeed']) && is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : '115200';
$serial_enabled = isset($config['system']['enableserial']); /* XXX zap me, can figure out serial from primary/secondary */ $serial_enabled = false;
$new_boot_config = array(); $new_boot_config = array();
$new_boot_config['comconsole_speed'] = null; $new_boot_config['comconsole_speed'] = null;
......
...@@ -1363,22 +1363,6 @@ function set_single_sysctl($name, $value) ...@@ -1363,22 +1363,6 @@ function set_single_sysctl($name, $value)
return true; return true;
} }
function mute_kernel_msgs()
{
global $config;
if (isset($config['system']['enableserial'])) {
return;
}
exec('/sbin/conscontrol mute on');
}
function unmute_kernel_msgs()
{
exec('/sbin/conscontrol mute off');
}
/****f* util/msort /****f* util/msort
* NAME * NAME
* msort - sort array * msort - sort array
......
...@@ -58,11 +58,11 @@ echo " done.\n"; ...@@ -58,11 +58,11 @@ echo " done.\n";
/* start devd (dhclient now uses it) */ /* start devd (dhclient now uses it) */
echo "Starting device manager (devd)..."; echo "Starting device manager (devd)...";
mute_kernel_msgs(); system_console_mute();
exec('/sbin/devd'); exec('/sbin/devd');
sleep(1); sleep(1);
set_device_perms(); set_device_perms();
unmute_kernel_msgs(); system_console_unmute();
echo "done.\n"; echo "done.\n";
/* configure login behaviour */ /* configure login behaviour */
...@@ -135,10 +135,10 @@ interfaces_loopback_configure(); ...@@ -135,10 +135,10 @@ interfaces_loopback_configure();
system_syslogd_start(true); system_syslogd_start(true);
/* set up interfaces */ /* set up interfaces */
mute_kernel_msgs(); system_console_mute();
openvpn_prepare_all(); openvpn_prepare_all();
interfaces_configure(); interfaces_configure();
unmute_kernel_msgs(); system_console_unmute();
/* start OpenVPN server & clients */ /* start OpenVPN server & clients */
echo "Syncing OpenVPN settings..."; echo "Syncing OpenVPN settings...";
......
...@@ -48,7 +48,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -48,7 +48,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']); $pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']);
$pconfig['loginautocomplete'] = isset($config['system']['webgui']['loginautocomplete']); $pconfig['loginautocomplete'] = isset($config['system']['webgui']['loginautocomplete']);
$pconfig['althostnames'] = $config['system']['webgui']['althostnames']; $pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
$pconfig['enableserial'] = isset($config['system']['enableserial']);
$pconfig['serialspeed'] = $config['system']['serialspeed']; $pconfig['serialspeed'] = $config['system']['serialspeed'];
$pconfig['primaryconsole'] = $config['system']['primaryconsole']; $pconfig['primaryconsole'] = $config['system']['primaryconsole'];
$pconfig['secondaryconsole'] = $config['system']['secondaryconsole']; $pconfig['secondaryconsole'] = $config['system']['secondaryconsole'];
...@@ -134,12 +133,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -134,12 +133,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['webgui']['noantilockout']); unset($config['system']['webgui']['noantilockout']);
} }
if ($pconfig['enableserial'] == "yes") {
$config['system']['enableserial'] = true;
} elseif (isset($config['system']['enableserial'])) {
unset($config['system']['enableserial']);
}
if (is_numeric($pconfig['serialspeed'])) { if (is_numeric($pconfig['serialspeed'])) {
$config['system']['serialspeed'] = $pconfig['serialspeed']; $config['system']['serialspeed'] = $pconfig['serialspeed'];
} elseif (isset($config['system']['serialspeed'])) { } elseif (isset($config['system']['serialspeed'])) {
...@@ -510,17 +503,7 @@ include("head.inc"); ...@@ -510,17 +503,7 @@ include("head.inc");
</td> </td>
</tr> </tr>
<tr> <tr>
<th colspan="2"><?=gettext("Serial Communications"); ?></th> <th colspan="2"><?=gettext("Console Options"); ?></th>
</tr>
<tr>
<td><a id="help_for_enableserial" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Serial Terminal"); ?></td>
<td width="78%">
<input name="enableserial" type="checkbox" id="enableserial" value="yes" <?=!empty($pconfig['enableserial']) ? "checked=\"checked\"" : "";?> />
<strong><?=gettext("Enable serial ports with 115200/8/N/1 by default, or another speed selectable below."); ?></strong>
<div class="hidden" for="help_for_enableserial">
<?=gettext("Note: This will redirect the console output and messages to the serial port. You can still access the console menu from the internal video card/keyboard. A null modem serial cable or adapter is required to use the serial console."); ?>
</div>
</td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_serialspeed" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Serial Speed")?></td> <td><a id="help_for_serialspeed" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Serial Speed")?></td>
...@@ -532,7 +515,7 @@ include("head.inc"); ...@@ -532,7 +515,7 @@ include("head.inc");
<option value="19200" <?=$pconfig['serialspeed'] == "19200" ? 'selected="selected"' : '' ?>>19200</option> <option value="19200" <?=$pconfig['serialspeed'] == "19200" ? 'selected="selected"' : '' ?>>19200</option>
<option value="14400" <?=$pconfig['serialspeed'] == "14400" ? 'selected="selected"' : '' ?>>14400</option> <option value="14400" <?=$pconfig['serialspeed'] == "14400" ? 'selected="selected"' : '' ?>>14400</option>
<option value="9600" <?=$pconfig['serialspeed'] == "9600" ? 'selected="selected"' : '' ?>>9600</option> <option value="9600" <?=$pconfig['serialspeed'] == "9600" ? 'selected="selected"' : '' ?>>9600</option>
</select> <?=gettext("bps");?> </select>
<div class="hidden" for="help_for_serialspeed"> <div class="hidden" for="help_for_serialspeed">
<?=gettext("Allows selection of different speeds for the serial console port."); ?> <?=gettext("Allows selection of different speeds for the serial console port."); ?>
</div> </div>
...@@ -567,9 +550,6 @@ include("head.inc"); ...@@ -567,9 +550,6 @@ include("head.inc");
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<th colspan="2"><?=gettext("Console Options"); ?></th>
</tr>
<tr> <tr>
<td><i class="fa fa-info-circle text-muted"></i></a> <?= gettext("Console menu") ?></td> <td><i class="fa fa-info-circle text-muted"></i></a> <?= gettext("Console menu") ?></td>
<td width="78%"> <td width="78%">
......
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