summaryrefslogtreecommitdiffstats
path: root/modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh
diff options
context:
space:
mode:
authorSimon Rettberg2026-01-21 12:16:35 +0100
committerSimon Rettberg2026-01-21 12:16:35 +0100
commitdcaa3a822f2a6b824a15740e299eb9d5734600b2 (patch)
tree5f4e8539ba5ddedbbb3bb626ed928207111ef567 /modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh
parentTry to fix cp over dangling symlink (diff)
downloadsystemd-init-master.tar.gz
systemd-init-master.tar.xz
systemd-init-master.zip
[dnbd3-rootfs] Turn hook into serviceHEADmaster
For some reason, after updating to dracut-ng, the service files don't get copied over anymore, while the dnbd3-client binary does. *shrug* Maybe it works better as a service, instead of a hook....
Diffstat (limited to 'modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh')
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh b/modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh
new file mode 100755
index 00000000..11f6500a
--- /dev/null
+++ b/modules.d/dnbd3-rootfs/hooks/s3-copy-dracut-systemd-files-into-newroot.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Copy dnbd3-client too, needed for controlling dnbd0
+mkdir -p "${NEWROOT}/opt/openslx/sbin"
+cp "$(which dnbd3-client)" "${NEWROOT}/opt/openslx/sbin/dnbd3-client"
+
+# Copy our services over to stage 4, so they still appear in
+# systemd-analyze plot etc.
+new_systemd_system_unit_path="${NEWROOT}/lib/systemd/system"
+
+mkdir --parents "$new_systemd_system_unit_path/initrd.target.wants"
+
+for dir in /run/systemd/system /lib/systemd/system /etc/systemd/system; do
+ for file in "$dir"/s3-*.{service,target} "$dir"/dracut-*.{service,target}; do
+ [ -f "$file" ] || continue
+ name="${file##*/}"
+ cp "${file}" "${new_systemd_system_unit_path}/${name}"
+ source_path="../${name}"
+ target_path="${new_systemd_system_unit_path}/initrd.target.wants/${name}"
+ ln -nfs "$source_path" "$target_path" || \
+ echo "Failed to link \"$source_path\" to \"$target_path\"." >&2
+ done
+done
+
+exit 0