From 9c91fccf6f57537510e7c19583216f2cd37b234b 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 troubleshooting 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 Resolves: #3370 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..023cac211a 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