mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix incorrectly updating session with build-ok before start of schema update Set a timeout for progress on the schema build 40s (lock wait time is 30s, so must be more than that). Allow the user to restart the process if this timeout is reached. Animate the progress bar while waiting for the schema update. Stop animation on failure or success. Properly destroy the session after install. This allows the user to restart if they need to without any tricks. Move next step buttons to the right.
72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* db-update.inc.php
|
|
*
|
|
* Run database update/deploy for installer
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* @package LibreNMS
|
|
* @link http://librenms.org
|
|
* @copyright 2017 Tony Murray
|
|
* @author Tony Murray <murraytony@gmail.com>
|
|
*/
|
|
|
|
if (file_exists($config['install_dir'] . '/config.php')) {
|
|
echo("This should only be called during install");
|
|
exit;
|
|
}
|
|
|
|
header("Content-type: text/plain");
|
|
header('X-Accel-Buffering: no');
|
|
|
|
$db_vars = array(
|
|
'dbhost' => 'h',
|
|
'dbuser' => 'u',
|
|
'dbpass' => 'p',
|
|
'dbname' => 'n',
|
|
'dbport' => 't',
|
|
'dbsocket' => 's',
|
|
);
|
|
|
|
$cmd = $config['install_dir'] . '/build-base.php -l';
|
|
|
|
foreach ($db_vars as $var => $opt) {
|
|
if ($_SESSION[$var]) {
|
|
$cmd .= " -$opt {$_SESSION[$var]}";
|
|
}
|
|
}
|
|
|
|
echo "Starting Update...\n";
|
|
|
|
if (($fp = popen($cmd . ' 2>&1', "r"))) {
|
|
while (!feof($fp)) {
|
|
$line = stream_get_line($fp, 1024, "\n");
|
|
echo preg_replace('/\033\[[\d;]+m/', '', $line) . PHP_EOL;
|
|
ob_flush();
|
|
flush(); // you have to flush the buffer
|
|
}
|
|
|
|
if (pclose($fp) === 0) {
|
|
echo "Database is up to date!";
|
|
$_SESSION['build-ok'] = true;
|
|
} else {
|
|
echo "Database schema update failed!";
|
|
}
|
|
}
|
|
|
|
ob_end_flush();
|
|
flush();
|
|
session_write_close();
|