From 9a3578f3ac590b77156bdf969e8a1c9f3aeab8b4 Mon Sep 17 00:00:00 2001 From: Saeed Vaziry Date: Thu, 19 Jun 2025 21:25:25 +0200 Subject: [PATCH] fix docker ssh issue by downgrading phpseclib --- app/Actions/Server/CheckConnection.php | 3 ++- .../Controllers/VitoSettingController.php | 8 ++++-- app/Support/helpers.php | 18 +++++++++++++ composer.json | 2 +- composer.lock | 26 +++++++++---------- docker-compose.yml | 4 +-- docker/docker-compose.yml | 2 +- docker/start.sh | 3 --- 8 files changed, 43 insertions(+), 23 deletions(-) diff --git a/app/Actions/Server/CheckConnection.php b/app/Actions/Server/CheckConnection.php index 00bf9160..9ce69adb 100644 --- a/app/Actions/Server/CheckConnection.php +++ b/app/Actions/Server/CheckConnection.php @@ -20,7 +20,8 @@ public function check(Server $server): Server $server->status = ServerStatus::READY; $server->save(); } - } catch (Throwable) { + } catch (Throwable $e) { + throw $e; $server->status = ServerStatus::DISCONNECTED; $server->save(); Notifier::send($server, new ServerDisconnected($server)); diff --git a/app/Http/Controllers/VitoSettingController.php b/app/Http/Controllers/VitoSettingController.php index 749809b9..fe4c3d8e 100644 --- a/app/Http/Controllers/VitoSettingController.php +++ b/app/Http/Controllers/VitoSettingController.php @@ -114,8 +114,12 @@ public function import(Request $request): RedirectResponse } File::move($extractPath.'/ssh-public.key', storage_path('ssh-public.key')); File::move($extractPath.'/ssh-private.pem', storage_path('ssh-private.pem')); - File::moveDirectory($extractPath.'/key-pairs', storage_path('app/key-pairs'), true); - File::moveDirectory($extractPath.'/server-logs', storage_path('app/server-logs'), true); + if (File::exists($extractPath.'/key-pairs')) { + move_directory($extractPath.'/key-pairs', storage_path('app/key-pairs')); + } + if (File::exists($extractPath.'/server-logs')) { + move_directory($extractPath.'/server-logs', storage_path('app/server-logs')); + } return redirect()->route('vito-settings') ->with('success', 'Settings imported successfully.'); diff --git a/app/Support/helpers.php b/app/Support/helpers.php index 103a9cd8..b7421fc3 100755 --- a/app/Support/helpers.php +++ b/app/Support/helpers.php @@ -277,3 +277,21 @@ function git_path(): ?string return array_find($paths, fn ($path) => is_executable($path)); } + +function move_directory(string $from, string $to): void +{ + // Remove any stale destination + if (File::exists($to)) { + File::deleteDirectory($to); + } + + // Ensure parent of $to exists + File::ensureDirectoryExists(dirname($to)); + + // Copy + delete (works across mounts / volumes) + if (! File::copyDirectory($from, $to)) { + throw new RuntimeException("Could not copy [$from] to [$to]"); + } + + File::deleteDirectory($from); +} diff --git a/composer.json b/composer.json index d43a09c2..c40e0f14 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "laravel/tinker": "^2.8", "mobiledetect/mobiledetectlib": "^4.8", "opcodesio/log-viewer": "^3.17", - "phpseclib/phpseclib": "~3.0", + "phpseclib/phpseclib": "3.0.43", "spatie/laravel-route-attributes": "^1.24", "tightenco/ziggy": "^2.5" }, diff --git a/composer.lock b/composer.lock index 83174893..879cf83f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f9540de1e2dd90b20d9fe05386e75252", + "content-hash": "fc8ee6c13042c4df2cd39b59c4d80ac1", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.345.0", + "version": "3.346.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "61b4675bc02db8d7f3e1ba6931dc827c5ae23aa8" + "reference": "27401e70b1b01114e4e228861933eb7b78630be7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/61b4675bc02db8d7f3e1ba6931dc827c5ae23aa8", - "reference": "61b4675bc02db8d7f3e1ba6931dc827c5ae23aa8", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/27401e70b1b01114e4e228861933eb7b78630be7", + "reference": "27401e70b1b01114e4e228861933eb7b78630be7", "shasum": "" }, "require": { @@ -153,9 +153,9 @@ "support": { "forum": "https://github.com/aws/aws-sdk-php/discussions", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.345.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.346.1" }, - "time": "2025-06-17T18:09:42+00:00" + "time": "2025-06-19T18:05:45+00:00" }, { "name": "bacon/bacon-qr-code", @@ -3566,16 +3566,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.44", + "version": "3.0.43", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "1d0b5e7e1434678411787c5a0535e68907cf82d9" + "reference": "709ec107af3cb2f385b9617be72af8cf62441d02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/1d0b5e7e1434678411787c5a0535e68907cf82d9", - "reference": "1d0b5e7e1434678411787c5a0535e68907cf82d9", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/709ec107af3cb2f385b9617be72af8cf62441d02", + "reference": "709ec107af3cb2f385b9617be72af8cf62441d02", "shasum": "" }, "require": { @@ -3656,7 +3656,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.44" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.43" }, "funding": [ { @@ -3672,7 +3672,7 @@ "type": "tidelift" } ], - "time": "2025-06-15T09:59:26+00:00" + "time": "2024-12-14T21:12:59+00:00" }, { "name": "pragmarx/google2fa", diff --git a/docker-compose.yml b/docker-compose.yml index cbe46aea..a6132450 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: app: build: - context: ./vendor/laravel/sail/runtimes/8.2 + context: ./vendor/laravel/sail/runtimes/8.4 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' @@ -24,7 +24,7 @@ services: depends_on: { } worker: build: - context: ./vendor/laravel/sail/runtimes/8.2 + context: ./vendor/laravel/sail/runtimes/8.4 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 51b3aee8..542b41da 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,7 +12,7 @@ services: extra_hosts: - 'host.docker.internal:host-gateway' ports: - - '${APP_PORT:-80}:80' + - '${APP_PORT:-8000}:80' - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' volumes: - "vito-storage:/var/www/html/storage" diff --git a/docker/start.sh b/docker/start.sh index 9b5df7d5..04f6137f 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -50,9 +50,6 @@ if [ ! -f "$INIT_FLAG" ]; then # create sqlite database touch /var/www/html/storage/database.sqlite - # install default plugins - php /var/www/html/artisan plugins:install https://github.com/vitodeploy/laravel-octane-plugin - # create the flag file to indicate completion of initialization tasks touch "$INIT_FLAG" fi