Files
panel/app/Http/Controllers/Api/Remote/EggInstallController.php

49 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2017-11-05 15:36:37 -06:00
<?php
2024-03-12 22:39:16 -04:00
namespace App\Http\Controllers\Api\Remote;
2017-11-05 15:36:37 -06:00
2024-03-16 15:01:21 -04:00
use App\Models\Server;
2017-11-05 15:36:37 -06:00
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
2024-03-12 22:39:16 -04:00
use App\Http\Controllers\Controller;
use App\Services\Servers\EnvironmentService;
2017-11-05 15:36:37 -06:00
class EggInstallController extends Controller
{
/**
* EggInstallController constructor.
*/
2024-03-16 15:01:21 -04:00
public function __construct(private EnvironmentService $environment)
2017-11-05 15:36:37 -06:00
{
}
/**
* Handle request to get script and installation information for a server
* that is being created on the node.
*/
public function index(Request $request, string $uuid): JsonResponse
{
$node = $request->attributes->get('node');
2024-03-16 15:01:21 -04:00
$server = Server::query()
->with('egg.scriptFrom')
->where('uuid', $uuid)
->where('node_id', $node->id)
->firstOrFail();
2017-11-05 15:36:37 -06:00
2024-03-16 15:01:21 -04:00
$egg = $server->egg;
2017-11-05 15:36:37 -06:00
return response()->json([
'scripts' => [
2021-01-23 12:33:34 -08:00
'install' => !$egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install),
2017-11-05 15:36:37 -06:00
'privileged' => $egg->script_is_privileged,
],
'config' => [
'container' => $egg->copy_script_container,
'entry' => $egg->copy_script_entry,
],
'env' => $this->environment->handle($server),
]);
}
}