try to fix github actions with new install/froxlor.sql.php; migrate update-functions into class
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function showUpdateStep
|
||||
*
|
||||
* stores and logs the current update progress
|
||||
*
|
||||
* @param string $task
|
||||
* @param bool $needs_status (if false, a linebreak will be added)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showUpdateStep($task = null, $needs_status = true)
|
||||
{
|
||||
global $update_tasks, $task_counter;
|
||||
|
||||
set_time_limit(30);
|
||||
|
||||
// output
|
||||
$update_tasks[$task_counter] = ['title' => $task, 'result' => 0];
|
||||
|
||||
if (!$needs_status) {
|
||||
$task_counter++;
|
||||
}
|
||||
|
||||
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function lastStepStatus
|
||||
*
|
||||
* outputs status of the last update-step
|
||||
*
|
||||
* @param int $status (0 = success, 1 = warning, 2 = failure)
|
||||
* @param string $message
|
||||
* @param string $additional_info
|
||||
*
|
||||
* @return string formatted output and log-entry
|
||||
*/
|
||||
function lastStepStatus(int $status = -1, string $message = '', string $additional_info = '')
|
||||
{
|
||||
global $update_tasks, $task_counter;
|
||||
|
||||
$update_tasks[$task_counter]['result_txt'] = $message ?? 'OK';
|
||||
$update_tasks[$task_counter]['result_desc'] = $additional_info ?? '';
|
||||
|
||||
switch ($status) {
|
||||
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$update_tasks[$task_counter]['result'] = 2;
|
||||
break;
|
||||
case 2:
|
||||
$update_tasks[$task_counter]['result'] = 1;
|
||||
break;
|
||||
default:
|
||||
$update_tasks[$task_counter]['result'] = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
$task_counter++;
|
||||
|
||||
if ($status == -1 || $status == 2) {
|
||||
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
|
||||
} elseif ($status == 0 || $status == 1) {
|
||||
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success');
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,10 @@
|
||||
* @license http://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||
*/
|
||||
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Install\Update;
|
||||
|
||||
if (!defined('_CRON_UPDATE')) {
|
||||
if (!defined('AREA') || (defined('AREA') && AREA != 'admin') || !isset($userinfo['loginname']) || (isset($userinfo['loginname']) && $userinfo['loginname'] == '')) {
|
||||
@@ -34,21 +36,21 @@ if (!defined('_CRON_UPDATE')) {
|
||||
}
|
||||
|
||||
// last 0.10.x release
|
||||
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
showUpdateStep("Updating from 0.10.99 to 0.11.0-dev1", false);
|
||||
if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
Update::showUpdateStep("Updating from 0.10.99 to 0.11.0-dev1", false);
|
||||
|
||||
showUpdateStep("Removing unused table");
|
||||
Update::showUpdateStep("Removing unused table");
|
||||
Database::query("DROP TABLE IF EXISTS `panel_sessions`;");
|
||||
Database::query("DROP TABLE IF EXISTS `panel_languages`;");
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
showUpdateStep("Updating froxlor - theme");
|
||||
Update::showUpdateStep("Updating froxlor - theme");
|
||||
Database::query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `theme` = 'Froxlor' WHERE `theme` <> 'Froxlor';");
|
||||
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `theme` = 'Froxlor' WHERE `theme` <> 'Froxlor';");
|
||||
Settings::Set('panel.default_theme', 'Froxlor');
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
showUpdateStep("Creating new tables and fields");
|
||||
Update::showUpdateStep("Creating new tables and fields");
|
||||
Database::query("DROP TABLE IF EXISTS `panel_usercolumns`;");
|
||||
$sql = "CREATE TABLE `panel_usercolumns` (
|
||||
`adminid` int(11) NOT NULL default '0',
|
||||
@@ -60,10 +62,10 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
KEY customerid (customerid)
|
||||
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;";
|
||||
Database::query($sql);
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
|
||||
showUpdateStep("Cleaning up old files");
|
||||
Update::showUpdateStep("Cleaning up old files");
|
||||
$to_clean = array(
|
||||
"install/lib",
|
||||
"install/lng",
|
||||
@@ -93,22 +95,22 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
}
|
||||
}
|
||||
if ($exec_allowed) {
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
} else {
|
||||
if (empty($del_list)) {
|
||||
// none of the files existed
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
} else {
|
||||
lastStepStatus(1, 'manual commands needed', 'Please run the following commands manually:<br><pre>' . $del_list . '</pre>');
|
||||
Update::lastStepStatus(1, 'manual commands needed', 'Please run the following commands manually:<br><pre>' . $del_list . '</pre>');
|
||||
}
|
||||
}
|
||||
|
||||
showUpdateStep("Adding new settings");
|
||||
Update::showUpdateStep("Adding new settings");
|
||||
$panel_settings_mode = isset($_POST['panel_settings_mode']) ? (int) $_POST['panel_settings_mode'] : 0;
|
||||
Settings::AddNew("panel.settings_mode", $panel_settings_mode);
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
showUpdateStep("Adjusting existing settings");
|
||||
Update::showUpdateStep("Adjusting existing settings");
|
||||
Settings::Set('system.passwordcryptfunc', PASSWORD_DEFAULT);
|
||||
// remap default-language
|
||||
$lang_map = [
|
||||
@@ -122,11 +124,11 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
'Česká republika' => 'cs'
|
||||
];
|
||||
Settings::Set('panel.standardlanguage', $lang_map[Settings::Get('panel_standardlanguage')] ?? 'en');
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
|
||||
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
showUpdateStep("Updating from 0.10.99 to 0.11.0-dev1", false);
|
||||
\Froxlor\Froxlor::updateToVersion('0.11.0-dev1');
|
||||
if (Froxlor::isFroxlorVersion('0.10.99')) {
|
||||
Update::showUpdateStep("Updating from 0.10.99 to 0.11.0-dev1", false);
|
||||
Froxlor::updateToVersion('0.11.0-dev1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
* @license http://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||
*/
|
||||
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FileDir;
|
||||
|
||||
/**
|
||||
* Function getPreConfig
|
||||
*
|
||||
@@ -38,7 +41,7 @@ function getPreConfig($current_version, $current_db_version): array
|
||||
{
|
||||
$has_preconfig = false;
|
||||
|
||||
include_once \Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/preconfig/0.11/preconfig_0.11.inc.php');
|
||||
include_once FileDir::makeCorrectFile(dirname(__FILE__) . '/preconfig/0.11/preconfig_0.11.inc.php');
|
||||
$return['section_011'] = [
|
||||
'title' => '0.11.x updates',
|
||||
'fields' => []
|
||||
@@ -69,9 +72,9 @@ function getPreConfig($current_version, $current_db_version): array
|
||||
|
||||
function versionInUpdate($current_version, $version_to_check)
|
||||
{
|
||||
if (!\Froxlor\Froxlor::isFroxlor()) {
|
||||
if (!Froxlor::isFroxlor()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \Froxlor\Froxlor::versionCompare2($current_version, $version_to_check) == -1;
|
||||
return Froxlor::versionCompare2($current_version, $version_to_check) == -1;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
* @license http://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||
*/
|
||||
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Filedir;
|
||||
use Froxlor\FroxlorLogger;
|
||||
|
||||
require_once __DIR__ . '/lib/updateFunctions.php';
|
||||
use Froxlor\UI\Response;
|
||||
use Froxlor\Database\IntegrityCheck;
|
||||
use Froxlor\Install\Update;
|
||||
|
||||
if (!defined('_CRON_UPDATE')) {
|
||||
if (!defined('AREA') || (defined('AREA') && AREA != 'admin') || !isset($userinfo['loginname']) || (isset($userinfo['loginname']) && $userinfo['loginname'] == '')) {
|
||||
@@ -41,35 +44,35 @@ $filelog = FroxlorLogger::getInstanceOf(array(
|
||||
// if first writing does not work we'll stop, tell the user to fix it
|
||||
// and then let him try again.
|
||||
try {
|
||||
$filelog->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, '-------------- START LOG --------------');
|
||||
$filelog->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, '-------------- START LOG --------------');
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::standard_error('exception', $e->getMessage());
|
||||
Response::standard_error('exception', $e->getMessage());
|
||||
}
|
||||
|
||||
if (\Froxlor\Froxlor::isFroxlor()) {
|
||||
if (Froxlor::isFroxlor()) {
|
||||
|
||||
// will be filled and increased by the update include-files below
|
||||
$update_tasks = [];
|
||||
$task_counter = 0;
|
||||
|
||||
include_once(\Froxlor\FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.11/update_0.11.inc.php'));
|
||||
include_once(FileDir::makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.11/update_0.11.inc.php'));
|
||||
|
||||
// Check Froxlor - database integrity (only happens after all updates are done, so we know the db-layout is okay)
|
||||
showUpdateStep("Checking database integrity");
|
||||
Update::showUpdateStep("Checking database integrity");
|
||||
|
||||
$integrity = new \Froxlor\Database\IntegrityCheck();
|
||||
$integrity = new IntegrityCheck();
|
||||
if (!$integrity->checkAll()) {
|
||||
lastStepStatus(1, 'Monkeys ate the integrity');
|
||||
showUpdateStep("Trying to remove monkeys, feeding bananas");
|
||||
Update::lastStepStatus(1, 'Monkeys ate the integrity');
|
||||
Update::showUpdateStep("Trying to remove monkeys, feeding bananas");
|
||||
if (!$integrity->fixAll()) {
|
||||
lastStepStatus(2, 'failed', 'Some monkeys just would not move, you should contact team@froxlor.org');
|
||||
Update::lastStepStatus(2, 'failed', 'Some monkeys just would not move, you should contact team@froxlor.org');
|
||||
} else {
|
||||
lastStepStatus(0, 'Integrity restored');
|
||||
Update::lastStepStatus(0, 'Integrity restored');
|
||||
}
|
||||
} else {
|
||||
lastStepStatus(0);
|
||||
Update::lastStepStatus(0);
|
||||
}
|
||||
|
||||
$filelog->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, '--------------- END LOG ---------------');
|
||||
$filelog->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, '--------------- END LOG ---------------');
|
||||
unset($filelog);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user