You've already forked Atomcms-edit
f5666c104d
- Add DiagnosticRunner integration to Commandocentrum for system health display - Refactor EmulatorUpdateService from 2524 lines to 395 lines (facade pattern) - Extract EmulatorStatusService, EmulatorJarService, EmulatorSourceService - Extract EmulatorBuildService, EmulatorSqlService, EmulatorBackupService - Add shared EmulatorConfiguration trait for dependency injection - Preserve backward compatibility on all public methods
127 lines
4.2 KiB
PHP
Executable File
127 lines
4.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Diagnostics\DiagnosticRunner;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
class SystemCheckCommand extends Command
|
|
{
|
|
#[\Override]
|
|
protected $signature = 'atom:check
|
|
{--fix : Start the deep-repair interactive wizard}
|
|
{--interactive : Alias for --fix}
|
|
{--auto : Run all fixes automatically without asking}
|
|
{--platform=auto : Force platform detection}
|
|
{--lang=en : Set language (en, nl)}
|
|
{--skip-migrations : Skip database migrations}
|
|
{--skip-build : Skip frontend asset building}
|
|
{--fix-env : Fix .env file with proper formatting}
|
|
{--setup : Run full setup (migrations, build, storage)}';
|
|
|
|
#[\Override]
|
|
protected $description = 'Ultimate Master Diagnostic & Auto-Repair Tool for Atom CMS';
|
|
|
|
private string $platform = 'auto';
|
|
|
|
private string $webUser = 'www-data';
|
|
|
|
private string $webGroup = 'www-data';
|
|
|
|
public function handle(): int
|
|
{
|
|
$lang = $this->option('lang');
|
|
if (is_string($lang) && in_array($lang, ['en', 'nl'])) {
|
|
App::setLocale($lang);
|
|
}
|
|
|
|
$this->platform = $this->detectPlatform();
|
|
$this->detectWebUserContext();
|
|
|
|
$this->info('╔════════════════════════════════════════════════════════════╗');
|
|
$this->info('║ ATOM CMS MASTER REPAIR COMMAND ║');
|
|
$this->info('╚════════════════════════════════════════════════════════════╝');
|
|
$this->info(' Platform: ' . strtoupper($this->platform));
|
|
$this->info(' User : ' . $this->webUser . ' / ' . $this->webGroup);
|
|
$this->info(' PHP : ' . PHP_VERSION);
|
|
$this->newLine();
|
|
|
|
$runner = new DiagnosticRunner;
|
|
$results = $runner->runAll();
|
|
|
|
foreach ($results as $result) {
|
|
$icon = match ($result->status) {
|
|
'ok' => '✓',
|
|
'warning' => '⚠',
|
|
'error' => '✗',
|
|
default => '?',
|
|
};
|
|
|
|
$this->line(" {$icon} {$result->name}: {$result->message}");
|
|
|
|
if ($result->fix) {
|
|
$this->line(" → {$result->fix}");
|
|
}
|
|
}
|
|
|
|
$this->newLine();
|
|
$this->info('Summary: ' . count($runner->getOk()) . ' OK, ' . count($runner->getWarnings()) . ' warnings, ' . count($runner->getErrors()) . ' errors');
|
|
|
|
if ($this->option('fix') || $this->option('interactive')) {
|
|
return $this->runFixWizard();
|
|
}
|
|
|
|
return $runner->hasErrors() ? 1 : 0;
|
|
}
|
|
|
|
private function runFixWizard(): int
|
|
{
|
|
$this->warn('Interactive fix wizard - use --auto for non-interactive mode');
|
|
|
|
if ($this->confirm('Run all automatic fixes?', false)) {
|
|
$this->call('optimize:clear');
|
|
$this->call('config:cache');
|
|
$this->call('view:cache');
|
|
|
|
$this->info('Fixes completed');
|
|
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
private function detectPlatform(): string
|
|
{
|
|
if (PHP_OS_FAMILY === 'Windows') {
|
|
return 'windows';
|
|
}
|
|
|
|
if (file_exists('/etc/nginx')) {
|
|
return 'linux-nginx';
|
|
}
|
|
|
|
if (file_exists('/etc/apache2') || file_exists('/etc/httpd')) {
|
|
return 'linux-apache';
|
|
}
|
|
|
|
return 'linux';
|
|
}
|
|
|
|
private function detectWebUserContext(): void
|
|
{
|
|
if (function_exists('posix_getpwuid')) {
|
|
$user = posix_getpwuid(posix_geteuid());
|
|
$this->webUser = $user['name'] ?? 'unknown';
|
|
}
|
|
|
|
if (file_exists('/etc/group')) {
|
|
$group = exec('id -gn 2>/dev/null');
|
|
if ($group) {
|
|
$this->webGroup = trim($group);
|
|
}
|
|
}
|
|
}
|
|
}
|