Compare commits

..

No commits in common. "51f99292288c623c8f9c4a13ac380f046afc84f4" and "724c57d309272ca8bb4586dc2cfe4ab6167c60de" have entirely different histories.

6 changed files with 29 additions and 58 deletions

5
.gitignore vendored
View File

@ -1,4 +1,5 @@
conf/user.inc.php
conf/user_defined.php
userdata
www/cache/
userdata/cronjobkey.txt
userdata/tmp/
www/cache/

View File

@ -1,19 +1,16 @@
OpenXE upgrade system
Upgrade the OpenXE system.
NOTE:
The upgrade system is for use in LINUX only and needs to have git installed.
The following steps are executed:
1. get files from git
2. run database upgrade
Files in this directory:
UPGRADE.md -> This file
upgrade.sh -> The upgrade starter, execute with "./upgrade.sh". Execute without parameters to view possible options.
upgrade.php -> The upgrade program
Files in the data subdirectory:
upgrade.php -> The upgrade program
.in_progress.flag -> if this file exists, an upgrade is in progress, system will be locked
db_schema.json -> Contains the nominal database structure
exported_db_schema.json -> Contains the exported database structure (optional)
remote.json -> Contains the git remote & branch which should be used for upgrade
upgrade.log -> Contains the output from the last run that was started from within OpenXE

View File

@ -91,12 +91,6 @@ if (php_sapi_name() == "cli") {
$force = false;
}
if (in_array('-o', $argv)) {
$origin = true;
} else {
$origin = false;
}
if (in_array('-connection', $argv)) {
$connection = true;
} else {
@ -127,7 +121,7 @@ if (php_sapi_name() == "cli") {
}
if ($check_git || $check_db || $do_git || $do_db) {
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection,$origin);
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection);
} else {
info();
}
@ -139,7 +133,7 @@ if (php_sapi_name() == "cli") {
}
// -------------------------------- END
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection) {
$mainfolder = dirname($directory);
$datafolder = $directory."/data";
@ -152,20 +146,16 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
//require_once($directory.'/../cronjobs/githash.php');
if ($origin) {
$remote_info = array('host' => 'origin','branch' => 'master');
} else {
$remote_info_contents = file_get_contents($remote_file_name);
if (!$remote_info_contents) {
abort("Unable to load $remote_file_name");
return(-1);
}
$remote_info = json_decode($remote_info_contents, true);
}
$remote_info_contents = file_get_contents($remote_file_name);
if (!$remote_info_contents) {
abort("Unable to load $remote_file_name");
return(-1);
}
$remote_info = json_decode($remote_info_contents, true);
if ($check_git || $do_git) {
$retval = git("log HEAD --", $output,$verbose,false,"");
$retval = git("log HEAD", $output,$verbose,false,"");
// Not a git repository -> Create it and then go ahead
if ($retval == 128) {
if (!$do_git) {
@ -174,12 +164,12 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
}
echo_out("Setting up git...");
$retval = git("init $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
$retval = git("init ..", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) {
abort("");
return(-1);
}
$retval = git("add $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
$retval = git("add ../.", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) {
abort("");
return(-1);
@ -190,7 +180,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
return(-1);
}
$retval = git("checkout FETCH_HEAD -f --", $output,$verbose,$verbose,"Error while initializing git!");
$retval = git("checkout FETCH_HEAD -f", $output,$verbose,$verbose,"Error while initializing git!");
if ($retval != 0) {
abort("");
return(-1);
@ -203,7 +193,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
// Get changed files on system -> Should be empty
$modified_files = false;
$output = array();
$retval = git("ls-files -m $mainfolder", $output,$verbose,false,"Error while checking Git status.");
$retval = git("ls-files -m ..", $output,$verbose,false,"Error while checking Git status.");
if (!empty($output)) {
$modified_files = true;
echo_out("There are modified files:\n");
@ -212,14 +202,14 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
if ($verbose) {
echo_out("--------------- Upgrade history ---------------\n");
$retval = git("log --date=short-local --pretty=\"%cd (%h): %s\" HEAD --not HEAD~5 --",$output,$verbose,$verbose,"Error while showing history!");
$retval = git("log --date=short-local --pretty=\"%cd (%h): %s\" HEAD --not HEAD~5",$output,$verbose,$verbose,"Error while showing history!");
if ($retval != 0) {
abort("");
return(-1);
}
} else {
echo_out("--------------- Current version ---------------\n");
$retval = git("log -1 --date=short-local --pretty=\"%cd (%h): %s\" HEAD --",$output,$verbose,true,"Error while showing history!");
$retval = git("log -1 --date=short-local --pretty=\"%cd (%h): %s\" HEAD",$output,$verbose,true,"Error while showing history!");
if ($retval != 0) {
return(-1);
}
@ -473,7 +463,6 @@ function info() {
echo_out("\t-do: execute all upgrades\n");
echo_out("\t-v: verbose output\n");
echo_out("\t-f: force override of existing files\n");
echo_out("\t-o: update from origin instead of remote.json\n");
echo_out("\t-connection use connection.json in data folder instead of user.inc.php\n");
echo_out("\t-clean: (not yet implemented) create the needed SQL to remove items from the database not in the JSON\n");
echo_out("\n");

View File

@ -1,2 +0,0 @@
#!/bin/bash
sudo -u www-data php data/upgrade.php "$@"

View File

@ -10,20 +10,6 @@
-->
<div id="tabs-1">
[MESSAGE]
<div class="row">
<div class="row-height">
<div class="col-xs-14 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|OpenXE Upgrade-System|}</legend>
Das Upgrade funktioniert in 2 Schritten: Dateien aktualisieren, Datenbank auffrischen. Wenn das Upgrade lange l&auml;uft, kann der Fortschritt in einem neuen Fenster mit "Anzeige auffrischen" angezeigt werden.<br><br>
Falls nach einem Abbruch oder schwerwiegenden Fehler kein Upgrade möglich ist, im Hauptordner den Ordner ".git" l&ouml;schen und das Upgrade in der Konsole erneut durchf&uuml;hren.
Dazu im Unterordner "upgrade" diesen Befehl starten: <pre>./upgrade.sh -do</pre>
</fieldset>
</div>
</div>
</div>
</div>
<form action="" method="post">
[FORMHANDLEREVENT]
<div class="row">
@ -68,11 +54,11 @@ Dazu im Unterordner "upgrade" diesen Befehl starten: <pre>./upgrade.sh -do</pre>
<tr><td colspan=2><button name="submit" value="refresh" class="ui-button-icon" style="width:100%;">Anzeige auffrischen</button></td></tr>
<tr><td colspan=2><button name="submit" value="check_upgrade" class="ui-button-icon" style="width:100%;">Upgrades pr&uuml;fen</button></td></tr>
<tr><td style="width:100%;">{|Upgrade-Details anzeigen|}:</td><td><input type="checkbox" name="details_anzeigen" value=1 [DETAILS_ANZEIGEN] size="20"></td></tr>
<tr [UPGRADE_VISIBLE]><td colspan=2><button name="submit" formtarget="_blank" value="do_upgrade" class="ui-button-icon" style="width:100%;">UPGRADE</button></td></tr>
<tr [UPGRADE_VISIBLE]><td colspan=2><button name="submit" value="do_upgrade" class="ui-button-icon" style="width:100%;">UPGRADE</button></td></tr>
<tr [UPGRADE_VISIBLE]><td style="width:100%;">{|Erzwingen (-f)|}:</td><td><input type="checkbox" name="erzwingen" value=1 [ERZWINGEN] size="20"></td></tr>
<tr><td colspan=2><button name="submit" value="check_db" class="ui-button-icon" style="width:100%;">Datenbank pr&uuml;fen</button></td></tr>
<tr><td style="width:100%;">{|Datenbank-Details anzeigen|}:</td><td><input type="checkbox" name="db_details_anzeigen" value=1 [DB_DETAILS_ANZEIGEN] size="20"></td></tr>
<tr [UPGRADE_DB_VISIBLE]><td colspan=2><button name="submit" formtarget="_blank" value="do_db_upgrade" class="ui-button-icon" style="width:100%;">Datenbank UPGRADE</button></td></tr>
<tr [UPGRADE_DB_VISIBLE]><td colspan=2><button name="submit" value="do_db_upgrade" class="ui-button-icon" style="width:100%;">Datenbank UPGRADE</button></td></tr>
</table>
</fieldset>
</div>

View File

@ -33,7 +33,7 @@ class upgrade {
$this->app->Tpl->Set('DETAILS_ANZEIGEN', $verbose?"checked":"");
$this->app->Tpl->Set('DB_DETAILS_ANZEIGEN', $db_verbose?"checked":"");
include("../upgrade/data/upgrade.php");
include("../upgrade/upgrade.php");
$logfile = "../upgrade/data/upgrade.log";
upgrade_set_out_file_name($logfile);
@ -41,7 +41,7 @@ class upgrade {
$this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden");
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden");
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection)
$directory = dirname(getcwd())."/upgrade";
@ -49,21 +49,21 @@ class upgrade {
case 'check_upgrade':
$this->app->Tpl->Set('UPGRADE_VISIBLE', "");
unlink($logfile);
upgrade_main($directory,$verbose,true,false,false,true,false,$force,false,false);
upgrade_main($directory,$verbose,true,false,false,true,false,$force,false);
break;
case 'do_upgrade':
unlink($logfile);
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false,false);
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false);
break;
case 'check_db':
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
unlink($logfile);
upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false,false);
upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false);
break;
case 'do_db_upgrade':
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
unlink($logfile);
upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false,false);
upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false);
break;
case 'refresh':
break;