summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-03-31 15:35:33 +0200
committerChristian Breunig <christian@breunig.cc>2026-04-09 20:54:06 +0200
commit51922535b79529d603c3b7d52cde9da54c069d42 (patch)
tree2bcaca4b3877a598a5f2f0229ac0329cb87f3ab6 /src/conf_mode
parentd2ad852ab4393862e9f27b2bc3bd7d382feb4c5a (diff)
downloadvyos-1x-51922535b79529d603c3b7d52cde9da54c069d42.tar.gz
vyos-1x-51922535b79529d603c3b7d52cde9da54c069d42.zip
serial: T8375: use boot activation script to define a serial console on the CLI
Required during first-boot of a system. We have images form amd64 and arm64 CPUs which also tend to have different serial interfaces (ttyS vs. ttyAMA). The images which are installed have the correct serial setting for GRUB (ttyS0 or ttyAMA0) and the activation script will probe the Kernel command-line. If a serial interface is defined, we will include it in the VyOS CLI configuration.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/system_console.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/conf_mode/system_console.py b/src/conf_mode/system_console.py
index 4411257e3..5d89eeba7 100755
--- a/src/conf_mode/system_console.py
+++ b/src/conf_mode/system_console.py
@@ -68,7 +68,7 @@ def verify(console):
# and it can not be used as a serial interface
if not os.path.isdir(by_bus_dir) or not os.path.exists(by_bus_device):
raise ConfigError(f'Device {device} does not support being used as tty')
- if not is_tty(device):
+ if not is_tty(device, warning=True):
Warning(f'Device "{device}" used for console is not a TTY!')
return None
@@ -82,6 +82,7 @@ def generate(console):
os.unlink(os.path.join(root, basename))
if not console or 'device' not in console:
+ grub_util.update_serial_console('', '', '')
return None
# replace keys in the config for ttyUSB items to use them in `apply()` later
@@ -112,14 +113,17 @@ def generate(console):
render(config_file, 'getty/serial-getty.service.j2', device_config)
os.symlink(config_file, getty_wants_symlink)
- # GRUB
- # For existing serial line change speed (if necessary)
- # Only applies to ttyS0
- if 'ttyS0' not in console['device']:
- return None
+ # GRUB - use first defined serial console to populate Kernel console= parameter
+ device = None
+ if 'device' in console and len(console['device']) > 0:
+ # We use the first device for the Kernel console
+ console_device = next(iter(console['device']))
+ console_speed = console['device'][console_device]['speed']
- speed = console['device']['ttyS0']['speed']
- grub_util.update_console_speed(speed)
+ # get console type ("ttyS" or "ttyAMA") from console_device (e.g. "ttyS0")
+ console_type = console_device.translate(str.maketrans('', '', '0123456789'))
+ console_num = ''.join(ch for ch in console_device if ch.isdigit())
+ grub_util.update_serial_console(console_type, console_num, console_speed)
return None
@@ -127,9 +131,9 @@ def apply(console):
# Reset screen blanking
call('/usr/bin/setterm -blank 0 -powersave off -powerdown 0 -term linux </dev/tty1 >/dev/tty1 2>&1')
- # Service control moved to vyos.utils.serial to unify checks and prompts.
- # If users are connected, we want to show an informational message on completing
- # the process, but not halt configuration processing with an interactive prompt.
+ # Service control moved to vyos.utils.serial to unify checks and prompts.
+ # If users are connected, we want to show an informational message on completing
+ # the process, but not halt configuration processing with an interactive prompt.
restart_login_consoles(prompt_user=False, quiet=False)
if not console: