From fb11ab78048fb570eb9d19e937f48c57d2ec1ebd Mon Sep 17 00:00:00 2001 From: Ian Leonard Date: Sat, 24 Feb 2024 22:34:09 -0500 Subject: [PATCH] systemd: nspawn: add and populate persistent directory for containers Signed-off-by: Ian Leonard --- packages/sysutils/systemd/package.mk | 7 +++++++ packages/sysutils/systemd/scripts/nspawn-symlink | 5 +++++ .../sysutils/systemd/system.d/nspawn-symlink.service | 12 ++++++++++++ .../systemd/tmpfiles.d/z_02_systemd-nspawn.conf | 4 ++++ 4 files changed, 28 insertions(+) create mode 100755 packages/sysutils/systemd/scripts/nspawn-symlink create mode 100644 packages/sysutils/systemd/system.d/nspawn-symlink.service create mode 100644 packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf diff --git a/packages/sysutils/systemd/package.mk b/packages/sysutils/systemd/package.mk index e4545f7bc39..75c836e3ace 100644 --- a/packages/sysutils/systemd/package.mk +++ b/packages/sysutils/systemd/package.mk @@ -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/systemd-nspawn@.service + 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 @@ -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 } diff --git a/packages/sysutils/systemd/scripts/nspawn-symlink b/packages/sysutils/systemd/scripts/nspawn-symlink new file mode 100755 index 00000000000..468988e7305 --- /dev/null +++ b/packages/sysutils/systemd/scripts/nspawn-symlink @@ -0,0 +1,5 @@ +#!/bin/sh + +for entry in $(find /storage/containers -mindepth 1 -maxdepth 1); do + ln -s "${entry}" /var/lib/machines/ +done diff --git a/packages/sysutils/systemd/system.d/nspawn-symlink.service b/packages/sysutils/systemd/system.d/nspawn-symlink.service new file mode 100644 index 00000000000..6baf682e37c --- /dev/null +++ b/packages/sysutils/systemd/system.d/nspawn-symlink.service @@ -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 diff --git a/packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf b/packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf new file mode 100644 index 00000000000..77b3c294c3c --- /dev/null +++ b/packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf @@ -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 - -