Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Services/Servers/StartupCommandService.php
10276 views
1
<?php
2
3
namespace Pterodactyl\Services\Servers;
4
5
use Pterodactyl\Models\Server;
6
7
class StartupCommandService
8
{
9
/**
10
* Generates a startup command for a given server instance.
11
*/
12
public function handle(Server $server, bool $hideAllValues = false): string
13
{
14
$find = ['{{SERVER_MEMORY}}', '{{SERVER_IP}}', '{{SERVER_PORT}}'];
15
$replace = [$server->memory, $server->allocation->ip, $server->allocation->port];
16
17
foreach ($server->variables as $variable) {
18
$find[] = '{{' . $variable->env_variable . '}}';
19
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
20
}
21
22
return str_replace($find, $replace, $server->startup);
23
}
24
}
25
26