summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjandob2016-03-02 09:36:55 +0100
committerjandob2016-03-02 09:36:55 +0100
commit3a7d36e9e8b6c8ad367b654de0398375f2c28ec9 (patch)
tree97012440c4bf8f265a13bd1dd4aa89109037a9cc
parentfix (diff)
downloadsystemd-init-3a7d36e9e8b6c8ad367b654de0398375f2c28ec9.tar.gz
systemd-init-3a7d36e9e8b6c8ad367b654de0398375f2c28ec9.tar.xz
systemd-init-3a7d36e9e8b6c8ad367b654de0398375f2c28ec9.zip
handle situations when dracut is already installed in the target system
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh31
1 files changed, 20 insertions, 11 deletions
diff --git a/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
index 1bce5ffb..d308decd 100755
--- a/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
+++ b/builder/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
@@ -10,6 +10,13 @@ exceptions.activate
logging.set_commands_level debug
logging.set_level debug
+# 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.
systemd_system_unit_path="$(dirname "$(find / -name dracut-mount.service \
-type f -print -quit)")"
@@ -25,19 +32,21 @@ for file in \
dracut-pre-trigger.service \
dracut-pre-udev.service
do
- cp "${systemd_system_unit_path}/${file}" \
- "${new_systemd_system_unit_path}/${file}"
- ln --symbolic "../${file}" \
- "${new_systemd_system_unit_path}/initrd.target.wants/${file}"
+ exceptions.try
+ {
+ cp "${systemd_system_unit_path}/${file}" \
+ "${new_systemd_system_unit_path}/${file}"
+ # ln returns an error if the link already exists
+ ln --symbolic "../${file}" \
+ "${new_systemd_system_unit_path}/initrd.target.wants/${file}"
+ }
+ exceptions.catch
+ {
+ logging.warn "failed to copy dracut service files to NEWROOT, " \
+ "maybe they already is already installed in the template system"
+ }
done
-# 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"
-
); result=$?; exceptions.deactivate; [[ $result == 0 ]] || exit 1
# region vim modline