2023-07-28 14:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Proxy;
|
|
|
|
|
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
class SaveConfigurationSync
|
|
|
|
{
|
2023-09-14 15:10:37 +00:00
|
|
|
public function __invoke(Server $server)
|
2023-07-28 14:42:28 +00:00
|
|
|
{
|
2023-09-01 08:02:24 +00:00
|
|
|
try {
|
2023-09-14 15:10:37 +00:00
|
|
|
$proxy_settings = resolve(CheckConfigurationSync::class)($server, true);
|
2023-09-01 08:02:24 +00:00
|
|
|
$proxy_path = get_proxy_path();
|
2023-09-14 15:10:37 +00:00
|
|
|
$docker_compose_yml_base64 = base64_encode($proxy_settings);
|
2023-07-28 14:42:28 +00:00
|
|
|
|
2023-09-01 08:02:24 +00:00
|
|
|
$server->proxy->last_saved_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
|
|
|
|
$server->save();
|
|
|
|
|
|
|
|
instant_remote_process([
|
|
|
|
"mkdir -p $proxy_path",
|
|
|
|
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
|
|
|
|
], $server);
|
2023-09-11 15:36:30 +00:00
|
|
|
} catch (\Throwable $e) {
|
|
|
|
ray($e);
|
2023-09-01 08:02:24 +00:00
|
|
|
}
|
2023-07-28 14:42:28 +00:00
|
|
|
|
|
|
|
}
|
2023-08-11 18:48:52 +00:00
|
|
|
}
|