#!ipxe

# Redhat Enterprise Linux (RHEL)
# https://www.redhat.com

isset ${dhcp-server} && set ipparam ip=dhcp || set ipparam ip=${ip}::${gateway}:${netmask}:::none nameserver=${dns}
set ipparam BOOTIF=${netX/mac} ${ipparam}

set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch x86_64 ||
iseq ${os_arch} arm64 && set os_arch aarch64 ||
goto ${menu} ||

:rhel
set os Red Hat Enterprise Linux - ${os_arch}
clear rhel_version
menu ${os}
item --gap Installers
item rhel_install ${space} ${os} Graphical Install
item rhel_install_text ${space} ${os} Text Install
item --gap Options:
item url_set ${space} Base URL [ ${rhel_base_url} ]
choose rhel_version || goto rhel_exit
goto ${rhel_version}

:url_set
echo Set the HTTP URL of an extracted RHEL ISO without the trailing slash:
echo e.g. http://www.mydomain.com/rhel/7
echo
echo -n URL: ${} && read rhel_base_url
echo
echo netboot.xyz will attempt to load the following files:
echo ${rhel_base_url}/os/${os_arch}/images/pxeboot/vmlinuz
echo ${rhel_base_url}/os/${os_arch}/images/pxeboot/initrd.img
echo
prompt Press any key to return to RHEL Menu...
goto rhel

:rhel_install_text
set params inst.text
goto rhel_install

:rhel_install
isset ${rhel_base_url} && goto boot || echo URL not set... && goto url_set
goto boot

:boot
imgfree
kernel ${rhel_base_url}/os/${os_arch}/images/pxeboot/vmlinuz inst.repo=${rhel_base_url}/os/${os_arch} ${ipparam} ${params} initrd=initrd.magic ${cmdline}
initrd ${rhel_base_url}/os/${os_arch}/images/pxeboot/initrd.img
md5sum vmlinuz initrd.img
boot
goto rhel

:rhel_exit
exit 0
