From a1c35d147429b31de3c5af39df369b60dcbc24d5 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 6 Jan 2025 14:15:03 -0700 Subject: [PATCH] python: sd_nspawn: Mount NAS into container Signed-off-by: Nathan Chancellor --- python/scripts/sd_nspawn.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/scripts/sd_nspawn.py b/python/scripts/sd_nspawn.py index ed7064da..a36b54a6 100755 --- a/python/scripts/sd_nspawn.py +++ b/python/scripts/sd_nspawn.py @@ -76,10 +76,14 @@ def __init__(self, name): lib.utils.chronic(['systemd-nspawn', '--version']).stdout.splitlines()[0].split()[1]) def _add_dynamic_mounts(self): - rw_mounts = { - '/dev/kvm', + automounted_mounts = { # We may be in a virtual machine os.environ['HOST_FOLDER'], + os.environ['NAS_FOLDER'], + } + rw_mounts = { + '/dev/kvm', + *automounted_mounts, os.environ['NVME_FOLDER'], # Allow 'fzf --tmux' to work properly '/var/tmp/fzf', @@ -116,10 +120,10 @@ def _add_dynamic_mounts(self): # which needs to be written to as the host root user by the # container root user. For mounts where the current user can read # and write to, the mapping mentioned earlier makes everything work - # as expeced without 'idmap'. We special case HOST_FOLDER because - # the os.access check may not pass if the folder has not been - # automounted yet. - if mount == os.environ['HOST_FOLDER'] or os.access(mount, os.R_OK | os.W_OK): + # as expeced without 'idmap'. We special case automounted mounts + # because the os.access check may not pass if the folder has not + # been automounted yet. + if mount in automounted_mounts or os.access(mount, os.R_OK | os.W_OK): item = mount else: item = f"{mount}:{mount}:idmap"