Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running inside Toolbx containers #3370

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def get_tmpdir_default(self):
else:
tmpdir = os.getenv('TMPDIR', None) or '/var/tmp'

if os.getenv('HOST', None) and os.getenv('container', None):
if os.getenv('HOST', None) \
and (os.path.isfile('/run/.containerenv')
or os.path.isfile('/.dockerenv')):
tmpdir = os.path.join(os.getenv('HOST'), tmpdir.lstrip('/'))

# no standard library method exists for this, so call out to stat to
Expand Down