mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
Compare commits
5 Commits
724c57d309
...
51f9929228
Author | SHA1 | Date | |
---|---|---|---|
|
51f9929228 | ||
|
508ee0ae8e | ||
|
ca9b48cb58 | ||
|
817dd802aa | ||
|
6a5679ba23 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
conf/user.inc.php
|
||||
conf/user_defined.php
|
||||
userdata/cronjobkey.txt
|
||||
userdata/tmp/
|
||||
www/cache/
|
||||
userdata
|
||||
www/cache/
|
||||
|
@ -1,16 +1,19 @@
|
||||
Upgrade the OpenXE system.
|
||||
OpenXE upgrade 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.php -> The upgrade program
|
||||
upgrade.sh -> The upgrade starter, execute with "./upgrade.sh". Execute without parameters to view possible options.
|
||||
|
||||
Files in the data subdirectory:
|
||||
.in_progress.flag -> if this file exists, an upgrade is in progress, system will be locked
|
||||
upgrade.php -> The upgrade program
|
||||
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
|
||||
|
@ -91,6 +91,12 @@ 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 {
|
||||
@ -121,7 +127,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);
|
||||
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection,$origin);
|
||||
} else {
|
||||
info();
|
||||
}
|
||||
@ -133,7 +139,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) {
|
||||
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) {
|
||||
|
||||
$mainfolder = dirname($directory);
|
||||
$datafolder = $directory."/data";
|
||||
@ -146,16 +152,20 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
|
||||
|
||||
//require_once($directory.'/../cronjobs/githash.php');
|
||||
|
||||
$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 ($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);
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -164,12 +174,12 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
|
||||
}
|
||||
|
||||
echo_out("Setting up git...");
|
||||
$retval = git("init ..", $output,$verbose,$verbose,"Error while initializing git!");
|
||||
$retval = git("init $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
|
||||
if ($retval != 0) {
|
||||
abort("");
|
||||
return(-1);
|
||||
}
|
||||
$retval = git("add ../.", $output,$verbose,$verbose,"Error while initializing git!");
|
||||
$retval = git("add $mainfolder", $output,$verbose,$verbose,"Error while initializing git!");
|
||||
if ($retval != 0) {
|
||||
abort("");
|
||||
return(-1);
|
||||
@ -180,7 +190,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);
|
||||
@ -193,7 +203,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 ..", $output,$verbose,false,"Error while checking Git status.");
|
||||
$retval = git("ls-files -m $mainfolder", $output,$verbose,false,"Error while checking Git status.");
|
||||
if (!empty($output)) {
|
||||
$modified_files = true;
|
||||
echo_out("There are modified files:\n");
|
||||
@ -202,14 +212,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);
|
||||
}
|
||||
@ -463,6 +473,7 @@ 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");
|
2
upgrade/upgrade.sh
Executable file
2
upgrade/upgrade.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo -u www-data php data/upgrade.php "$@"
|
@ -10,6 +10,20 @@
|
||||
-->
|
||||
<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ä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öschen und das Upgrade in der Konsole erneut durchfü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">
|
||||
@ -54,11 +68,11 @@
|
||||
<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ü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" value="do_upgrade" class="ui-button-icon" style="width:100%;">UPGRADE</button></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 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ü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" 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" formtarget="_blank" value="do_db_upgrade" class="ui-button-icon" style="width:100%;">Datenbank UPGRADE</button></td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
@ -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/upgrade.php");
|
||||
include("../upgrade/data/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)
|
||||
//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) {
|
||||
|
||||
$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);
|
||||
upgrade_main($directory,$verbose,true,false,false,true,false,$force,false,false);
|
||||
break;
|
||||
case 'do_upgrade':
|
||||
unlink($logfile);
|
||||
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false);
|
||||
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false,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);
|
||||
upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false,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);
|
||||
upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false,false);
|
||||
break;
|
||||
case 'refresh':
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user