Skip to content

Commit

Permalink
python: sd_nspawn: Mount NAS into container
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Jan 6, 2025
1 parent d00daa7 commit a1c35d1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/scripts/sd_nspawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a1c35d1

Please sign in to comment.