36 lines
1006 B
PHP
36 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Actions\Proxy;
|
|
|
|
use App\Models\Server;
|
|
use Illuminate\Support\Str;
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
class CheckConfiguration
|
|
{
|
|
use AsAction;
|
|
|
|
public function handle(Server $server, bool $reset = false)
|
|
{
|
|
$proxyType = $server->proxyType();
|
|
if ($proxyType === 'NONE') {
|
|
return 'OK';
|
|
}
|
|
$proxy_path = $server->proxyPath();
|
|
$payload = [
|
|
"mkdir -p $proxy_path",
|
|
"cat $proxy_path/docker-compose.yml",
|
|
];
|
|
$proxy_configuration = instant_remote_process($payload, $server, false);
|
|
|
|
if ($reset || ! $proxy_configuration || is_null($proxy_configuration)) {
|
|
$proxy_configuration = Str::of(generate_default_proxy_configuration($server))->trim()->value;
|
|
}
|
|
if (! $proxy_configuration || is_null($proxy_configuration)) {
|
|
throw new \Exception('Could not generate proxy configuration');
|
|
}
|
|
|
|
return $proxy_configuration;
|
|
}
|
|
}
|