summaryrefslogtreecommitdiffstats
path: root/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-files-into-newroot.sh
blob: 2ff8664f1fb30d4baf6b0ebc2afa1f3a85a845ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# -*- coding: utf-8 -*-

# copy dnbd3root.service to NEWROOT to ensure it stays known to systemd
systemd_system_unit_path="$(dirname \
    "$(systemctl show -p FragmentPath dracut-mount.service | cut -c 14-)")"
new_systemd_system_unit_path="${NEWROOT}/lib/systemd/system"
cp "${systemd_system_unit_path}/dnbd3root.service" \
    "${new_systemd_system_unit_path}/dnbd3root.service"
mkdir --parents "${new_systemd_system_unit_path}/sysinit.target.wants"
ln --symbolic '../dnbd3root.service' \
    "${new_systemd_system_unit_path}/sysinit.target.wants/dnbd3root.service"

# copy dnbd3-client binary to NEWROOT to make sure it is compatible with the
# kernel module
dnbd3_client_path="$(type -p dnbd3-client)"
if [ -n "$dnbd3_client_path" ]; then
	mkdir -p "${NEWROOT}/${dnbd3_client_path%/*}"
	cp "$dnbd3_client_path" "${NEWROOT}/${dnbd3_client_path}"
fi
true