From 70ecb92e82c69aecbe912ef48d1aa7e3dea83884 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 25 Oct 2023 09:41:41 +0200 Subject: [PATCH] cleanup ssh dir on start --- app/Console/Commands/Init.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 6abac7029..31d7639be 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -10,6 +10,7 @@ use App\Models\StandaloneMongodb; use App\Models\StandalonePostgresql; use App\Models\StandaloneRedis; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Storage; class Init extends Command { @@ -21,8 +22,23 @@ class Init extends Command ray()->clearAll(); $this->cleanup_in_progress_application_deployments(); $this->cleanup_stucked_resources(); + $this->cleanup_ssh(); } + private function cleanup_ssh() { + try { + $files = Storage::allFiles('ssh/keys'); + foreach ($files as $file) { + Storage::delete($file); + } + $files = Storage::allFiles('ssh/mux'); + foreach ($files as $file) { + Storage::delete($file); + } + } catch (\Throwable $e) { + echo "Error: {$e->getMessage()}\n"; + } + } private function cleanup_in_progress_application_deployments() { // Cleanup any failed deployments