Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Useful Scripts
2012-06-20, 15:23
Post: #1
Wink Useful Scripts
show_all_variables.ipxe
=================

Description: will show all (or most) variables (List: http://ipxe.org/cfg) currently assigned or inherited by the dhcp server, perfect when testing, saved me a bunch of time... It is formatted to fill exactly the full page, and show the dhcp option id when it exists.

Code:
#!ipxe
# Made by ZeroQI
# PXE error codes        http://h18013.www1.hp.com/products/servers/management/rdp/knowledgebase/00000138.html
# Ascii to Hec convertor http://easycalculation.com/ascii-hex.php
#In the same way that option 43 is an option space containing vendor-encapsulated options,
# gPXE/iPXE uses option 175 to contain gPXE-specific encapsulated options.

:first_page
echo Client Fields___ Option_ Value_________________________________________________
echo manufacturer.... ....... ${manufacturer}
echo product......... ....... ${product}
echo serial.......... ....... ${serial}
echo asset........... ....... ${asset}
echo mac............. ....... ${mac}
echo uuid............ 097.... ${uuid}
echo busid........... 175.177 ${busid}#can be used to chainload
echo user class...... 077.... ${user-class}
echo
echo DHCP Fields_____ Option_ Value_________________________________________________
echo dhcp-server..... 054.... ${dhcp-server}
echo domain.......... 015.... ${domain}
echo hostname........ 012.... ${hostname}
echo ip.............. 050.... ${ip}
echo netmask......... 001.... ${netmask}
echo gateway......... 003.... ${gateway}
echo dns............. 006.... ${dns}
echo syslog.......... 007.... ${7:ipv4} / "${syslog}" (if support compiled)
echo ntp-server...... 042.... ${42:ipv4}
echo
echo next-server..... 066.... ${next-server}
echo filename........ 067.... ${filename}
echo
prompt Press any key to continue...

:second_page
echo DHCP options____ Option_ Value_________________________________________________
echo priority........ 175.001 ${priority:hex}
echo no-pxedhcp...... 175.176 ${175.176:hex}
echo use-cached...... 175.178 ${use-cached:hex}
echo scriptlet....... 175.081 ${scriptlet}
echo bios-drive...... 175.189 ${189}#what is this for???
echo version-code.... 175.235 ${235}#what is this for???
echo
echo San settings____ Option_ Value_________________________________________________
echo keep-san........ 175.008 ${keep-san:hex}
echo skip-san-boot... 175.009 ${skip-san-boot}
echo root-path....... 017.... ${root-path}    #iscsi:<servername (domain name, ipv4)>:[protocol (6)]:[port (3260)]:[LUN (0)]:<targetname (IQN)>
echo initiator-iqn... 203.... ${initiator-iqn}    #iscsi:my.target.dns.name::::iqn.2007-08.name.dns.target.my:iscsiboot #[Serva32/64 forbid ascii use]
echo
echo Authenticaition_ Option_ Value_________________________________________________
echo username........ 175.190 ${username}        
echo password........ 175.191 ${password}
echo reverse-username 175.192 ${reverse-username}
echo reverse-password 175.193 ${reverse-password}
echo
echo
echo
echo
echo
#Go in windows character map, select system font, 0x100+ascii code for letter in key.h [ http://git.ipxe.org/ipxe.git/blob/HEAD:/src/include/ipxe/keys.h ]
prompt --key 0x141 Press UP to go back to the first page or any other key to continue... && goto first_page ||    #UP
Find all posts by this user
Quote this message in a reply
2012-06-27, 08:03 (This post was last modified: 2012-06-27 08:03 by robinsmidsrod.)
Post: #2
RE: Useful Scripts
You are aware of the "config" command, aren't you? Any reason why you'd go to all this trouble when it is there? It is designed for interactive use. http://ipxe.org/cmd/config
Visit this user's website Find all posts by this user
Quote this message in a reply
2012-06-27, 10:16
Post: #3
RE: Useful Scripts
I was aware of config command but it didn't show when i tried the values of "no-pxedhcp" and "use-cached", and other variables. I simply wanted to show all variables and also the corresponding dhcp option and how to display/use it in a script in an easy way... I do believe this script achieve that.
Find all posts by this user
Quote this message in a reply
2012-06-28, 09:13 (This post was last modified: 2012-06-28 09:26 by ZeroQI.)
Post: #4
Speed_test.ipxe
============
Here is a small test showing me how long it takes in seconds to transfer files of different sizes, to compare FTP, TFTP, and HTTP performance...

Code:
#!ipxe
echo ===============================================================================
time imgfetch tftp://${next-server}/diag/test/1MB                && imgfree && set tftp 1 ||
time imgfetch http://${next-server}/diag/test/1MB                && imgfree && set http 1 ||
time imgfetch  ftp://serva:serva@${next-server}:21/diag/test/1MB            && imgfree && set ftp  1 ||
#echo ===============================================================================
#isset $(tftp) && time imgfetch tftp://${next-server}/diag/test/5MB        && imgfree ||
#isset $(hftp) && time imgfetch http://${next-server}/diag/test/5MB        && imgfree ||
#isset $(ftp)  && time imgfetch  ftp://serva:serva@${next-server}/diag/test/5MB    && imgfree ||
echo ===============================================================================
isset $(tftp) && time imgfetch tftp://${next-server}/diag/test/10MB        && imgfree ||
isset $(hftp) && time imgfetch http://${next-server}/diag/test/10MB        && imgfree ||
isset $(ftp)  && time imgfetch  ftp://serva:serva@${next-server}/diag/test/10MB    && imgfree ||
#echo ===============================================================================
#isset $(tftp) && time imgfetch tftp://${next-server}/diag/test/20MB        && imgfree ||
#isset $(hftp) && time imgfetch http://${next-server}/diag/test/20MB        && imgfree ||
#isset $(ftp)  && time imgfetch  ftp://serva:serva@${next-server}/diag/test/20MB    && imgfree ||
#echo ===============================================================================
#isset $(tftp) && time imgfetch tftp://${next-server}/diag/test/50MB        && imgfree ||
#isset $(hftp) && time imgfetch http://${next-server}/diag/test/50MB        && imgfree ||
#isset $(ftp)  && time imgfetch  ftp://serva:serva@${next-server}/diag/test/50MB    && imgfree ||
echo ===============================================================================
isset $(tftp) && time imgfetch tftp://${next-server}/diag/test/100MB        && imgfree ||
isset $(hftp) && time imgfetch http://${next-server}/diag/test/100MB        && imgfree ||
isset $(ftp)  && time imgfetch  ftp://serva:serva@${next-server}/diag/test/100MB    && imgfree ||
echo ===============================================================================
prompt Press a key to continue...

=======
Before menu command i made a small menu that would be called, allowing me to load either PXElinux 3.86 or PXElinux 4.04 with the same menu, so it is easy to carry out tests...

Might be useful for people using older versions of iPxe

Code:
:menu
echo iPXE menu
echo =========
echo 1) Show_all_variables.ipxe
echo 2) Speed_test.ipxe
echo ===============================================
echo 3) iPXE -> Vesamenu.c32 [no pxelinux, exit when runnin script]
echo 4) TFTP Chainload PXElinux 3.86 [Com32]
echo 5) TFTP Chainload PXElinux 4.04 [Com32R]
echo
echo 6) iSCSI Boot iso (int 0x13 or iSCSI driver managed)
echo 7) http sanbooot (Currently fails with)
echo 8) memdisk http load
echo
echo 9) Reboot (if compiled in kernel)
echo 0) Exit to iPXE shell prompt
echo
echo -n Please select the option:
read key
goto option_${key} || goto menu # loop back if empty or wrong
#iseq option_${key} option_ && goto menu || #loop back if empty choice only

echo "goto" support not implemented option for key "${key}" doesn't exist
prompt Press a key to continue...
reboot ||
echo "reboot" support not implemented
autoboot

:option_1
chain show_all_variables.ipxe
goto menu

:option_2
chain speed_test.ipxe
goto menu

:option_3
chain /pxelinux.cfg/3.86/vesamenu.c32 ../skin/default/graphics.conf ../default ../pxelinux-not-loaded
prompt Press a key to continue...
goto menu

:option_4
set 209:string ../pxelinux-loader
set 210:string pxelinux.cfg/3.86/
chain ${210:string}pxelinux.0
goto end

:option_5
set 209:string ../pxelinux-loader
set 210:string pxelinux.cfg/4.04/
chain ${210:string}/pxelinux.0
goto end

:option_6
#ipxe ibft support passing 1 parameter only
set keep-san 1
#set initiator-iqn iqn.1998-01.com.vmware:ipxe.testlab.bv.ar.us.local
#sanhook iscsi:192.168.65.2::::iqn.1991-05.com.microsoft:ipxe-target
sanboot --drive 0x81 iscsi:${next-server}::::iqn.2008-08.com.starwindsoftware:${next-server}-recovery
Goto end

:option_7
#sanboot --drive 0x81 --no-describe http://${next-server}/iso/Utilities/7rd32.iso
imgfetch iso/Windows_Tiny7.iso
chain pxelinux.cfg/3.86/memdisk iso raw
goto end

:option_8
#imgfetch http://${next-server}/iso/ReflashUtility1-10.iso
#chain    http://${next-server}/pxelinux.cfg/3.86/memdisk iso raw
#syno_hw_version=DS1010+v20 ihd_num=2 init=/sbin/init /etc/sh
###loadbusybox
#kernel /synology/kernel/vmlinuz2
#initrd /synology/kernel/rd.gz
#imgargs vmlinuz2 root=/dev/sda1 init=/bin/sh raid=noautodetect
kernel /synology/kernel/vmlinuz2
initrd /synology/kernel/rd.gz
imgargs vmlinuz2 root=/dev/sda1 init=/bin/sh
imgstat
boot

goto end

:option_9
reboot ||

:option_0
:end
echo "menu.ipxe: End of script"
shell ||

Here is the iSCSI code i wrote when using starwind software iSCSI solution...

I thought it could help somebody doing the same...

Code:
#!ipxe

dhcp
goto host_${hostname} || goto unknown

:host_thinclient1
sanboot iscsi:192.168.0.1::::iqn.2010-04.org.ipxe:winxp

:host_thinclient2
sanboot iscsi:192.168.0.1::::iqn.2010-04.org.ipxe:win7

:unknown
echo Unknown host ${hostname}

#!ipxe
#to enable when embedded, use cache set to 1 if kkpxe, not for kpxe due to dropped pxe stack
#set use-cached 0
#dhcp net0

set keep-san 1
set initiator-iqn ${next-server}::::iqn.2008-08.com.starwindsoftware:${next-server}-test
set root-path iscsi:${initiator-iqn}-test

#sanhook --drive 0x80 --no-describe iscsi:10.0.0.1::::iqn.2008-08.com.starwindsoftware:10.0.0.1-test
#sanboot --drive 0x81 --no-describe iscsi:10.0.0.1::::iqn.2008-08.com.starwindsoftware:10.0.0.1-esx41

sanhook iscsi:${next-server}::::iqn.2008-08.com.starwindsoftware:${next-server}-${net0/mac:hexhyp} ||
sanboot --drive 0x81 --no-describe iscsi:${next-server}::::iqn.2008-08.com.starwindsoftware:${next-server}-esx41
sanboot ${root-path} ||
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)