upgrade added info and -o option

This commit is contained in:
OpenXE 2022-12-14 15:18:06 +00:00
parent 6a5679ba23
commit 817dd802aa
3 changed files with 39 additions and 15 deletions

View File

@ -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,12 +152,16 @@ 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);
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 = json_decode($remote_info_contents, true);
if ($check_git || $do_git) {
@ -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");

View File

@ -10,6 +10,19 @@
-->
<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>{|Info|}</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>
Zum Start in der Konsole, im Unterordner "upgrade" diesen Befehl starten: <pre>sudo -u www-data php upgrade.php -do</pre>
</fieldset>
</div>
</div>
</div>
</div>
<form action="" method="post">
[FORMHANDLEREVENT]
<div class="row">
@ -54,11 +67,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&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" 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&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" 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>

View File

@ -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;