Skip to content

Commit

Permalink
systemd: nspawn: add and populate persistent directory for containers
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Leonard <[email protected]>
  • Loading branch information
antonlacon committed Apr 19, 2024
1 parent dda952d commit fb11ab7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/sysutils/systemd/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ post_makeinstall_target() {
if [ ${NSPAWN_SUPPORT} != "yes" ]; then
safe_remove ${INSTALL}/usr/bin/systemd-nspawn
safe_remove ${INSTALL}/usr/lib/systemd/system/[email protected]
safe_remove ${INSTALL}/usr/lib/tmpfiles.d/z_02_systemd-nspawn.conf
safe_remove ${INSTALL}/usr/lib/systemd/system/nspawn-symlink.service
else
find_file_path scripts/nspawn-symlink && cp -PRv ${FOUND_PATH} ${INSTALL}/usr/bin
fi

# remove unneeded generators
Expand Down Expand Up @@ -310,4 +314,7 @@ post_install() {
enable_service network-base.service
enable_service systemd-timesyncd.service
enable_service systemd-timesyncd-setup.service
if [ "${NSPAWN_SUPPORT}" = "yes" ]; then
enable_service nspawn-symlink.service
fi
}
5 changes: 5 additions & 0 deletions packages/sysutils/systemd/scripts/nspawn-symlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

for entry in $(find /storage/containers -mindepth 1 -maxdepth 1); do
ln -s "${entry}" /var/lib/machines/
done
12 changes: 12 additions & 0 deletions packages/sysutils/systemd/system.d/nspawn-symlink.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Make symlinks from /storage/containers to /var/lib/machines
After=systemd-tmpfiles-setup.service
Requires=systemd-tmpfiles-setup.service

[Service]
Type=oneshot
ExecStart=/usr/bin/nspawn-symlink
RemainAfterExit=yes

[Install]
WantedBy=basic.target
4 changes: 4 additions & 0 deletions packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2024-present Team LibreELEC (https://libreleec.tv)

d /storage/containers 0755 root root - -

0 comments on commit fb11ab7

Please sign in to comment.