fix(proxy): replace CheckConfiguration with GetProxyConfiguration and SaveConfiguration with SaveProxyConfiguration for improved clarity and consistency in proxy management
This commit is contained in:
32
app/Actions/Proxy/SaveProxyConfiguration.php
Normal file
32
app/Actions/Proxy/SaveProxyConfiguration.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Proxy;
|
||||
|
||||
use App\Models\Server;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SaveProxyConfiguration
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(Server $server, string $configuration): void
|
||||
{
|
||||
$proxy_path = $server->proxyPath();
|
||||
$docker_compose_yml_base64 = base64_encode($configuration);
|
||||
|
||||
// Update the saved settings hash
|
||||
$server->proxy->last_saved_settings = str($docker_compose_yml_base64)->pipe('md5')->value;
|
||||
$server->save();
|
||||
|
||||
// Transfer the configuration file to the server
|
||||
instant_remote_process([
|
||||
"mkdir -p $proxy_path",
|
||||
[
|
||||
'transfer_file' => [
|
||||
'content' => base64_decode($docker_compose_yml_base64),
|
||||
'destination' => "$proxy_path/docker-compose.yml",
|
||||
],
|
||||
],
|
||||
], $server);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user