2017-03-18 17:09:30 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-03-18 17:09:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2017-05-25 01:42:31 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
|
2017-03-18 17:09:30 +00:00
|
|
|
return response()->json([
|
|
|
|
'scripts' => [
|
2017-04-27 20:16:57 +00:00
|
|
|
'install' => (! $server->option->copy_script_install) ? null : str_replace(["\r\n", "\n", "\r"], "\n", $server->option->copy_script_install),
|
2017-03-18 17:09:30 +00:00
|
|
|
'privileged' => $server->option->script_is_privileged,
|
|
|
|
],
|
2017-04-20 22:52:43 +00:00
|
|
|
'config' => [
|
2017-04-27 20:16:57 +00:00
|
|
|
'container' => $server->option->copy_script_container,
|
|
|
|
'entry' => $server->option->copy_script_entry,
|
2017-04-20 22:52:43 +00:00
|
|
|
],
|
2017-05-25 01:42:31 +00:00
|
|
|
'env' => $environment->toArray(),
|
2017-03-18 17:09:30 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|