2020-07-11 18:13:20 +02:00
|
|
|
#!/bin/ash
|
2020-05-30 00:01:28 +02:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2010-03-17 14:43:11 +01:00
|
|
|
|
2016-05-25 21:35:12 +02:00
|
|
|
run_earlyhook() {
|
2020-07-16 14:49:23 +02:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
# defined via initcpio's parse_cmdline()
|
2020-07-11 18:13:20 +02:00
|
|
|
if [ -n "${ip}" ] && [ -n "${archiso_nbd_srv}" ]; then
|
2016-05-25 21:35:12 +02:00
|
|
|
# Module autoloading like with loop devices does not work, doing manually...
|
2016-05-28 23:36:56 +02:00
|
|
|
modprobe nbd 2> /dev/null
|
2016-05-25 21:35:12 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-11-28 16:28:03 +01:00
|
|
|
run_hook() {
|
2020-07-11 18:13:20 +02:00
|
|
|
if [ -n "${ip}" ] && [ -n "${archiso_nbd_srv}" ]; then
|
2011-12-02 04:44:02 +01:00
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
archiso_nbd_srv=$(eval echo "${archiso_nbd_srv}")
|
|
|
|
[ -z "${archiso_nbd_name}" ] && archiso_nbd_name="archiso"
|
2011-07-07 20:24:24 +02:00
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
export mount_handler="archiso_pxe_nbd_mount_handler"
|
2010-03-18 15:20:05 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
archiso_pxe_nbd_mount_handler () {
|
|
|
|
newroot="${1}"
|
|
|
|
|
2010-12-08 18:44:48 +01:00
|
|
|
msg ":: Waiting for boot device..."
|
|
|
|
while ! poll_device /dev/nbd0 30; do
|
|
|
|
echo "ERROR: boot device didn't show up after 30 seconds..."
|
|
|
|
echo " Falling back to interactive prompt"
|
|
|
|
echo " You can try to fix the problem manually, log out when you are finished"
|
|
|
|
launch_interactive_shell
|
2010-03-18 15:20:05 +01:00
|
|
|
done
|
|
|
|
|
2011-11-28 16:28:03 +01:00
|
|
|
msg ":: Setup NBD from ${archiso_nbd_srv} at /dev/nbd0"
|
2020-07-11 18:13:20 +02:00
|
|
|
if [ "${copytoram}" != "n" ]; then
|
|
|
|
nbd-client "${archiso_nbd_srv}" -N "${archiso_nbd_name}" /dev/nbd0
|
2012-10-17 00:10:17 +02:00
|
|
|
copytoram="y"
|
2016-05-24 12:02:42 +02:00
|
|
|
else
|
2020-07-11 18:13:20 +02:00
|
|
|
nbd-client "${archiso_nbd_srv}" -N "${archiso_nbd_name}" -systemd-mark -persist /dev/nbd0
|
2012-10-17 00:10:17 +02:00
|
|
|
fi
|
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
export archisodevice=/dev/nbd0
|
2010-03-17 14:43:11 +01:00
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
archiso_mount_handler "${newroot}"
|
2010-03-17 14:43:11 +01:00
|
|
|
|
2020-07-11 18:13:20 +02:00
|
|
|
if [ "${copytoram}" = "y" ]; then
|
2016-05-24 12:02:42 +02:00
|
|
|
msg ":: Disconnect NBD from ${archiso_nbd_srv} at /dev/nbd0"
|
|
|
|
nbd-client -d /dev/nbd0
|
|
|
|
fi
|
2010-03-17 14:43:11 +01:00
|
|
|
}
|
2020-07-11 18:13:20 +02:00
|
|
|
|
|
|
|
# vim: set ft=sh:
|