diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index e37c4880b..485ef4c20 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -247,6 +247,54 @@ class ServerController extends Controller ]); } + public function getStartup(Request $request, $uuid) + { + $server = Models\Server::getByUUID($uuid); + $this->authorize('view-startup', $server); + $node = Models\Node::find($server->node); + $allocation = Models\Allocation::findOrFail($server->allocation); + + Javascript::put([ + 'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']), + 'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'), + ]); + + $variables = Models\ServiceVariables::select( + 'service_variables.*', + DB::raw('COALESCE(server_variables.variable_value, service_variables.default_value) as a_serverValue') + )->leftJoin('server_variables', 'server_variables.variable_id', '=', 'service_variables.id') + ->where('service_variables.option_id', $server->option) + ->where('server_variables.server_id', $server->id) + ->get(); + + $service = Models\Service::select( + DB::raw('IFNULL(service_options.executable, services.executable) as executable') + )->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id') + ->where('service_options.id', $server->option) + ->where('services.id', $server->service) + ->first(); + + $serverVariables = [ + '{{SERVER_MEMORY}}' => $server->memory, + '{{SERVER_IP}}' => $allocation->ip, + '{{SERVER_PORT}}' => $allocation->port, + ]; + + $processed = str_replace(array_keys($serverVariables), array_values($serverVariables), $server->startup); + foreach ($variables as &$variable) { + $replace = ($variable->user_viewable === 1) ? $variable->a_serverValue : '**'; + $processed = str_replace('{{' . $variable->env_variable . '}}', $replace, $processed); + } + + return view('server.settings.startup', [ + 'server' => $server, + 'node' => Models\Node::find($server->node), + 'variables' => $variables->where('user_viewable', 1), + 'service' => $service, + 'processedStartup' => $processed, + ]); + } + public function getDatabases(Request $request, $uuid) { $server = Models\Server::getByUUID($uuid); diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php index f6fd01ae6..065487896 100644 --- a/app/Http/Routes/ServerRoutes.php +++ b/app/Http/Routes/ServerRoutes.php @@ -65,8 +65,12 @@ class ServerRoutes 'uses' => 'Server\ServerController@postSettingsSFTP', ]); - $router->post('/settings/startup', [ + $router->get('/settings/startup', [ 'as' => 'server.settings.startup', + 'uses' => 'Server\ServerController@getStartup', + ]); + + $router->post('/settings/startup', [ 'uses' => 'Server\ServerController@postSettingsStartup', ]); diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 31e935052..0d2e305a8 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -1,6 +1,7 @@ 'You are not authorized to perform this action.', 'auth_error' => 'There was an error while attempting to login.', 'authentication_required' => 'Authentication is required in order to continue.', 'remember_me' => 'Remember Me', diff --git a/resources/lang/en/server.php b/resources/lang/en/server.php index 34e188e75..8db854001 100644 --- a/resources/lang/en/server.php +++ b/resources/lang/en/server.php @@ -6,4 +6,21 @@ return [ 'header' => 'Server Console', 'header_sub' => 'Control your server in real time.', ], + 'config' => [ + 'startup' => [ + 'header' => 'Start Configuration', + 'header_sub' => 'Control server startup arguments.', + 'command' => 'Startup Command', + 'edit_params' => 'Edit Parameters', + 'update' => 'Update Startup Parameters', + ], + 'sftp' => [ + 'header' => 'SFTP Configuration', + 'header_sub' => 'Account details for SFTP connections.', + 'change_pass' => 'Change SFTP Password', + 'details' => 'SFTP Details', + 'conn_addr' => 'Connection Address', + 'warning' => 'Ensure that your client is set to use SFTP and not FTP or FTPS for connections, there is a difference between the protocols.', + ], + ] ]; diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index 6a97203dd..301e40e4f 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -36,4 +36,7 @@ return [ 'never' => 'never', 'sign_out' => 'Sign out', 'admin_control' => 'Admin Control', + 'required' => 'Required', + 'port' => 'Port', + 'username' => 'Username', ]; diff --git a/resources/themes/pterodactyl/layouts/master.blade.php b/resources/themes/pterodactyl/layouts/master.blade.php index 048cd6db6..0baab1477 100644 --- a/resources/themes/pterodactyl/layouts/master.blade.php +++ b/resources/themes/pterodactyl/layouts/master.blade.php @@ -167,7 +167,7 @@