diff options
author | Jonathan Bauer | 2020-05-13 11:04:02 +0200 |
---|---|---|
committer | Jonathan Bauer | 2020-05-13 11:04:02 +0200 |
commit | 1130873aa55c9b0a7e5af48edc44bd6c6fd1f888 (patch) | |
tree | 0fcfa186cd631d8d36611b3d4bc509fd38841d51 /modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh | |
parent | Merge branch 'centos8' into downloader (diff) | |
download | systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.gz systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.xz systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.zip |
restructure repo
* remove packager
* move everything from builder/* back to root
Diffstat (limited to 'modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh')
-rwxr-xr-x | modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh | 35 |
1 files changed, 35 insertions, 0 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 new file mode 100755 index 00000000..5de1f2e9 --- /dev/null +++ b/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh + +# Needed to be able to go back to dracut at system shutdown. +temporary_directory_path="$(mktemp --directory)" +mount --options bind / "$temporary_directory_path" +cp --recursive --no-target-directory "$temporary_directory_path" /run/initramfs +umount "$temporary_directory_path" +rm --dir "$temporary_directory_path" + +# 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%/*}" +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" "$targetPath" &>/dev/null || \ + warn "Failed to link \"$source_path\" to \"$target_path\"." +done |