Skip to content

Commit

Permalink
Add delete stale configs command "configs:clean"
Browse files Browse the repository at this point in the history
- Update startup message
  • Loading branch information
araszka committed Oct 3, 2022
1 parent 92de075 commit 067ff49
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 17 deletions.
2 changes: 1 addition & 1 deletion core/Classes/ManiaLinkDrag.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __toString()
return '
Void maniaLinkDrag(){
declare Vec2[Text] lastFramePosition for This;
declare handle <=> (Page.MainFrame.GetFirstChild("' . $this->targetId . '") as CMlFrame);
declare handle <=> (Page.MainFrame.GetFirstChild("' . $this->targetId . '") as CMlQuad);
if(!handle.Parent.Visible){
return;
Expand Down
2 changes: 1 addition & 1 deletion core/Classes/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* @method static array getManialinkPageAnswers()
* @method static bool sendOpenLinkToId(int $int, string $string, int $int)
* @method static bool sendOpenLinkToLogin(string $recipient, string $link, int $linkType)
* @method static bool kick(string $login, string $reason)
* @method static bool kick(string $login, string $reason = '')
* @method static bool kickId(int $int, string $string)
* @method static bool ban(string $string, string $string)
* @method static bool banAndBlackList(string $string, string $string, bool $boolean)
Expand Down
54 changes: 54 additions & 0 deletions core/Commands/DeleteUnusedConfigs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace EvoSC\Commands;

use EvoSC\Classes\Log;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DeleteUnusedConfigs extends Command
{
/**
* Command settings
*/
protected function configure()
{
$this->setName('configs:clean')
->setDescription('Removes stale configs that are no more used by EvoSC core.');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
Log::setOutput($output);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$outdated = [
'match-tracker.config.json'
];

$output->writeln("Deleting stale configs...");

foreach ($outdated as $outdatedConfigFile) {
$path = configDir($outdatedConfigFile);

if (file_exists($path)) {
$output->writeln("Deleting config file $outdatedConfigFile.");
unlink($path);
}
}

return 0;
}
}
46 changes: 33 additions & 13 deletions core/Commands/EscRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use EvoSC\Controllers\TemplateController;
use EvoSC\Models\AccessRight;
use EvoSC\Models\Map;
use EvoSC\Models\Player;
use EvoSC\Modules\InputSetup\InputSetup;
use EvoSC\Modules\QuickButtons\QuickButtons;
use Exception;
Expand All @@ -44,7 +43,14 @@

class EscRun extends Command
{
/**
* @var bool
*/
protected static bool $docker = false;

/**
* @var bool
*/
protected bool $keepRunning = true;

/**
Expand All @@ -55,8 +61,7 @@ protected function configure()
$this->setName('run')
->addOption('docker', null, InputOption::VALUE_OPTIONAL, 'Set this flag if EvoSC runs inside docker.', false)
->addOption('setup', null, InputOption::VALUE_OPTIONAL, 'Start the setup on boot.', false)
->addOption('skip_map_check', 'f', InputOption::VALUE_OPTIONAL, 'Start without verifying map integrity.',
false)
->addOption('skip_map_check', 'f', InputOption::VALUE_OPTIONAL, 'Start without verifying map integrity.', false)
->addOption('skip_migrate', 's', InputOption::VALUE_OPTIONAL, 'Skip migrations at start.', false)
->setDescription('Run Evo Server Controller');
}
Expand All @@ -72,9 +77,11 @@ protected function initialize(InputInterface $input, OutputInterface $output)
global $pidPath;
global $serverLogin;

ConfigController::init();
Log::setOutput($output);
$migrate = $this->getApplication()->find('configs:clean');
$migrate->execute($input, $output);

Log::setOutput($output);
ConfigController::init();
ChatCommand::removeAll();
Timer::destroyAll();
QuickButtons::removeAll();
Expand Down Expand Up @@ -169,14 +176,27 @@ protected function execute(InputInterface $input, OutputInterface $output)
global $serverLogin;

$version = getEvoSCVersion();
$motd = " ______ _____ ______
/ ____/ _______ / ___// ____/
/ __/| | / / __ \\__ \/ /
/ /___| |/ / /_/ /__/ / /___
/_____/|___/\____/____/\____/ $version
";

$output->writeln("<fg=cyan;options=bold>$motd</>");
$motd = "
▄▄▄▄▄▄▄▄▄
▄▄█████████████████▄▄
▄█████████████████████▀▀
████████████████████▀▀
▄████████████████▀▀
█████████████▀▀ ▄▄▄
▐████████▀▀ ▄▄▄█████████ <fg=white>EvoSC v$version</>
█████▀ ▄▄▄████████████████▌ <href=https://github.com/EvoTM/EvoSC>https://github.com/EvoTM/EvoSC</>
▀▀ ▄▄▄████████████████████████▌
▄▄████████████████████▀▀▀▀▀▀▀
████████████▀▀▀▀▀▀
▀▀
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄═
▀███████████████████████████████▀
▀███████████████████████████▀
▀▀█████████████████████▀
▀▀▀██████████▀▀▀
";

$output->writeln("<fg=#ff0058;options=bold>$motd</>");

Log::info("Starting...");

Expand Down
2 changes: 0 additions & 2 deletions core/Modules/MatchStats/MatchStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use EvoSC\Classes\DB;
use EvoSC\Classes\Hook;
use EvoSC\Classes\Log;
use EvoSC\Classes\ManiaLinkEvent;
use EvoSC\Classes\Module;
use EvoSC\Models\AccessRight;
use EvoSC\Controllers\MapController;
Expand Down
2 changes: 2 additions & 0 deletions esc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use EvoSC\Commands\LoadAuthorNamesTMX;
use EvoSC\Commands\GetVersion;
use EvoSC\Commands\EscRun;
use EvoSC\Commands\AddAdmin;
use EvoSC\Commands\DeleteUnusedConfigs;
use EvoSC\Commands\FakeLocals;
use EvoSC\Commands\ImportUaseco;
use EvoSC\Commands\ImportPyplanet;
Expand Down Expand Up @@ -56,6 +57,7 @@ $application->add(new FakeLocals());
$application->add(new AddAdmin());
$application->add(new SetupAccessRights());
$application->add(new LoadAuthorNamesTMX());
$application->add(new DeleteUnusedConfigs());
$application->setDefaultCommand("list");

try {
Expand Down

0 comments on commit 067ff49

Please sign in to comment.