2010-03-17 14:43:11 +01:00
|
|
|
# vim: set ft=sh:
|
|
|
|
|
2011-11-28 16:28:03 +01:00
|
|
|
run_hook() {
|
2011-12-02 04:44:02 +01:00
|
|
|
if [[ -n "${ip}" && -n "${archiso_nbd_srv}" ]]; then
|
|
|
|
|
|
|
|
archiso_nbd_srv=$(eval echo ${archiso_nbd_srv})
|
2011-07-07 20:24:24 +02:00
|
|
|
[[ -z "${archiso_nbd_name}" ]] && archiso_nbd_name="archiso"
|
|
|
|
|
2010-03-18 15:20:05 +01:00
|
|
|
mount_handler="archiso_pxe_nbd_mount_handler"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
archiso_pxe_nbd_mount_handler () {
|
|
|
|
newroot="${1}"
|
|
|
|
|
|
|
|
# Module autoloading like with loop devices does not work, doing manually...
|
|
|
|
modprobe nbd 2> /dev/null
|
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"
|
|
|
|
if [[ "${copytoram}" = "y" ]]; then
|
|
|
|
nbd-client ${archiso_nbd_srv} -N ${archiso_nbd_name} /dev/nbd0
|
2010-03-18 15:20:05 +01:00
|
|
|
else
|
2011-11-28 16:28:03 +01:00
|
|
|
nbd-client ${archiso_nbd_srv} -N ${archiso_nbd_name} /dev/nbd0 -persist
|
2010-03-18 15:20:05 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
archisodevice=/dev/nbd0
|
2010-03-17 14:43:11 +01:00
|
|
|
|
2010-03-18 15:20:05 +01:00
|
|
|
archiso_mount_handler ${newroot}
|
2010-03-17 14:43:11 +01:00
|
|
|
|
2011-11-28 16:28:03 +01:00
|
|
|
if [[ "${copytoram}" = "y" ]]; then
|
|
|
|
msg ":: Disconnect NBD from ${archiso_nbd_srv} at /dev/nbd0"
|
2010-03-18 15:20:05 +01:00
|
|
|
nbd-client -d /dev/nbd0
|
2011-06-19 00:46:08 +02:00
|
|
|
else
|
2011-08-26 09:39:03 +02:00
|
|
|
mkdir -p /run/archiso
|
|
|
|
pidof nbd-client > /run/archiso/nbd_client.pid
|
2011-08-29 20:27:03 +02:00
|
|
|
cp /archiso_pxe_nbd ${newroot}/etc/rc.d/functions.d/
|
2010-03-17 14:43:11 +01:00
|
|
|
fi
|
|
|
|
}
|