Skip to content

Commit

Permalink
image-tools: T6176: add console hint during image install
Browse files Browse the repository at this point in the history
  • Loading branch information
jestabro committed May 10, 2024
1 parent eb28119 commit 428d03e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/op_mode/image_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 428d03e

Please sign in to comment.