From 471e3f50e42b64908b81e3478546046ac7d8ccf0 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 2 Oct 2023 15:59:50 +0200 Subject: [PATCH] [sos] Support running inside Toolbx containers Toolbx [1] containers are Podman containers that are designed to be used as interactive command line environments for development and troubleshooting the host operating system. Currently, those trying to use them for troubleshooting with 'sos report' have been setting the HOST environment variable inside their containers. It will improve the user experience if sos(1) could detect that it's running inside a Toolbx container and automatically configure itself to do the right thing. Toolbx containers can be distinguished from other Podman containers by the presence of the /run/.toolboxenv file. [1] https://containertoolbx.org/ https://github.com/containers/toolbox Signed-off-by: Debarshi Ray --- sos/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sos/__init__.py b/sos/__init__.py index 78e4526768..931fabfee1 100644 --- a/sos/__init__.py +++ b/sos/__init__.py @@ -51,6 +51,9 @@ class SoS(): """ def __init__(self, args): + if not os.getenv('HOST', None) and os.path.isfile("/run/.toolboxenv"): + os.environ['HOST'] = '/run/host' + self.cmdline = args # define the local subcommands that exist on the system # first import the necessary module, then add an entry to the dict that