Deploy Ladill Hosting / deploy (push) Successful in 47s
Treat ns_auto domains as managed DNS, publish subdomain A records via PowerDNS without failing the UX when the local DNS registry is missing, and promote real linked domains over pending-setup.local placeholders. Co-authored-by: Cursor <cursoragent@cursor.com>
70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\HostingAccount;
|
|
use App\Services\Hosting\PlaceholderPrimaryDomainService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class RepairPlaceholderPrimaryDomainsCommand extends Command
|
|
{
|
|
protected $signature = 'hosting:repair-placeholder-primaries
|
|
{--account= : Limit to one hosting account id}
|
|
{--dry-run : Show what would change without writing}';
|
|
|
|
protected $description = 'Promote real linked domains over pending-setup.local / placeholder primaries.';
|
|
|
|
public function handle(PlaceholderPrimaryDomainService $placeholders): int
|
|
{
|
|
$accounts = HostingAccount::query()
|
|
->with(['sites', 'node'])
|
|
->when($this->option('account'), fn ($q, $id) => $q->whereKey($id))
|
|
->orderBy('id')
|
|
->get()
|
|
->filter(fn (HostingAccount $account) => $placeholders->accountNeedsPromotion($account)
|
|
|| $account->sites->contains(
|
|
fn ($site) => PlaceholderPrimaryDomainService::isPlaceholderDomain($site->domain)
|
|
));
|
|
|
|
if ($accounts->isEmpty()) {
|
|
$this->info('No accounts need placeholder primary repair.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$healed = 0;
|
|
|
|
foreach ($accounts as $account) {
|
|
$before = $account->primary_domain ?: '(null)';
|
|
$this->line(sprintf(
|
|
'[%d] %s primary=%s sites=%s',
|
|
$account->id,
|
|
$account->username,
|
|
$before,
|
|
$account->sites->pluck('domain')->implode(', ') ?: '(none)'
|
|
));
|
|
|
|
if ($this->option('dry-run')) {
|
|
continue;
|
|
}
|
|
|
|
if ($placeholders->healAccount($account)) {
|
|
$account->refresh();
|
|
$this->info(sprintf(
|
|
' → healed to primary=%s',
|
|
$account->primary_domain ?: '(null)'
|
|
));
|
|
$healed++;
|
|
}
|
|
}
|
|
|
|
if ($this->option('dry-run')) {
|
|
$this->warn('Dry run: no changes applied.');
|
|
} else {
|
|
$this->info("Healed {$healed} account(s).");
|
|
}
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|