Browse Source

- online-update: fix get-kernel.php

master
vanhofen 2 years ago
parent
commit
50b1e13879
  1. 36
      support/online-update/get-kernel.php

36
support/online-update/get-kernel.php

@ -1,7 +1,7 @@
<?php
/*
Example:
http://www.neutrino-images.de/neutrino-images/get-kernel.php?boxtype=armbox&boxmodel=hd51
http://www.neutrino-images.de/neutrino-images/get-kernel.php?boxtype=coolstream&boxmodel=apollo
*/
$boxtype = trim($_GET["boxtype"]);
@ -9,7 +9,9 @@ $boxtype_sc = ""; # autofilled
$boxseries = trim($_GET["boxseries"]);
$boxmodel = trim($_GET["boxmodel"]);
$kernel_prefix = "";
$kernel_suffix = "";
$image_version = "???"; # wildcard for version (e.g. 320)
$image_date = "????????????"; # wildcard for date (e.g. 201601012359)
$image_type = "nightly";
# convert strings to lower case
@ -25,25 +27,37 @@ if ($boxtype == "coolstream" || $boxtype == "cst")
if ($boxmodel == "nevis")
{
$kernel_prefix = "-zImage.img";
$kernel_suffix = "-zImage.img";
}
elseif ($boxmodel == "apollo" || $boxmodel == "shiner" || $boxmodel == "kronos" || $boxmodel == "kronos_v2")
{
$kernel_prefix = "-vmlinux.ub.gz";
$kernel_suffix = "-vmlinux.ub.gz";
}
}
elseif ($boxtype == "armbox" || $boxtype == "arm")
{
$boxtype_sc = "arm";
$kernel_prefix = ".bin";
$kernel_suffix = ".bin";
}
# release/kernel-cst-kronos-vmlinux.ub.gz
# release/ni320-YYYYMMDDHHMM-cst-kronos-vmlinux.ub.gz
$directory = $image_type;
$kernel = $directory . "/kernel-" . $boxtype_sc . "-" . $boxmodel . $kernel_prefix;
$pattern = $directory . "/ni" . $image_version . "-" . $image_date . "-" . $boxtype_sc . "-" . $boxmodel . $kernel_suffix;
if (!file_exists($kernel))
# find last (newest) kernel
$last_mod = 0;
$last_kernel = "";
foreach (glob($pattern) as $kernel)
{
if (is_file($kernel) && filectime($kernel) > $last_mod)
{
$last_mod = filectime($kernel);
$last_kernel = $kernel;
}
}
if (empty($last_kernel))
{
# send error
header('HTTP/1.0 404 Not Found');
@ -54,11 +68,11 @@ else
# send kernel
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($kernel) . '"');
header('Content-Disposition: attachment; filename="' . basename($last_kernel) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($kernel));
readfile($kernel);
header('Content-Length: ' . filesize($last_kernel));
readfile($last_kernel);
}
?>
Loading…
Cancel
Save