Files
ladill-hosting/app/Console/Commands/RepairSslCommand.php
T
isaaccladandCursor e251a4cf60
Deploy Ladill Hosting / deploy (push) Failing after 17s
Initial Ladill Hosting app with Gitea deploy pipeline.
Shared web hosting extracted from the platform monolith, with CI deploy
to /var/www/ladill-hosting matching Bird/Domains/Email.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 16:24:20 +00:00

60 lines
1.7 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\HostedSite;
use App\Services\Hosting\Providers\SharedNodeProvider;
use Illuminate\Console\Command;
class RepairSslCommand extends Command
{
protected $signature = 'hosting:repair-ssl
{domain? : Specific domain to repair (e.g., dailya.cc)}
{--all : Repair SSL for all sites with ssl_enabled=true}';
protected $description = 'Repair SSL configuration for hosted sites by regenerating nginx config with SSL';
public function handle(SharedNodeProvider $nodeProvider): int
{
$domain = $this->argument('domain');
$all = $this->option('all');
if (!$domain && !$all) {
$this->error('Please specify a domain or use --all flag');
return 1;
}
$query = HostedSite::query()->where('ssl_enabled', true);
if ($domain) {
$query->where('domain', $domain);
}
$sites = $query->get();
if ($sites->isEmpty()) {
$this->warn('No sites found matching criteria');
return 0;
}
$this->info("Found {$sites->count()} site(s) to repair");
foreach ($sites as $site) {
$this->line("Processing {$site->domain}...");
try {
// Re-request SSL certificate (certbot will reuse existing cert if valid)
$nodeProvider->requestLetsEncryptCertificate($site);
$this->info(" ✓ SSL repaired for {$site->domain}");
} catch (\Exception $e) {
$this->error(" ✗ Failed for {$site->domain}: " . $e->getMessage());
}
}
$this->newLine();
$this->info('Done!');
return 0;
}
}