pelican-panel-mirror/app/Services/Servers/StartupCommandService.php
Lance Pioch 0179ade557
Add Laravel Data package, also some small fixes (#1065)
* Simplify

* Update these

* Add Laravel Data

* Remove unused imports

* Quick fix

* Fix double array

* Update app/Console/Commands/Egg/CheckEggUpdatesCommand.php
2025-03-08 19:56:06 -05:00

25 lines
780 B
PHP

<?php
namespace App\Services\Servers;
use App\Models\Server;
class StartupCommandService
{
/**
* Generates a startup command for a given server instance.
*/
public function handle(Server $server, bool $hideAllValues = false): string
{
$find = ['{{SERVER_MEMORY}}', '{{SERVER_IP}}', '{{SERVER_PORT}}'];
$replace = [(string) $server->memory, $server->allocation->ip, (string) $server->allocation->port];
foreach ($server->variables as $variable) {
$find[] = '{{' . $variable->env_variable . '}}';
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
}
return str_replace($find, $replace, $server->startup);
}
}