mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Initial commit
This commit is contained in:
parent
e2111fdf1f
commit
d14040d3a7
43
ajax/system/sys_read_logfile.php
Normal file
43
ajax/system/sys_read_logfile.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
$logFile = '/tmp/raspap_install.log';
|
||||||
|
$searchStrings = [
|
||||||
|
'Configure update' => 1,
|
||||||
|
'Updating sources' => 2,
|
||||||
|
'Installing required packages' => 3,
|
||||||
|
'Cloning latest files' => 4,
|
||||||
|
'Installing application' => 5,
|
||||||
|
'Installation completed' => 6,
|
||||||
|
'error' => 7
|
||||||
|
];
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
if (file_exists($logFile)) {
|
||||||
|
$handle = fopen($logFile, 'r');
|
||||||
|
|
||||||
|
if ($handle) {
|
||||||
|
while (($line = fgets($handle)) !== false) {
|
||||||
|
foreach ($searchStrings as $searchString => $value) {
|
||||||
|
if (strpos($line, $searchString) !== false) {
|
||||||
|
echo $value .PHP_EOL;
|
||||||
|
flush();
|
||||||
|
ob_flush();
|
||||||
|
if ($value === 6) {
|
||||||
|
fclose($handle);
|
||||||
|
exit();
|
||||||
|
} elseif ($value === 7) {
|
||||||
|
echo $line .PHP_EOL;
|
||||||
|
fclose($handle);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
} else {
|
||||||
|
echo json_encode("Unable to open file: $logFile");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo json_encode("File does not exist: $logFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user