Skip to content

Instantly share code, notes, and snippets.

@blha303
Created August 31, 2018 06:43
Show Gist options
  • Save blha303/355414d84b84cecd72e9294c99ef269a to your computer and use it in GitHub Desktop.
Save blha303/355414d84b84cecd72e9294c99ef269a to your computer and use it in GitHub Desktop.
Loads a directory of isos and returns an ipxe-compatible boot list
<?php
header("Content-Type: text/plain");
$server = "http://192.168.1.1";
?>
#!ipxe
menu ISO Directory
<?php
$arr = array();
$urls = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('iso', FilesystemIterator::SKIP_DOTS)) as $item => $file) {
$arr[] = $item;
}
sort($arr);
foreach($arr as $item) {
if (substr($item,-4) == ".iso") {
$bn = basename($item, ".iso");
$urls[] = array($bn,$item); ?>
item <?php echo $bn; ?> ${space} <?php echo $bn; ?>
<?php
}
} ?>
choose --default ${menu} menu || goto iso_exit
echo ${cls}
goto ${menu} ||
chain ${menu}.ipxe || goto iso_exit
goto iso_exit
<?php
foreach ($urls as $pair) { ?>
:<?php echo $pair[0]; ?>
set util_path <?php echo $pair[1]; ?>
set util_file <?php echo $pair[0]; ?>.iso
goto boot_memdisk
<?php
}
?>
:boot_memdisk
imgfree
kernel ${memdisk} iso raw
initrd --name ${util_file} <?php echo $server; ?>/pxe/${util_path}
echo
boot
goto iso_exit
:iso_exit
clear menu
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment