forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEggInstallController.php
More file actions
70 lines (61 loc) · 2.22 KB
/
EggInstallController.php
File metadata and controls
70 lines (61 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Pterodactyl\Http\Controllers\API\Remote;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Servers\EnvironmentService;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
class EggInstallController extends Controller
{
/**
* @var \Pterodactyl\Services\Servers\EnvironmentService
*/
private $environment;
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
private $repository;
/**
* EggInstallController constructor.
*
* @param \Pterodactyl\Services\Servers\EnvironmentService $environment
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
*/
public function __construct(EnvironmentService $environment, ServerRepositoryInterface $repository)
{
$this->environment = $environment;
$this->repository = $repository;
}
/**
* Handle request to get script and installation information for a server
* that is being created on the node.
*
* @param \Illuminate\Http\Request $request
* @param string $uuid
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function index(Request $request, string $uuid): JsonResponse
{
$node = $request->attributes->get('node');
/** @var \Pterodactyl\Models\Server $server */
$server = $this->repository->findFirstWhere([
['uuid', '=', $uuid],
['node_id', '=', $node->id],
]);
$this->repository->loadEggRelations($server);
$egg = $server->getRelation('egg');
return response()->json([
'scripts' => [
'install' => ! $egg->copy_script_install ? null : str_replace(["\r\n", "\n", "\r"], "\n", $egg->copy_script_install),
'privileged' => $egg->script_is_privileged,
],
'config' => [
'container' => $egg->copy_script_container,
'entry' => $egg->copy_script_entry,
],
'env' => $this->environment->handle($server),
]);
}
}