2010-03-17 14:43:11 +01:00
|
|
|
# vim: set ft=sh:
|
2010-03-18 15:20:05 +01:00
|
|
|
run_hook () {
|
2010-03-17 14:43:11 +01:00
|
|
|
local line i address netmask gateway dns0 dns1 rootserver rootpath filename
|
|
|
|
|
|
|
|
: > /ip_opts
|
|
|
|
|
|
|
|
if [ -n "${ip}" ]; then
|
2010-03-21 21:46:16 +01:00
|
|
|
if [ -n "${BOOTIF}" ]; then
|
|
|
|
bootif_mac=${BOOTIF#01-}
|
|
|
|
bootif_mac=${bootif_mac//-/:}
|
2011-10-12 19:40:19 +02:00
|
|
|
bootif_dev=$(grep -l ${bootif_mac} /sys/class/net/*/address)
|
2010-03-21 21:46:16 +01:00
|
|
|
bootif_dev=${bootif_dev#/sys/class/net/}
|
|
|
|
bootif_dev=${bootif_dev%/address}
|
2011-10-12 19:40:19 +02:00
|
|
|
ip="${ip}::${bootif_dev}"
|
2010-03-21 21:46:16 +01:00
|
|
|
fi
|
|
|
|
|
2010-03-17 14:43:11 +01:00
|
|
|
# setup network and save some values
|
|
|
|
ipconfig "ip=${ip}" | while read line; do
|
|
|
|
# echo ":: ${line}"
|
|
|
|
if [ "${line#"IP-Config:"}" != "${line}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
line="$(echo ${line} | sed -e 's/ :/:/g;s/: /=/g')"
|
|
|
|
for i in ${line}; do
|
|
|
|
case "${i}" in
|
|
|
|
address=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
netmask=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
gateway=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
dns0=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
dns1=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
rootserver=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
rootpath=*)
|
|
|
|
echo "${i}" >> /ip_opts
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
. /ip_opts
|
|
|
|
|
|
|
|
echo "IP-Config: ${address}/${netmask}"
|
|
|
|
echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}"
|
|
|
|
|
2010-03-18 15:20:05 +01:00
|
|
|
nbdserver=${rootserver}
|
2010-03-17 14:43:11 +01:00
|
|
|
|
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
|
|
|
|
|
2010-10-12 06:28:43 +02:00
|
|
|
msg "::: Setup NBD from ${nbdserver} at /dev/nbd0"
|
2010-03-18 15:20:05 +01:00
|
|
|
if [ "${copytoram}" = "y" ]; then
|
2011-07-07 20:24:24 +02:00
|
|
|
nbd-client ${nbdserver} -N ${archiso_nbd_name} /dev/nbd0
|
2010-03-18 15:20:05 +01:00
|
|
|
else
|
2011-07-07 20:24:24 +02:00
|
|
|
nbd-client ${nbdserver} -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
|
|
|
|
2010-03-18 15:20:05 +01:00
|
|
|
if [ "${copytoram}" = "y" ]; then
|
2011-03-02 13:43:32 +01:00
|
|
|
msg "::: Disconnect NBD from ${nbdserver} 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
|
|
|
|
}
|