setup commands wip
This commit is contained in:
37
app/Console/Commands/Setup/GenerateSshKey.php
Normal file
37
app/Console/Commands/Setup/GenerateSshKey.php
Normal 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.');
|
||||
}
|
||||
}
|
||||
17
app/Console/Commands/Setup/Setup.php
Normal file
17
app/Console/Commands/Setup/Setup.php
Normal 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);
|
||||
}
|
||||
}
|
||||
13
app/Enums/ServerStatus.php
Normal file
13
app/Enums/ServerStatus.php
Normal 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';
|
||||
}
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user