2023-07-28 14:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Proxy;
|
|
|
|
|
2023-09-18 10:18:45 +00:00
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
2023-07-28 14:42:28 +00:00
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
2023-09-18 10:18:45 +00:00
|
|
|
class CheckConfiguration
|
2023-07-28 14:42:28 +00:00
|
|
|
{
|
2023-09-18 10:18:45 +00:00
|
|
|
use AsAction;
|
|
|
|
public function handle(Server $server, bool $reset = false)
|
2023-07-28 14:42:28 +00:00
|
|
|
{
|
2024-03-11 14:08:05 +00:00
|
|
|
$proxyType = $server->proxyType();
|
|
|
|
if ($proxyType === 'NONE') {
|
|
|
|
return 'OK';
|
|
|
|
}
|
|
|
|
$proxy_path = $server->proxyPath();
|
2024-04-16 18:57:54 +00:00
|
|
|
$payload = [
|
|
|
|
"mkdir -p $proxy_path",
|
|
|
|
"cat $proxy_path/docker-compose.yml",
|
|
|
|
];
|
2024-04-16 13:42:38 +00:00
|
|
|
$proxy_configuration = instant_remote_process($payload, $server, false);
|
2023-07-28 14:42:28 +00:00
|
|
|
|
2023-09-18 11:14:05 +00:00
|
|
|
if ($reset || !$proxy_configuration || is_null($proxy_configuration)) {
|
2023-07-28 14:42:28 +00:00
|
|
|
$proxy_configuration = Str::of(generate_default_proxy_configuration($server))->trim()->value;
|
|
|
|
}
|
2023-09-18 11:14:05 +00:00
|
|
|
if (!$proxy_configuration || is_null($proxy_configuration)) {
|
|
|
|
throw new \Exception("Could not generate proxy configuration");
|
|
|
|
}
|
2023-07-28 14:42:28 +00:00
|
|
|
return $proxy_configuration;
|
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
}
|