summaryrefslogtreecommitdiffstats
path: root/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
blob: 007b950d385d62e8829891f5f2a69a7c15c8e117 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

type emergency_shell &>/dev/null || source /lib/dracut-lib.sh

# 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" || \
			warn "Failed to link \"$source_path\" to \"$target_path\"."
	done
done