iPXE discussion forum
Simple Chainload from UNDIonly.kpxe to ipxe.pxe - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: Simple Chainload from UNDIonly.kpxe to ipxe.pxe (/showthread.php?tid=6761)



Simple Chainload from UNDIonly.kpxe to ipxe.pxe - MultimediaMan - 2012-11-04 00:21

Playing around with some scripts, and came up with this as a general purpose UNDI bootstrap script: The first script has a small pause and a display of system CPU capabilities which can be used for other purposes further down the chain. (Like what branch to install... i386 or x86_64)

Code:
#!ipxe
#Embedded Boot Script for undionly.kpxe

set boot-mode undionly

cpuid --ext 29 && set arch x86_64 || set arch i386
cpuid 6 && set pae 1 || set pae 0
cpuid --ecx 5 && set vmx 1 || set vmx 0
cpuid --ext --ecx 2 && set svm 1 || set svm 0

set 0_attempt 1
echo
echo Welcome to iPXE!
echo
echo iPXE is running in UNDI Mode...
echo
goto 0_startme

:0_retry0
set 0_attempt 2
sleep 3
goto 0_startme

:0_retry1
set 0_attempt 3
sleep 3
goto 0_startme

:0_retry2
echo No DHCP Lease or Boot Filename received; Exiting iPXE.
sleep 3
exit

:0_startme
dhcp && isset {filename} || goto 0_retry_loop
goto 0_sys_info

:0_retry_loop
#Three (3) re-tries of the 0_startme Function to get a DHCP Address.
iseq ${0_attempt} 1 && goto 0_retry0 ||
iseq ${0_attempt} 2 && goto 0_retry1 ||
iseq ${0_attempt} 3 && goto 0_retry2 ||

:0_sys_info
echo
echo iPXE System Summary:
echo Processor Architecture: ${arch}
echo PAE Supported ${pae}
iseq ${vmx} 1 && echo VTx Supported ${vmx} ||
iseq ${svm} 1 && echo AMD-v Supported ${svm} ||
echo Model: ${product}
echo UUID: ${uuid}
echo Serial Number: ${serial}
echo MAC Address of Booting Interface: ${net0/mac}
echo Root Path: ${17}
echo Boot File Name: ${filename}
echo
sleep 5

echo
echo Attempting to load Native iPXE MicroKernel...
sleep 2
chain ${17}/ipxe.pxe || goto 0_end

:0_end
echo
echo Thank You for using iPXE!
sleep 3
exit

To be used with the following Native ipxe.pxe Embedded script: This script offers up hard system information and capabilities to a PHP-driven decision engine.

Code:
#!ipxe

echo
echo iPXE is running in Native Mode...
echo

dhcp

set boot-mode native

echo
echo Attempting Serial Number Boot Script...
sleep 2
chain ${17}/boot.php?sn=${serial}&uuid=${uuid}&arch=${arch}&product=${product}&vmx=${vmx}&svm=${svm} && goto 0_end || goto 0_outcome_0

:0_outcome_0
echo
echo PHP Boot Script Not Found... Attempting Default Boot Script...
sleep 2
chain ${17}/default.ipxe && goto 0_end || goto 0_outcome_1

:0_outcome_1
echo
echo No Boot Script Not Found... Embedded Boot Script Ending; exiting iPXE...
sleep 2

:0_end
echo
echo Thank You for using iPXE!
sleep 3
exit