From fba27cac855cf196a394ac4bb955f9f7402982cb Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 30 Jul 2025 21:40:11 +0100 Subject: serial: T7484: treat unavailable serial console devices as non-fatal Instead of failing or starting agetty on an invalid device, we now check whether the specified serial console device is a valid TTY. If it's not, we display a warning to the user and skip starting the agetty process. --- python/vyos/utils/serial.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python') diff --git a/python/vyos/utils/serial.py b/python/vyos/utils/serial.py index 68aad676e..36b483e91 100644 --- a/python/vyos/utils/serial.py +++ b/python/vyos/utils/serial.py @@ -116,3 +116,16 @@ def restart_login_consoles(prompt_user=False, quiet=True, devices: List[str]=[]) cmd(f'systemctl stop {unit_name}') return True + +def is_tty(name: str) -> bool: + """ Check if a given device file (e.g. /dev/ttyS0) is a TTY (teletypewriter) + device in Linux + """ + import os + path_tty = f'/dev/{name}' + if os.path.exists(path_tty): + with open(path_tty, 'rb') as f: + fd = f.fileno() + # True if filename is a TTY + return os.isatty(fd) + return False -- cgit v1.2.3