Instantly share code, notes, and snippets.
-
Star
1
(1)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save warewolf/39e2166a90addff73358 to your computer and use it in GitHub Desktop.
authenticated iscsi login retry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ipxe | |
# boot-url and sanboot-url is set in bootstrap.ipxe | |
# Setup some basic convenience variables | |
set menu-timeout 5000 | |
set submenu-timeout ${menu-timeout} | |
set base-iqn iqn.2012-12.com.xabean.sandbox | |
set base-iscsi iscsi:${iscsi-server}:::1:${base-iqn} | |
# Set initiator-iqn to either hostname or mac | |
isset ${hostname} && set initiator-iqn ${base-iqn}:${hostname} || set initiator-iqn ${base-iqn}:${mac} | |
# Ensure we have menu-default set to something | |
isset ${menu-default} || set menu-default exit | |
# Figure out some typical client information | |
cpuid --ext 29 && set arch x64 || set arch x86 | |
cpuid --ext 29 && set archl 64 || set archl 32 | |
###################### MAIN MENU #################################### | |
:start | |
menu iPXE http boot menu for ${initiator-iqn} | |
item --gap -- ------------------------- Operating systems ------------------------------ | |
item --key f fedora Boot Fedora from iSCSI | |
item --key w windows7 Boot Windows 7 from iSCSI | |
item --key w windowsxp Boot Windows XP from iSCSI | |
item --gap -- ------------------------- Tools and utilities ---------------------------- | |
item --key p pxelinux Load PXELinux menu | |
item --key i menu-install Installers... | |
item --key l menu-live Live Environments ... | |
item --gap -- ------------------------- Advanced options ------------------------------- | |
item --key c config Configure settings | |
item shell Drop to iPXE shell | |
item reboot Reboot computer | |
item poweroff Power off computer | |
item | |
item --key x exit Exit iPXE and continue BIOS boot | |
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel | |
set menu-timeout 0 | |
goto ${selected} | |
:cancel | |
echo You cancelled the menu, dropping you to a shell | |
:shell | |
echo Type 'exit' to get the back to the menu | |
shell | |
set menu-timeout 0 | |
set submenu-timeout 0 | |
goto start | |
:failed | |
echo Booting failed, dropping to shell | |
goto shell | |
:reboot | |
reboot | |
:poweroff | |
poweroff | |
:exit | |
exit | |
:config | |
config | |
goto start | |
:back | |
set submenu-timeout 0 | |
clear submenu-default | |
goto start | |
:failed-login | |
echo Failed to log into ${failed-login} menu option. | |
prompt --key 0x03 Press Ctrl-B to enter the iPXE command line, or any other key to retry login && shell || | |
login || goto ${failed-login} | |
############ MAIN MENU ITEMS ############ | |
:fedora | |
echo Booting Fedora from iSCSI for ${initiator-iqn} | |
isset ${username} && isset ${password} || login || | |
set root-path ${base-iscsi}:${hostname}.boot.fedora | |
sanhook ${root-path} || set failed-login fedora || goto failed-login | |
boot || goto failed | |
goto start | |
:windows7 | |
echo Booting Windows 7 from iSCSI for ${initiator-iqn} | |
# Force gateway to be the iSCSI target server (kludge for stupid window behavior) | |
#clear netX/gateway | |
#set netX/gateway ${iscsi-server} | |
set root-path ${base-iscsi}:${hostname}.boot.windows7 | |
sanboot ${root-path} || goto failed | |
goto start | |
:windowsxp | |
echo Booting Windows XP from iSCSI for ${initiator-iqn} | |
# Force gateway to be the iSCSI target server (kludge for stupid window behavior) | |
set netX/gateway ${iscsi-server} | |
set root-path ${base-iscsi}:${hostname}.boot.windowsxp | |
sanboot ${root-path} || goto failed | |
goto start | |
:pxelinux | |
set 210:string tftp://${next-server}/ | |
chain ${210:string}pxelinux.0 || goto failed | |
goto start | |
###################### LIVE ENVIRONMENT MENU ######################## | |
:menu-live | |
menu Live environments for ${initiator-iqn} | |
item ubuntu-live-1204 Boot Ubuntu LiveCD 12.04 ${archl} | |
item --key 0x08 back Back to top menu... | |
iseq ${menu-default} menu-live && isset ${submenu-default} && goto menu-live-timed || | |
choose selected && goto ${selected} || goto start | |
:menu-live-timed | |
choose --timeout ${submenu-timeout} --default ${submenu-default} selected && goto ${selected} || goto start | |
:ubuntu-live-1204 | |
# XXX RGH | |
# See http://manpages.ubuntu.com/manpages/precise/man7/casper.7.html for casper cmdline details | |
echo Booting Ubuntu Live 12.04 ${archl} for ${initiator-iqn} | |
set base-url ${boot-url}/ubuntu1204 | |
kernel ${base-url}/casper/vmlinuz | |
initrd ${base-url}/casper/initrd.lz | |
imgargs vmlinuz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.2.104:/nfs4exports/readynas/ubuntu | |
shell | |
boot || goto failed | |
goto start | |
############################ INSTALLER MENU ######################### | |
:menu-install | |
menu Installers for ${initiator-iqn} | |
item fedora-20-install-local Install Fedora 20 to local drive | |
item fedora-20-install Install Fedora 20 to iSCSI | |
item fedora-20-rescue Rescue Fedora 20 to local drive | |
item --gap -- | |
item windows7-install-local Install Windows 7 to local drive | |
item windows7-install Install Windows 7 to iSCSI | |
item windows7-hookonly Hook Windows 7 iSCSI and boot local CD | |
item | |
item --key 0x08 back Back to top menu... | |
iseq ${menu-default} menu-install && isset ${submenu-default} && goto menu-install-timed || | |
choose selected && goto ${selected} || goto start | |
:menu-install-timed | |
choose --timeout ${submenu-timeout} --default ${submenu-default} selected && goto ${selected} || goto start | |
############################ FEDORA 20 | |
:fedora-20-install-local | |
echo Starting Fedora 20 ${archl} local installer for ${initiator-iqn} | |
set base-url ${boot-url}/fc20_${archl} | |
kernel ${base-url}/vmlinuz | |
initrd ${base-url}/initrd.img | |
imgargs vmlinuz repo=nfs:192.168.2.104:/nfs4exports/readynas/fc20_${archl} | |
boot || goto failed | |
goto start | |
:fedora-20-rescue | |
echo Starting Rescue Fedora 20 ${archl} local installer for ${initiator-iqn} | |
set base-url ${boot-url}/fc20_${archl} | |
kernel ${base-url}/vmlinuz | |
initrd ${base-url}/initrd.img | |
imgargs vmlinuz repo=nfs:192.168.2.104:/nfs4exports/readynas/fc20_${archl} rescue | |
boot || goto failed | |
goto start | |
:fedora-20-install | |
echo Fedora 20 ${archl} installer for ${initiator-iqn} | |
set base-url ${boot-url}/fc20_${archl} | |
kernel ${base-url}/vmlinuz | |
initrd ${base-url}/initrd.img | |
imgargs vmlinuz repo=nfs:192.168.2.104:/nfs4exports/readynas/fc20_${archl} ip-ibft | |
set root-path ${base-iscsi}:${hostname}.boot.fedora | |
sanhook ${root-path} || goto failed | |
boot || goto failed | |
goto start | |
:windows7-install-local | |
echo Starting Windows 7 ${arch} installer for ${initiator-iqn} | |
set base-url ${boot-url}/windows-7/professional-${arch}-en | |
kernel ${boot-url}/wimboot | |
initrd ${base-url}/bootmgr bootmgr | |
initrd ${base-url}/boot/bcd BCD | |
initrd ${base-url}/boot/fonts/wgl4_boot.ttf wgl4_boot.ttf | |
initrd ${base-url}/boot/boot.sdi boot.sdi | |
initrd ${base-url}/sources/boot.wim boot.wim | |
boot || goto failed | |
goto start | |
:windows7-install | |
echo Starting Windows 7 ${arch} installer for ${initiator-iqn} | |
set netX/gateway ${iscsi-server} | |
set root-path ${base-iscsi}:${hostname}.boot.windows7 | |
sanhook ${root-path} || goto failed | |
set base-url ${boot-url}/windows-7/professional-${arch}-en | |
kernel ${boot-url}/wimboot | |
initrd ${base-url}/bootmgr bootmgr | |
initrd ${base-url}/boot/bcd BCD | |
initrd ${base-url}/boot/fonts/wgl4_boot.ttf wgl4_boot.ttf | |
initrd ${base-url}/boot/boot.sdi boot.sdi | |
initrd ${base-url}/sources/boot.wim boot.wim | |
boot || goto failed | |
goto start | |
:windows7-hookonly | |
echo Hooking Windows 7 iSCSI volume for ${initiator-iqn} | |
# Force gateway to be the iSCSI target server (kludge for stupid window behavior) | |
set netX/gateway ${iscsi-server} | |
# Hook iSCSI drive | |
set root-path ${base-iscsi}:${hostname}.boot.windows7 | |
sanhook --drive 0x81 ${root-path} || goto failed | |
echo Start Windows 7 installer DVD from local drive | |
sanboot --no-describe --drive 0x80 ${sanboot-url}/windows-7/professional-${arch}-en.iso || goto failed | |
goto start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment