74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
|
|
$SelfUpdateUrl = "https://tonoxisisle.services/tononixOS/recovery/BUILD-DATA";
|
|
$SelfUpdateZipUrl = "https://tonoxisisle.services/tononixOS/recovery/recovery.zip";
|
|
|
|
$SerialNumber = file_get_contents("/sys/firmware/devicetree/base/serial-number");
|
|
#$SerialNumber = "000019292900aTEST";
|
|
$SerialNumber = str_replace("\r","",$SerialNumber);
|
|
$SerialNumber = str_replace("\n","",$SerialNumber);
|
|
|
|
$RecoveryVersionInfo = file("/mnt/BUILD-DATA");
|
|
$RecoveryVersion = str_replace("PINN Version: ", "", $RecoveryVersionInfo[1]);
|
|
$RecoveryVersion = str_replace("\r","",$RecoveryVersion);
|
|
$RecoveryVersion = str_replace("\n","",$RecoveryVersion);
|
|
|
|
$UpdateServiceHeaders = [
|
|
'X-Device-Serial-Number' => $SerialNumber,
|
|
'X-Device-Bootloader-Version' => $RecoveryVersion,
|
|
'User-Agent' => 'wget/1.0 tononixPC/'.$RecoveryVersion
|
|
];
|
|
|
|
switch($_GET['file'])
|
|
{
|
|
case 'BUILD-DATA':
|
|
$vars = [
|
|
"action"=> "selfupdate_check"
|
|
];
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $SelfUpdateUrl);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders);
|
|
#curl_setopt($ch, CURLOPT_POST, 1);
|
|
#curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_CRLF, 1);
|
|
$buildData = curl_exec($ch);
|
|
if(curl_errno($ch)) {
|
|
print "Error ". curl_errno($ch);
|
|
exit();
|
|
}
|
|
curl_close($ch);
|
|
$version = $buildData;
|
|
|
|
## Begin Processing and Outputting of the data file.
|
|
print($version."\r\n");
|
|
## End Processing and Outputting of the data file.
|
|
|
|
break;
|
|
case 'recovery.zip':
|
|
$vars = [
|
|
"action" => "selfupdate_file"
|
|
];
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $SelfUpdateZipUrl);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $UpdateServiceHeaders);
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
$recoveryZipData = curl_exec($ch);
|
|
if(curl_errno($ch)) {
|
|
print "Error ". curl_errno($ch);
|
|
exit();
|
|
}
|
|
curl_close($ch);
|
|
|
|
# BEGIN Processing and Outputting of ZIP file
|
|
echo($recoveryZipData);
|
|
# END Processing and Outputting of ZIP file
|
|
|
|
break;
|
|
} |