summaryrefslogtreecommitdiffstats
path: root/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh')
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh33
1 files changed, 13 insertions, 20 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
index d0e847ca..58f23207 100755
--- a/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
+++ b/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
@@ -2,27 +2,20 @@
# -*- coding: utf-8 -*-
type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
-# Dracut may not be installed on the new root. Thus copy all services over.
-dracut_mount_unit_path="$(systemctl show -p FragmentPath dracut-mount.service \
- | cut -c 14-)"
-systemd_system_unit_path="${dracut_mount_unit_path%/*}"
+# Copy out 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 file in \
- dracut-cmdline.service \
- dracut-initqueue.service \
- dracut-mount.service \
- dracut-pre-mount.service \
- dracut-pre-pivot.service \
- dracut-pre-trigger.service \
- dracut-pre-udev.service
-do
- cp "${systemd_system_unit_path}/${file}" \
- "${new_systemd_system_unit_path}/${file}"
- # "ln" returns an error if the link already exists.
- source_path="../${file}"
- target_path="${new_systemd_system_unit_path}/initrd.target.wants/${file}"
- ln --symbolic "$source_path" "$target_path" &>/dev/null || \
- warn "Failed to link \"$source_path\" to \"$target_path\"."
+
+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" || \
+ warn "Failed to link \"$source_path\" to \"$target_path\"."
+ done
done