diff options
author | Christian Breunig <christian@breunig.cc> | 2024-05-10 18:50:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-10 18:50:10 +0200 |
commit | d0bfe6ddb92f4a0e3d19c26eb475cbc42f946480 (patch) | |
tree | 38bf27c7da5ee0d9bc4bedea93983d75ad2f800a /src/op_mode/image_installer.py | |
parent | def74a8fa4e0fb9c7ef95bfb6daff8a4f1a9878f (diff) | |
parent | 428d03e47e7d01b08ccb8cf1acc0ab8a53275286 (diff) | |
download | vyos-1x-d0bfe6ddb92f4a0e3d19c26eb475cbc42f946480.tar.gz vyos-1x-d0bfe6ddb92f4a0e3d19c26eb475cbc42f946480.zip |
Merge pull request #3443 from jestabro/fix-boot-console
image-tools: T6176: fixes for boot console
Diffstat (limited to 'src/op_mode/image_installer.py')
-rwxr-xr-x | src/op_mode/image_installer.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py index ba0e3b6db..22bdc26fb 100755 --- a/src/op_mode/image_installer.py +++ b/src/op_mode/image_installer.py @@ -23,6 +23,8 @@ from shutil import copy, chown, rmtree, copytree from glob import glob from sys import exit from os import environ +from os import readlink +from os import getpid, getppid from typing import Union from urllib.parse import urlparse from passlib.hosts import linux_context @@ -65,7 +67,7 @@ MSG_INPUT_PASSWORD: str = 'Please enter a password for the "vyos" user:' MSG_INPUT_PASSWORD_CONFIRM: str = 'Please confirm password for the "vyos" user:' MSG_INPUT_ROOT_SIZE_ALL: str = 'Would you like to use all the free space on the drive?' MSG_INPUT_ROOT_SIZE_SET: str = 'Please specify the size (in GB) of the root partition (min is 1.5 GB)?' -MSG_INPUT_CONSOLE_TYPE: str = 'What console should be used by default? (K: KVM, S: Serial, U: USB-Serial)?' +MSG_INPUT_CONSOLE_TYPE: str = 'What console should be used by default? (K: KVM, S: Serial)?' MSG_INPUT_COPY_DATA: str = 'Would you like to copy data to the new image?' MSG_INPUT_CHOOSE_COPY_DATA: str = 'From which image would you like to save config information?' MSG_INPUT_COPY_ENC_DATA: str = 'Would you like to copy the encrypted config to the new image?' @@ -614,6 +616,20 @@ def copy_ssh_host_keys() -> bool: return False +def console_hint() -> str: + pid = getppid() if 'SUDO_USER' in environ else getpid() + try: + path = readlink(f'/proc/{pid}/fd/1') + except OSError: + path = '/dev/tty' + + name = Path(path).name + if name == 'ttyS0': + return 'S' + else: + return 'K' + + def cleanup(mounts: list[str] = [], remove_items: list[str] = []) -> None: """Clean up after installation @@ -710,8 +726,8 @@ def install_image() -> None: # ask for default console console_type: str = ask_input(MSG_INPUT_CONSOLE_TYPE, default='K', - valid_responses=['K', 'S', 'U']) - console_dict: dict[str, str] = {'K': 'tty', 'S': 'ttyS', 'U': 'ttyUSB'} + valid_responses=['K', 'S']) + console_dict: dict[str, str] = {'K': 'tty', 'S': 'ttyS'} config_boot_list = ['/opt/vyatta/etc/config/config.boot', '/opt/vyatta/etc/config.boot.default'] |