Last active 1535661780

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

Steven Smith revised this gist 1535697780. Go to revision

1 file changed, 53 insertions

ipxe-isodir.php(file created)

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