Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ composer.lock
it-toolbox-report-*.txt
it-toolbox-report-*.md
it-toolbox-report-*.json
it-toolbox-inventory-*.md
it-toolbox-inventory-*.json
.DS_Store
Thumbs.db
.env
148 changes: 95 additions & 53 deletions README.md

Large diffs are not rendered by default.

154 changes: 98 additions & 56 deletions README.pt-BR.md

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions app/Commands/Maintenance/CleanBrowsersCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

namespace App\Commands\Maintenance;

use App\Commands\Concerns\InteractsWithLocale;
use App\Contracts\SystemDriverInterface;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class CleanBrowsersCommand extends Command
{
use InteractsWithLocale;

/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'maintenance:browsers
{--force : Skip confirmation prompt}
{--lang= : Interface language (en or pt_BR)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Safely clean Chrome, Edge, and Firefox cache directories while preserving passwords, history, and cookies';

/**
* Execute the console command.
*/
public function handle(SystemDriverInterface $driver): int
{
$this->resolveLocale();

info((string) __('messages.maintenance.browsers_section'));

if (! $this->option('force') && ! confirm(
label: (string) __('messages.maintenance.confirm_browsers_clean'),
default: true,
yes: (string) __('messages.common.yes'),
no: (string) __('messages.common.no'),
)) {
warning((string) __('messages.common.cancelled'));

return self::SUCCESS;
}

$result = spin(
callback: fn () => $driver->cleanBrowserCaches(),
message: (string) __('messages.spinners.maintenance_browsers'),
);

return $this->renderActionResult($result);
}
}
83 changes: 83 additions & 0 deletions app/Commands/Maintenance/LargeFilesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

declare(strict_types=1);

namespace App\Commands\Maintenance;

use App\Commands\Concerns\InteractsWithLocale;
use App\Contracts\SystemDriverInterface;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\info;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\table;
use function Laravel\Prompts\warning;

class LargeFilesCommand extends Command
{
use InteractsWithLocale;

/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'maintenance:large-files
{path? : Target directory path to scan (defaults to user Home directory)}
{--limit=15 : Maximum number of largest files to list}
{--lang= : Interface language (en or pt_BR)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Scan a directory recursively to locate the largest files consuming disk space';

/**
* Execute the console command.
*/
public function handle(SystemDriverInterface $driver): int
{
$this->resolveLocale();

info((string) __('messages.maintenance.large_files_section'));

$pathArg = $this->argument('path');
$targetPath = is_string($pathArg) && trim($pathArg) !== '' ? trim($pathArg) : null;
$limit = max(1, (int) $this->option('limit'));

/** @var array<int, array{path: string, size_bytes: float, size_formatted: string, modified_at: string}> $files */
$files = spin(
callback: fn (): array => $driver->findLargeFiles($targetPath, $limit),
message: (string) __('messages.spinners.maintenance_large_files'),
);

if ($files === []) {
warning((string) __('messages.maintenance.no_large_files'));

return self::SUCCESS;
}

table(
headers: [
'#',
(string) __('messages.maintenance.large_files_headers.size'),
(string) __('messages.maintenance.large_files_headers.modified'),
(string) __('messages.maintenance.large_files_headers.path'),
],
rows: array_map(
fn (array $file, int $idx): array => [
(string) ($idx + 1),
$file['size_formatted'],
$file['modified_at'],
$file['path'],
],
$files,
array_keys($files)
),
);

return self::SUCCESS;
}
}
63 changes: 63 additions & 0 deletions app/Commands/Maintenance/OsRepairCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

namespace App\Commands\Maintenance;

use App\Commands\Concerns\InteractsWithLocale;
use App\Contracts\SystemDriverInterface;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class OsRepairCommand extends Command
{
use InteractsWithLocale;

/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'maintenance:repair
{--force : Skip confirmation prompt}
{--lang= : Interface language (en or pt_BR)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Verify and repair OS system files and package integrity (SFC & DISM / dpkg / rpm / pacman)';

/**
* Execute the console command.
*/
public function handle(SystemDriverInterface $driver): int
{
$this->resolveLocale();

info((string) __('messages.maintenance.repair_section'));

if (! $this->option('force') && ! confirm(
label: (string) __('messages.maintenance.confirm_repair'),
default: false,
yes: (string) __('messages.common.yes'),
no: (string) __('messages.common.no'),
)) {
warning((string) __('messages.common.cancelled'));

return self::SUCCESS;
}

$result = spin(
callback: fn () => $driver->repairOsIntegrity(),
message: (string) __('messages.spinners.maintenance_repair'),
);

return $this->renderActionResult($result);
}
}
74 changes: 74 additions & 0 deletions app/Commands/Maintenance/OsUpdatesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

declare(strict_types=1);

namespace App\Commands\Maintenance;

use App\Commands\Concerns\InteractsWithLocale;
use App\Contracts\SystemDriverInterface;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\info;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\table;

class OsUpdatesCommand extends Command
{
use InteractsWithLocale;

/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'maintenance:updates {--lang= : Interface language (en or pt_BR)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Inspect pending OS patches and upgradable system packages';

/**
* Execute the console command.
*/
public function handle(SystemDriverInterface $driver): int
{
$this->resolveLocale();

info((string) __('messages.maintenance.updates_section'));

/** @var array<int, array{package: string, version: string, source: string, status: string}> $updates */
$updates = spin(
callback: fn (): array => $driver->getPendingUpdates(),
message: (string) __('messages.spinners.maintenance_updates'),
);

if ($updates === []) {
info((string) __('messages.maintenance.no_pending_updates'));

return self::SUCCESS;
}

table(
headers: [
(string) __('messages.maintenance.updates_headers.package'),
(string) __('messages.maintenance.updates_headers.version'),
(string) __('messages.maintenance.updates_headers.source'),
(string) __('messages.maintenance.updates_headers.status'),
],
rows: array_map(
fn (array $upd): array => [
$upd['package'] ?? '-',
$upd['version'] ?? '-',
$upd['source'] ?? '-',
$upd['status'] ?? '-',
],
$updates
),
);

return self::SUCCESS;
}
}
75 changes: 75 additions & 0 deletions app/Commands/Maintenance/SchedulerCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

declare(strict_types=1);

namespace App\Commands\Maintenance;

use App\Commands\Concerns\InteractsWithLocale;
use App\Contracts\SystemDriverInterface;
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\info;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\table;
use function Laravel\Prompts\warning;

class SchedulerCommand extends Command
{
use InteractsWithLocale;

/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'maintenance:scheduler {--lang= : Interface language (en or pt_BR)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'List active non-system scheduled tasks, cron jobs, and systemd timers';

/**
* Execute the console command.
*/
public function handle(SystemDriverInterface $driver): int
{
$this->resolveLocale();

info((string) __('messages.maintenance.scheduler_section'));

/** @var array<int, array{name: string, schedule: string, next_run: string, status: string}> $tasks */
$tasks = spin(
callback: fn (): array => $driver->getScheduledTasks(),
message: (string) __('messages.spinners.maintenance_scheduler'),
);

if ($tasks === []) {
warning((string) __('messages.maintenance.no_scheduled_tasks'));

return self::SUCCESS;
}

table(
headers: [
(string) __('messages.maintenance.scheduler_headers.name'),
(string) __('messages.maintenance.scheduler_headers.schedule'),
(string) __('messages.maintenance.scheduler_headers.next_run'),
(string) __('messages.maintenance.scheduler_headers.status'),
],
rows: array_map(
fn (array $task): array => [
$task['name'] ?? '-',
$task['schedule'] ?? '-',
$task['next_run'] ?? '-',
$task['status'] ?? '-',
],
$tasks
),
);

return self::SUCCESS;
}
}
Loading
Loading