log` pair // tried to do. The earlier echo was buggy (the `>` redirect was // run as www-data, not under sudo, so it could only ever truncate // a www-data-writable file — a silent no-op when the log was last // touched as root). Run synchronously, BEFORE the backgrounded // pistar-update spawn, so the script's first writes always land // in a freshly cleared file regardless of `&` scheduling. system('sudo truncate -s 0 /var/log/pi-star/pi-star_update.log'); system('sudo /usr/local/sbin/pistar-update > /dev/null 2>&1 &'); } // Sanity Check Passed. header('Cache-Control: no-cache'); // session_start() is no longer called here — csrf_verify() at // the top of the file already started the session via // csrf_session_start(). A second session_start() would emit a // "session is already active" NOTICE on PHP 8.x. The existing // $_SESSION['update_offset'] log-tail logic below works // unchanged against the already-active session. // Initialize session offset only if update has been confirmed if (!isset($_GET['ajax']) && !empty($_POST) && isset($_POST['confirm_update'])) { //unset($_SESSION['update_offset']); if (file_exists('/var/log/pi-star/pi-star_update.log')) { $_SESSION['update_offset'] = filesize('/var/log/pi-star/pi-star_update.log'); } else { $_SESSION['update_offset'] = 0; } } if (isset($_GET['ajax'])) { //session_start(); if (!file_exists('/var/log/pi-star/pi-star_update.log')) { exit(); } $handle = fopen('/var/log/pi-star/pi-star_update.log', 'rb'); if (isset($_SESSION['update_offset'])) { fseek($handle, 0, SEEK_END); if ($_SESSION['update_offset'] > ftell($handle)) //log rotated/truncated $_SESSION['update_offset'] = 0; //continue at beginning of the new log $data = stream_get_contents($handle, -1, $_SESSION['update_offset']); $_SESSION['update_offset'] += strlen($data); echo nl2br($data); } else { fseek($handle, 0, SEEK_END); $_SESSION['update_offset'] = ftell($handle); } exit(); } ?> Pi-Star - <?php echo $lang['digital_voice']." ".$lang['dashboard']." - ".$lang['update'];?>
Pi-Star: / Dashboard:

Pi-Star -

Update Running
Starting update, please wait...
" method="post">

This will update your Pi-Star installation to the latest version.

The update process may take several minutes to complete.
Please do not interrupt the process or power off your system during the update.