v1.8.1: Alignement upload offline sur le flow online (UX + self-heal)
L'upload offline avait deux defauts vs l'update online: - pas de self-heal des services (pas de Step 3c equivalent) - ancienne UX synchrone (spinner sans feedback pendant 60-90s) Maintenant: - update_firmware_from_file.sh: nouveau Step 4c qui appelle setup_services.sh (alignement avec online) - launcher.php upload_firmware: lance le script en background et reutilise le mecanisme log/done de l'update online - admin.html uploadFirmware: apres l'upload du ZIP, bascule sur le meme systeme de polling/progress que l'online (avec mapping d'etapes specifique au script offline) - Detection de fin par substring 'completed successfully!' (matche les 2 markers finaux differents) Fix au passage: le bouton 'Upload & Install' restait bloque sur 'Installing...' apres succes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -578,19 +578,31 @@ if ($type == "upload_firmware") {
|
||||
|
||||
$new_version = trim(file_get_contents("$source_dir/VERSION"));
|
||||
|
||||
// Execute update script
|
||||
$command = "sudo /var/www/nebuleair_pro_4g/update_firmware_from_file.sh '$source_dir' 2>&1";
|
||||
$output = shell_exec($command);
|
||||
// Launch update script in background, reusing the same log/done file mechanism
|
||||
// as the online update. The frontend can then poll update_firmware_progress
|
||||
// to get a live view and final status.
|
||||
$logFile = '/tmp/nebuleair_firmware_update.log';
|
||||
$doneFile = '/tmp/nebuleair_firmware_update.done';
|
||||
|
||||
// Cleanup (also done in script, but just in case)
|
||||
shell_exec("rm -rf $tmp_dir");
|
||||
@file_put_contents($logFile, '');
|
||||
@unlink($doneFile);
|
||||
|
||||
// Note: $source_dir is escaped because it can contain a version-derived folder name.
|
||||
// $tmp_dir is removed by the script itself (Step 7) but we also clean here as a safety net
|
||||
// — done AFTER the script finishes, so we chain it inside the background block.
|
||||
$cmd = '(sudo /var/www/nebuleair_pro_4g/update_firmware_from_file.sh '
|
||||
. escapeshellarg($source_dir) . ' > '
|
||||
. escapeshellarg($logFile) . ' 2>&1; '
|
||||
. 'echo "EXIT_CODE=$?" >> ' . escapeshellarg($logFile) . '; '
|
||||
. 'rm -rf ' . escapeshellarg($tmp_dir) . '; '
|
||||
. 'touch ' . escapeshellarg($doneFile) . ') > /dev/null 2>&1 &';
|
||||
shell_exec($cmd);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'output' => $output,
|
||||
'started_at' => time(),
|
||||
'old_version' => $old_version,
|
||||
'new_version' => $new_version,
|
||||
'timestamp' => date('Y-m-d H:i:s')
|
||||
'new_version' => $new_version
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user