coolify/app/Actions/Proxy/CheckConfiguration.php

34 lines
973 B
PHP
Raw Normal View History

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