mk-pxelinux-ramfs: make infinite loop a timeout

So far it infinitely retried the bootscript, that doesn#t seem
reasonable. Per IRC discussion this is now changed to a 600 sec timeout
waiting for a config to appear to then run once on that config.

In case the pxe boot fails the it is now no more a retry loop, but
instead considered a crash as init exits.

Closes: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
Christian Ehrhardt
2017-11-13 15:41:50 +01:00
committed by Michael Holzheu
parent 9259370891
commit 3fc01e7520

View File

@@ -164,7 +164,6 @@ echo "$cmd: Making init script"
# --- begin init script
cat <<'EOF' > $builddir/init
#!/bin/sh
script="/sbin/pxeboot.script"
/bin/mount -t devtmpfs none /dev
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
@@ -173,12 +172,7 @@ script="/sbin/pxeboot.script"
/sbin/modprobe virtio_net
/sbin/udhcpc -O pxeconffile -O pxepathprefix &
while true
do
${script}
/bin/sleep 1
echo "retry ${script}"
done
/sbin/pxeboot.script
EOF
# --- end init script
chmod +x $builddir/init
@@ -305,16 +299,26 @@ cat <<'EOF' > $builddir/sbin/pxeboot.script
set -e
# Check if a valid pxe conf is available
# so far a non configurable 600 sec timeout
PXE_CONF=/etc/pxe.conf
TIMEOUT=600
WAITED=0
echo "waiting for pxe config from DHCP (max $TIMEOUT sec)"
while [ ! -f $PXE_CONF ]
do
sleep 1
WAITED=$(($WAITED + 1))
if [ $WAITED -gt $TIMEOUT ]
then
echo Error waiting for PXE configuration from DHCP
exit
fi
done
# Source the DHCP-generated TFTP info
# Currently we are just looking for siaddr
PXE_CONF=/etc/pxe.conf
if [ -f $PXE_CONF ]
then
. $PXE_CONF
else
echo waiting for PXE configuration from DHCP
exit
fi
. $PXE_CONF
# Retrieve the config (default only for now)
CONFIGS=""