diff options
author | John Estabrook <jestabro@vyos.io> | 2024-05-10 09:20:38 -0500 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-05-10 16:51:22 +0000 |
commit | 2fa4014d2f4e1f65dfb2be57177a2185e804fc1b (patch) | |
tree | 76ffe1db2c74e5935005acf968df1e10bdb03282 /src | |
parent | f8da2a726cec513c245402f1374b2545e39309eb (diff) | |
download | vyos-1x-2fa4014d2f4e1f65dfb2be57177a2185e804fc1b.tar.gz vyos-1x-2fa4014d2f4e1f65dfb2be57177a2185e804fc1b.zip |
image-tools: T6176: add console hint during image install
(cherry picked from commit 428d03e47e7d01b08ccb8cf1acc0ab8a53275286)
Diffstat (limited to 'src')
-rwxr-xr-x | src/op_mode/image_installer.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py index a3413b2c6..d65cd6b1d 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 @@ -564,6 +566,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 |