mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Setup/Maintenance
* toggle maintenance mode in a more reasonable manner (i.e. not when displaying help test) * move connectivity tests to class DB * restore generate everything functionality when running --sql and --build with an empty parameter set
This commit is contained in:
@@ -12,65 +12,44 @@ require_once 'setup/tools/setupScript.class.php';
|
||||
require_once 'setup/tools/dbc.class.php';
|
||||
require_once 'setup/tools/imagecreatefromblp.func.php';
|
||||
|
||||
|
||||
function finish(bool $unlock = true) : void
|
||||
function finish() : void
|
||||
{
|
||||
if (CLISetup::getOpt('delete')) // generated with TEMPORARY keyword. Manual deletion is not needed
|
||||
CLI::write('generated dbc_* - tables have been deleted.', CLI::LOG_INFO);
|
||||
|
||||
if ($unlock)
|
||||
lockSite(false);
|
||||
|
||||
die("\n");
|
||||
}
|
||||
|
||||
function lockSite(bool $enable = true) : void
|
||||
{
|
||||
if (DB::isConnectable(DB_AOWOW))
|
||||
DB::Aowow()->query('UPDATE ?_config SET `value` = ?d WHERE `key` = "maintenance"', $enable ? 1 : 0);
|
||||
}
|
||||
|
||||
CLISetup::init();
|
||||
|
||||
if (!CLISetup::getOpt(0x3))
|
||||
die(CLISetup::optHelp(0x7));
|
||||
|
||||
$cmd = CLISetup::getOpt(0x3)[0]; // get arguments present in argGroup 1 or 2, if set. Pick first.
|
||||
$unlock = false;
|
||||
$s = [];
|
||||
$b = [];
|
||||
$cmd = CLISetup::getOpt(0x3)[0]; // get arguments present in argGroup 1 or 2, if set. Pick first.
|
||||
$s = [];
|
||||
$b = [];
|
||||
switch ($cmd) // we accept only one main parameter
|
||||
{
|
||||
case 'setup':
|
||||
lockSite(true);
|
||||
require_once 'setup/tools/clisetup/firstrun.func.php';
|
||||
$success = firstrun();
|
||||
|
||||
finish($success);
|
||||
case 'sql':
|
||||
case 'build':
|
||||
lockSite(true);
|
||||
$unlock = true;
|
||||
case 'account':
|
||||
case 'dbconfig':
|
||||
case 'siteconfig':
|
||||
require_once 'setup/tools/clisetup/'.$cmd.'.func.php';
|
||||
$cmd();
|
||||
|
||||
finish($unlock);
|
||||
finish();
|
||||
case 'update':
|
||||
lockSite(true);
|
||||
require_once 'setup/tools/clisetup/update.func.php';
|
||||
|
||||
[$s, $b] = update(); // return true if we do not rebuild stuff
|
||||
update($s, $b); // return true if we do not rebuild stuff
|
||||
if (!$s && !$b)
|
||||
finish(true);
|
||||
finish();
|
||||
case 'sync':
|
||||
lockSite(true);
|
||||
require_once 'setup/tools/clisetup/sync.func.php';
|
||||
|
||||
sync($s, $b);
|
||||
finish(true);
|
||||
finish();
|
||||
case 'dbc':
|
||||
foreach (CLISetup::getOpt('dbc') as $n)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user