Slightly cleanup
This commit is contained in:
parent
07798b7366
commit
fa9431c54d
8 changed files with 16 additions and 191 deletions
|
@ -12,7 +12,7 @@ class PruneOrphanedBackupsCommand extends Command
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:maintenance:prune-backups {--since-minutes=30}';
|
||||
protected $signature = 'p:maintenance:prune-backups {--prune-age=}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -21,9 +21,9 @@ class PruneOrphanedBackupsCommand extends Command
|
|||
|
||||
public function handle(BackupRepository $repository)
|
||||
{
|
||||
$since = $this->option('since-minutes');
|
||||
if (!is_digit($since)) {
|
||||
throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.');
|
||||
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
|
||||
if (!$since || !is_digit($since)) {
|
||||
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
|
||||
}
|
||||
|
||||
$query = $repository->getBuilder()
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Migration;
|
||||
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Illuminate\Console\Command;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
|
||||
class CleanOrphanedApiKeysCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:migration:clean-orphaned-keys';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Cleans API keys from the database that are not assigned a specific role.';
|
||||
|
||||
/**
|
||||
* CleanOrphanedApiKeysCommand constructor.
|
||||
*/
|
||||
public function __construct(ApiKeyRepositoryInterface $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all orphaned API keys from the database when upgrading from 0.6 to 0.7.
|
||||
*
|
||||
* @return void|null
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
|
||||
$continue = $this->confirm(
|
||||
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?',
|
||||
false
|
||||
);
|
||||
|
||||
if (!$continue) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->info('Deleting keys...');
|
||||
$this->repository->deleteWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
|
||||
$this->info('Keys were successfully deleted.');
|
||||
}
|
||||
}
|
|
@ -13,12 +13,12 @@ class KeyGenerateCommand extends BaseKeyGenerateCommand
|
|||
public function handle()
|
||||
{
|
||||
if (!empty(config('app.key')) && $this->input->isInteractive()) {
|
||||
$this->output->warning(trans('command/messages.key.warning'));
|
||||
if (!$this->confirm(trans('command/messages.key.confirm'))) {
|
||||
$this->output->warning('It appears you have already configured an application encryption key. Continuing with this process with overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW WHAT YOU ARE DOING.');
|
||||
if (!$this->confirm('I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->confirm(trans('command/messages.key.final_confirm'))) {
|
||||
if (!$this->confirm('Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,10 @@ class SeedCommand extends BaseSeedCommand
|
|||
use RequiresDatabaseMigrations;
|
||||
|
||||
/**
|
||||
* Block someone from running this seed command if they have not completed the migration
|
||||
* process.
|
||||
*
|
||||
* @return int
|
||||
* Block someone from running this seed command if they have not completed
|
||||
* the migration process.
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (!$this->hasCompletedMigrations()) {
|
||||
return $this->showMigrationWarning();
|
||||
|
|
|
@ -10,9 +10,10 @@ class UpCommand extends BaseUpCommand
|
|||
use RequiresDatabaseMigrations;
|
||||
|
||||
/**
|
||||
* @return bool|int
|
||||
* Block someone from running this up command if they have not completed
|
||||
* the migration process.
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (!$this->hasCompletedMigrations()) {
|
||||
return $this->showMigrationWarning();
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Console\Commands\Server;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use Illuminate\Console\Command;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
|
||||
|
||||
class BulkReinstallActionCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
|
||||
*/
|
||||
private $configurationStructureService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
||||
*/
|
||||
private $daemonRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Reinstall a single server, all servers on a node, or all servers on the panel.';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'p:server:reinstall
|
||||
{server? : The ID of the server to reinstall.}
|
||||
{--node= : ID of the node to reinstall all servers on. Ignored if server is passed.}';
|
||||
|
||||
/**
|
||||
* BulkReinstallActionCommand constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
DaemonServerRepository $daemonRepository,
|
||||
ServerConfigurationStructureService $configurationStructureService,
|
||||
ServerRepository $repository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->configurationStructureService = $configurationStructureService;
|
||||
$this->daemonRepository = $daemonRepository;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle command execution.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$servers = $this->getServersToProcess();
|
||||
|
||||
if (!$this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bar = $this->output->createProgressBar(count($servers));
|
||||
|
||||
$servers->each(function ($server) use ($bar) {
|
||||
$bar->clear();
|
||||
|
||||
try {
|
||||
$this->daemonRepository->setServer($server)->reinstall();
|
||||
} catch (RequestException $exception) {
|
||||
$this->output->error(trans('command/messages.server.reinstall.failed', [
|
||||
'name' => $server->name,
|
||||
'id' => $server->id,
|
||||
'node' => $server->node->name,
|
||||
'message' => $exception->getMessage(),
|
||||
]));
|
||||
}
|
||||
|
||||
$bar->advance();
|
||||
$bar->display();
|
||||
});
|
||||
|
||||
$this->line('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the servers to be reinstalled.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
private function getServersToProcess()
|
||||
{
|
||||
Assert::nullOrIntegerish($this->argument('server'), 'Value passed in server argument must be null or an integer, received %s.');
|
||||
Assert::nullOrIntegerish($this->option('node'), 'Value passed in node option must be null or integer, received %s.');
|
||||
|
||||
return $this->repository->getDataForReinstall($this->argument('server'), $this->option('node'));
|
||||
}
|
||||
}
|
|
@ -23,12 +23,9 @@ class Kernel extends ConsoleKernel
|
|||
// Execute scheduled commands for servers every minute, as if there was a normal cron running.
|
||||
$schedule->command('p:schedule:process')->everyMinute()->withoutOverlapping();
|
||||
|
||||
if (config('backups.prune_age')) {
|
||||
// Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted.
|
||||
$pruneAge = config('backups.prune_age', 360); // Defaults to 6 hours (time is in minuteS)
|
||||
if ($pruneAge > 0) {
|
||||
$schedule->command('p:maintenance:prune-backups', [
|
||||
'--since-minutes' => $pruneAge,
|
||||
])->everyThirtyMinutes();
|
||||
$schedule->command('p:maintenance:prune-backups')->everyThirtyMinutes();
|
||||
}
|
||||
|
||||
// Every day cleanup any internal backups of service files.
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'key' => [
|
||||
'warning' => 'It appears you have already configured an application encryption key. Continuing with this process with overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW WHAT YOU ARE DOING.',
|
||||
'confirm' => 'I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.',
|
||||
'final_confirm' => 'Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.',
|
||||
],
|
||||
'location' => [
|
||||
'no_location_found' => 'Could not locate a record matching the provided short code.',
|
||||
'ask_short' => 'Location Short Code',
|
||||
|
|
Loading…
Reference in a new issue