system: allow USB-based serial ports; closes #2026

This commit is contained in:
Franco Fichtner 2018-07-15 19:47:43 +02:00
parent 086d372e7e
commit 6bbfcf4b02
2 changed files with 17 additions and 2 deletions

View File

@ -1309,8 +1309,9 @@ function system_login_configure($verbose = false)
}
}
/* serial terminals */
foreach (array('ttyu0', 'ttyu1', 'ttyu2', 'ttyu3') as $serialport) {
if (strpos($tty, $serialport) === 0) {
foreach (array('tty%s0', 'tty%s1', 'tty%s2', 'tty%s3') as $serialport) {
$serialport = sprintf($serialport, isset($config['system']['serialusb']) ? 'U' : 'u');
if (stripos($tty, $serialport) === 0) {
fwrite($fd, "{$serialport}\t\"/usr/libexec/getty {$serial_type}\"\tvt100\t{$on_off_secure_u}\n");
continue 2;
}

View File

@ -60,6 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']);
$pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
$pconfig['serialspeed'] = $config['system']['serialspeed'];
$pconfig['serialusb'] = isset($config['system']['serialusb']);
$pconfig['primaryconsole'] = $config['system']['primaryconsole'];
$pconfig['secondaryconsole'] = $config['system']['secondaryconsole'];
$pconfig['enablesshd'] = $config['system']['ssh']['enabled'];
@ -188,6 +189,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['serialspeed']);
}
if (!empty($pconfig['serialusb'])) {
$config['system']['serialusb'] = true;
} elseif (isset($config['system']['serialusb'])) {
unset($config['system']['serialusb']);
}
if (!empty($pconfig['primaryconsole'])) {
$config['system']['primaryconsole'] = $pconfig['primaryconsole'];
} elseif (isset($config['system']['primaryconsole'])) {
@ -762,6 +769,13 @@ $(document).ready(function() {
</div>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i></a> <?= gettext('USB-based serial') ?></td>
<td>
<input name="serialusb" type="checkbox" value="yes" <?= empty($pconfig['serialusb']) ? '' : 'checked="checked"' ?> />
<?= gettext('Use USB-based serial ports') ?>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i></a> <?= gettext("Console menu") ?></td>
<td>