Files
ladill-servers/app/Console/Commands/ReprovisionHostingAccount.php
isaaccladandCursor b6c8ac343f Extract Ladill Servers as standalone app at servers.ladill.com.
VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 19:18:30 +00:00

63 lines
2.0 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\HostingAccount;
use App\Services\Hosting\Providers\SharedNodeProvider;
use Illuminate\Console\Command;
class ReprovisionHostingAccount extends Command
{
protected $signature = 'hosting:reprovision {account_id}';
protected $description = 'Re-provision a hosting account on its node (creates user, directories, etc.)';
public function handle(SharedNodeProvider $provider): int
{
$account = HostingAccount::with('node')->find($this->argument('account_id'));
if (!$account) {
$this->error('Account not found');
return 1;
}
if (!$account->node) {
$this->error('Account has no hosting node assigned');
return 1;
}
$this->info("Re-provisioning account: {$account->username} on node {$account->node->hostname}");
try {
$result = $provider->createAccount($account);
$account->update([
'status' => HostingAccount::STATUS_ACTIVE,
'home_directory' => $result['home_directory'],
'provisioned_at' => now(),
]);
$this->info("Account provisioned successfully!");
$this->info("Username: {$result['username']}");
$this->info("Password: {$result['password']}");
$this->info("Home Directory: {$result['home_directory']}");
// Also provision any existing sites
foreach ($account->sites as $site) {
$this->info("Provisioning site: {$site->domain}");
try {
$provider->addSite($site);
$site->update(['status' => 'active']);
$this->info(" - Site provisioned");
} catch (\Exception $e) {
$this->warn(" - Failed: {$e->getMessage()}");
}
}
return 0;
} catch (\Exception $e) {
$this->error("Failed to provision: {$e->getMessage()}");
return 1;
}
}
}