setup commands wip

This commit is contained in:
2025-03-27 13:28:48 +00:00
parent 2c881c9722
commit 2f5536342b
4 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands\Setup;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process;
class GenerateSshKey extends Command
{
protected $signature = 'setup:generate-ssh-key';
protected $description = 'Generates an SSH key pair for the application.';
public function handle()
{
if (file_exists(storage_path('app/private/ssh/id_ed25519'))) {
$this->components->info('SSH key pair already exists.');
return;
}
$this->components->info('Generating SSH key pair...');
if (!file_exists(storage_path('app/private/ssh'))) {
$this->components->info('ssh directory does not exist. Creating it now...');
mkdir(storage_path('app/private/ssh'), 0755, true);
}
$result = Process::run(['ssh-keygen', '-t', 'ed25519', '-f', storage_path('app/private/ssh/id_ed25519'), '-N', '']);
if (!$result->successful()) {
$this->components->error('Failed to generate SSH key pair.');
$this->line($result->output());
$this->line($result->errorOutput());
return;
}
$this->components->success('SSH key pair generated successfully.');
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Console\Commands\Setup;
use Illuminate\Console\Command;
class Setup extends Command
{
protected $signature = 'setup';
protected $description = 'Initialize the application.';
public function handle()
{
$this->call('migrate');
$this->call(GenerateSshKey::class);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Enums;
enum ServerStatus: string
{
case PENDING = 'pending';
case PROVISIONING = 'provisioning';
case UPDATING = 'updating';
case ACTIVE = 'active';
case DELETING = 'deleting';
case DELETED = 'deleted';
}

View File

@@ -3,6 +3,7 @@
namespace App\Models;
use App\Enums\ServerProvider;
use App\Enums\ServerStatus;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -14,6 +15,7 @@ class Server extends Model
{
return [
'provider' => ServerProvider::class,
'status' => ServerStatus::class,
];
}