This commit is contained in:
Andras Bacsai
2023-05-25 12:55:34 +02:00
parent acaacec82d
commit 2834d7f342
8 changed files with 17 additions and 58 deletions

View File

@@ -46,20 +46,18 @@ function remote_process(
function save_private_key_for_server(Server $server)
{
$temp_file = "id.root@{$server->ip}";
LocalStorage::ssh_keys()->put($temp_file, $server->privateKey->private_key);
return '/var/www/html/storage/app/private/ssh/keys/' . $temp_file;
Storage::disk('ssh-keys')->put($temp_file, $server->privateKey->private_key);
Storage::disk('ssh-mux')->makeDirectory('.');
return '/var/www/html/storage/app/ssh/keys/' . $temp_file;
}
function generate_ssh_command(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true)
{
LocalStorage::ssh_keys();
LocalStorage::ssh_mux();
$delimiter = 'EOF-COOLIFY-SSH';
$ssh_command = "ssh ";
if ($isMux && config('coolify.mux_enabled')) {
$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/private/ssh/mux/%h_%p_%r ';
$ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/ssh/mux/%h_%p_%r ';
}
$ssh_command .= "-i {$private_key_location} "
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '

View File

@@ -1,38 +0,0 @@
<?php
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Storage;
class LocalStorage extends Facade
{
public static function deployments()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/deployments"),
'visibility' => 'private',
]);
$storage->makeDirectory('.');
return $storage;
}
public static function ssh_keys()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/ssh/keys"),
'visibility' => 'private'
]);
$storage->makeDirectory('.');
return $storage;
}
public static function ssh_mux()
{
$storage = Storage::build([
'driver' => 'local',
'root' => storage_path("app/private/ssh/mux"),
'visibility' => 'private',
]);
$storage->makeDirectory('.');
return $storage;
}
}