mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 22:03:44 +02:00
Fix inability to create a server
This commit is contained in:
70
app/Http/Controllers/API/Remote/EggInstallController.php
Normal file
70
app/Http/Controllers/API/Remote/EggInstallController.php
Normal file
@@ -0,0 +1,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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Daemon;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
||||
class OptionController extends Controller
|
||||
{
|
||||
public function details(Request $request, $server)
|
||||
{
|
||||
$server = Server::with('allocation', 'option', 'variables.variable')->where('uuid', $server)->firstOrFail();
|
||||
|
||||
$environment = $server->variables->map(function ($item) {
|
||||
return sprintf('%s=%s', $item->variable->env_variable, $item->variable_value);
|
||||
});
|
||||
|
||||
$mergeInto = [
|
||||
'STARTUP=' . $server->startup,
|
||||
'SERVER_MEMORY=' . $server->memory,
|
||||
'SERVER_IP=' . $server->allocation->ip,
|
||||
'SERVER_PORT=' . $server->allocation->port,
|
||||
];
|
||||
|
||||
if ($environment->count() === 0) {
|
||||
$environment = collect($mergeInto);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'scripts' => [
|
||||
'install' => (! $server->option->copy_script_install) ? null : str_replace(["\r\n", "\n", "\r"], "\n", $server->option->copy_script_install),
|
||||
'privileged' => $server->option->script_is_privileged,
|
||||
],
|
||||
'config' => [
|
||||
'container' => $server->option->copy_script_container,
|
||||
'entry' => $server->option->copy_script_entry,
|
||||
],
|
||||
'env' => $environment->toArray(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user