Last active 1535661780

Loads a directory of isos and returns an ipxe-compatible boot list

ipxe-isodir.php Raw
1<?php
2header("Content-Type: text/plain");
3$server = "http://192.168.1.1";
4?>
5#!ipxe
6
7menu ISO Directory
8<?php
9$arr = array();
10$urls = array();
11foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('iso', FilesystemIterator::SKIP_DOTS)) as $item => $file) {
12 $arr[] = $item;
13}
14sort($arr);
15foreach($arr as $item) {
16 if (substr($item,-4) == ".iso") {
17 $bn = basename($item, ".iso");
18 $urls[] = array($bn,$item); ?>
19item <?php echo $bn; ?> ${space} <?php echo $bn; ?>
20
21<?php
22 }
23} ?>
24choose --default ${menu} menu || goto iso_exit
25echo ${cls}
26goto ${menu} ||
27chain ${menu}.ipxe || goto iso_exit
28goto iso_exit
29
30<?php
31foreach ($urls as $pair) { ?>
32
33:<?php echo $pair[0]; ?>
34
35set util_path <?php echo $pair[1]; ?>
36
37set util_file <?php echo $pair[0]; ?>.iso
38goto boot_memdisk
39<?php
40}
41?>
42
43:boot_memdisk
44imgfree
45kernel ${memdisk} iso raw
46initrd --name ${util_file} <?php echo $server; ?>/pxe/${util_path}
47echo
48boot
49goto iso_exit
50
51:iso_exit
52clear menu
53exit 0
54