-
-
Save ppouliot/aba354a944046a537eb61f85dc357a16 to your computer and use it in GitHub Desktop.
ipxe php boot system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ipxe | |
# | |
# This file gets compiled into undionly.kpxe | |
################################################################ | |
:vars | |
set next-server 192.168.2.121 | |
cpuid --ext 29 && set arch amd64 || set arch x86 | |
:netconfig | |
dhcp net0 || goto ipxeshell | |
:prompt | |
prompt --key 0x02 --timeout 3000 Press Ctrl-B for the iPXE command line... && goto ipxeshell || | |
# | |
# We call strap so we can escape out of logging for some computers | |
chain http://${next-server}/boot/strap.php && goto exit || | |
echo | |
echo Failed to boot to: http://${next-server}/boot/strap.php | |
echo | |
echo Type help for commands. | |
:ipxeshell | |
shell | |
:exit | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo "#!ipxe\n:start\necho Boot menu\nmenu Selection\n"; | |
$directory = new RecursiveDirectoryIterator("/var/www/iso/"); | |
$display = Array ( 'iso' ); | |
$count = 0; | |
foreach(new RecursiveIteratorIterator($directory) as $file) | |
{ | |
if (in_array(strtolower(array_pop(explode('.', $file))), $display)) | |
echo "item ". $count . " " . array_pop(explode("/", $file)) . "\n"; | |
$count += 1; | |
} | |
echo "choose os && goto \${os}\n"; | |
$count = 0; | |
foreach(new RecursiveIteratorIterator($directory) as $file) | |
{ | |
if (in_array(strtolower(array_pop(explode('.', $file))), $display)) | |
echo ":". $count ."\nsanboot http://debian" . substr($file,8) . "\ngoto start\n"; | |
$count += 1; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('America/Chicago'); | |
//header ( "Content-type: text/plain" ); | |
//if you no mac or webview is set then it is probably a webbrowser | |
if (!isset($_GET['MAC']) ) { | |
$mac = $_GET['MAC']; | |
?><table style="border:5px dotted red" width=800><tr><td> | |
This was not started as an iPXE script. There is a logic in the script you can't see.<br> | |
</td></tr></table> | |
<pre><? | |
} | |
echo "#!gpxe\n"; | |
echo "imgfree\n"; | |
foreach($_GET as $k=>$v){ | |
$$k=$v; | |
#echo "echo $k=$v\n"; #uncomment to debug | |
} | |
$logfile = 'bootlog.csv'; | |
////////////////////////////////////////////////////////////////////////////////////////////////////// | |
$skipfile = "skipmaclog.txt"; | |
if ($skipfile) { $skipmac = file($skipfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } | |
if (in_array($MAC, $skipmac)) { | |
echo "echo not logged.\n"; | |
echo "chain http://".$_SERVER['SERVER_NAME']."/boot/menu.php?MANUFACTURER=\${manufacturer}&PRODUCT=\${product}&SERIAL=\${serial}&MAC=\${netX/mac}&ASSET=\${asset}&HOSTNAME=\${hostname}&USER-CLASS=\${user-class}&UUID=\${uuid}&DHCP-SERVER=\${dhcp-server}&NEXT-SERVER=\${next-server}&FILENAME=\${filename}&ROOT-PATH=\${root-path}&IQN=\${initiator-iqn}\n"; | |
break; | |
} | |
////////////////////////////////////////////////////////////////////////////////////////////////////// | |
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { | |
$serverproto = "https://"; | |
} else { | |
$serverproto = "http://"; | |
} | |
$ipaddress = $_SERVER['REMOTE_ADDR']; | |
$servername = $_SERVER['SERVER_NAME']; | |
$port = $_SERVER['SERVER_PORT']; | |
$page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"; | |
$page .= (!empty($_SERVER['QUERY_STRING'])) ? "?{$_SERVER['QUERY_STRING']}" : ""; | |
$referrer = $_SERVER['HTTP_REFERER']; | |
$useragent = $_SERVER['HTTP_USER_AGENT']; | |
$remotehost = @getHostByAddr($ipaddress); | |
$datetime = mktime(); | |
$logline = $datetime . '|' . $serverproto . '|' . $servername . '|' . $port . '|' . $page . '|' . $referrer . '|' . $useragent . '|' . $MANUFACTURER . '|' . $PRODUCT . '|' . $SERIAL . '|' . $ARCH . '|' . $remotehost . '|'. $ipaddress . '|' . $MAC . '|' . $UUID . "\n"; | |
//echo "echo $datetime . '|' . $serverproto . '|' . $servername . '|' . $port . '|' . $page . '|' . $referrer . '|' . $useragent . '|' . $MANUFACTURER . '|' . $PRODUCT . '|' . $SERIAL . '|' . $ARCH . '|' . $remotehost . '|'. $ipaddress . '|' . $MAC . '|' . $UUID . "\n""; | |
if (!$handle = fopen($logfile, 'a+')) { | |
die("Failed to open log file"); | |
} | |
if (fwrite($handle, $logline) === FALSE) { | |
die("Failed to write to log file"); | |
} | |
fclose($handle); | |
echo "echo logged.\n"; | |
echo "chain http://".$_SERVER['SERVER_NAME']."/boot/menu.php?MANUFACTURER=\${manufacturer}&PRODUCT=\${product}&SERIAL=\${serial}&MAC=\${netX/mac}&ASSET=\${asset}&HOSTNAME=\${hostname}&USER-CLASS=\${user-class}&UUID=\${uuid}&DHCP-SERVER=\${dhcp-server}&NEXT-SERVER=\${next-server}&FILENAME=\${filename}&ROOT-PATH=\${root-path}&IQN=\${initiator-iqn}\n"; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header ( "Content-type: text/plain" ); | |
echo "#!ipxe \n"; | |
echo "imgfree\n"; | |
echo "cpuid --ext 29 && set arch x64 || set arch x86\n"; | |
echo "chain http://".$_SERVER['SERVER_NAME']."/boot/log.php?MANUFACTURER=\${manufacturer}&PRODUCT=\${product}&SERIAL=\${serial}&MAC=\${netX/mac}&ASSET=\${asset}&ARCH=\${arch}&HOSTNAME=\${hostname}&USER-CLASS=\${user-class}&UUID=\${uuid}&DHCP-SERVER=\${dhcp-server}&NEXT-SERVER=\${next-server}&FILENAME=\${filename}&ROOT-PATH=\${root-path}&IQN=\${initiator-iqn}\n"; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
date_default_timezone_set('America/Chicago'); | |
$logfile = 'bootlog.csv'; | |
if (file_exists($logfile)) { | |
$handle = fopen($logfile, "r"); | |
$log = fread($handle, filesize($logfile)); | |
fclose($handle); | |
} else { | |
die ("The log file doesn't exist!"); | |
} | |
$log = explode("\n", trim($log)); | |
for ($i = 0; $i < count($log); $i++) { | |
$log[$i] = trim($log[$i]); | |
$log[$i] = explode('|', $log[$i]); | |
} | |
echo count($log) . " have hit this file."; | |
echo '<table border="1">'; | |
echo '<th>Date</th>'; | |
//echo '<th>Proto</th>'; | |
//echo '<th>Server</th>'; | |
//echo '<th>Port</th>'; | |
//echo '<th>Page</th>'; | |
//echo '<th>Referrer</th>'; | |
//echo '<th>Useragent</th>'; | |
echo '<th>Manufacturer</th>'; | |
echo '<th>Product</th>'; | |
echo '<th>Service Tag</th>'; | |
echo '<th>Arch</th>'; | |
echo '<th>Remote Hostname</th>'; | |
echo '<th>IP Address</th>'; | |
echo '<th>MAC Address</th>'; | |
echo '<th>UUID</th>'; | |
foreach ($log as $logline) { | |
echo '<tr>'; | |
echo '<td nowrap>' . date('d/m/Y H:i:s', $logline['0']) . '</td>'; | |
//echo '<td nowrap>' . $logline['1'] . '</td>'; | |
//echo '<td nowrap>' . $logline['2'] . '</td>'; | |
//echo '<td nowrap>' . $logline['3'] . '</td>'; | |
//echo '<td nowrap>' . $logline['4'] . '</td>'; | |
//echo '<td nowrap>' . $logline['5'] . '</td>'; | |
//echo '<td nowrap>' . $logline['6'] . '</td>'; | |
echo '<td nowrap>' . $logline['7'] . '</td>'; | |
echo '<td nowrap>' . $logline['8'] . '</td>'; | |
echo '<td nowrap>' . $logline['9'] . '</td>'; | |
echo '<td nowrap>' . $logline['10'] . '</td>'; | |
echo '<td nowrap>' . $logline['11'] . '</td>'; | |
echo '<td nowrap>' . $logline['12'] . '</td>'; | |
echo '<td nowrap>' . urldecode($logline['13']) . '</td>'; | |
echo '<td nowrap>' . $logline['14'] . '</td>'; | |
echo '</tr>'; | |
} | |
echo '</table>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment