diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index b8604757f..add1296e6 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -65,14 +65,14 @@ class EmailSettingsCommand extends Command public function handle() { $this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice( - trans('command/messages.environment.mail.ask_driver'), [ + trans('command/messages.environment.mail.ask_driver'), [ 'smtp' => 'SMTP Server', 'mail' => 'PHP\'s Internal Mail Function', 'mailgun' => 'Mailgun Transactional Email', 'mandrill' => 'Mandrill Transactional Email', 'postmark' => 'Postmarkapp Transactional Email', ], $this->config->get('mail.driver', 'smtp') - ); + ); $method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables'; if (method_exists($this, $method)) { diff --git a/app/Contracts/Repository/UserRepositoryInterface.php b/app/Contracts/Repository/UserRepositoryInterface.php index 41649f48b..f5ba47b4b 100644 --- a/app/Contracts/Repository/UserRepositoryInterface.php +++ b/app/Contracts/Repository/UserRepositoryInterface.php @@ -22,4 +22,12 @@ interface UserRepositoryInterface extends RepositoryInterface, SearchableInterfa * @return \Illuminate\Support\Collection */ public function filterUsersByQuery(?string $query): Collection; + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model; } diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php index 2a0689124..d900425d9 100644 --- a/app/Helpers/Utilities.php +++ b/app/Helpers/Utilities.php @@ -6,6 +6,7 @@ use Exception; use Carbon\Carbon; use Cron\CronExpression; use Illuminate\Support\Facades\Log; +use Illuminate\Support\ViewErrorBag; class Utilities { @@ -50,4 +51,15 @@ class Utilities sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek) )->getNextRunDate()); } + + public static function checked($name, $default) + { + $errors = session('errors'); + + if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) { + return old($name) ? 'checked' : ''; + } + + return ($default) ? 'checked' : ''; + } } diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php index 569fec1d7..0aee86806 100644 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -165,6 +165,7 @@ class DatabaseController extends Controller $this->alert->danger( sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) )->flash(); + return $redirect->withInput($request->normalize()); } else { throw $exception; diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 14b3b594f..18e7e3b43 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -177,10 +177,15 @@ class UserController extends Controller * Get a JSON response of users on the system. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection|\Pterodactyl\Models\Model */ public function json(Request $request) { + // Handle single user requests. + if ($request->query('user_id')) { + return $this->repository->filterById($request->input('user_id')); + } + return $this->repository->filterUsersByQuery($request->input('q')); } } diff --git a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php index 340e2541a..7461a950a 100644 --- a/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php +++ b/app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php @@ -86,7 +86,7 @@ class ScheduleTaskController extends ClientApiController } $this->repository->update($task->id, [ - 'action' => $request->input('action'), + 'action' => $request->input('action'), 'payload' => $request->input('payload'), 'time_offset' => $request->input('time_offset'), ]); diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php b/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php index b4599ee0a..8daee56af 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerBackupController.php @@ -3,8 +3,6 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers; use Carbon\Carbon; -use Illuminate\Http\Request; -use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\BackupRepository; diff --git a/app/Repositories/Eloquent/UserRepository.php b/app/Repositories/Eloquent/UserRepository.php index 1ed6c5b74..b6468b5bb 100644 --- a/app/Repositories/Eloquent/UserRepository.php +++ b/app/Repositories/Eloquent/UserRepository.php @@ -54,4 +54,22 @@ class UserRepository extends EloquentRepository implements UserRepositoryInterfa return $item; }); } + + /** + * Returns a user with the given id in a format that can be used for dropdowns. + * + * @param int $id + * @return \Pterodactyl\Models\Model + */ + public function filterById(int $id): \Pterodactyl\Models\Model + { + $this->setColumns([ + 'id', 'email', 'username', 'name_first', 'name_last', + ]); + + $model = $this->getBuilder()->findOrFail($id, $this->getColumns())->getModel(); + $model->md5 = md5(strtolower($model->email)); + + return $model; + } } diff --git a/app/Services/Nodes/NodeCreationService.php b/app/Services/Nodes/NodeCreationService.php index 5090ba23c..261526a91 100644 --- a/app/Services/Nodes/NodeCreationService.php +++ b/app/Services/Nodes/NodeCreationService.php @@ -41,8 +41,8 @@ class NodeCreationService */ public function handle(array $data) { - $data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH); - $data['daemon_token_id'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_ID_LENGTH)); + $data['daemon_token'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)); + $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH); return $this->repository->create($data, true, true); } diff --git a/config/ide-helper.php b/config/ide-helper.php index 9f10873f6..5922f533c 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -168,8 +168,8 @@ return [ | Cast the given "real type" to the given "type". | */ - 'type_overrides' => [ + 'type_overrides' => [ 'integer' => 'int', 'boolean' => 'bool', - ], + ], ]; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 3b2d3e728..93fbac555 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -3,8 +3,8 @@ use Ramsey\Uuid\Uuid; use Cake\Chronos\Chronos; use Illuminate\Support\Str; -use Faker\Generator as Faker; use Pterodactyl\Models\Node; +use Faker\Generator as Faker; use Pterodactyl\Models\ApiKey; /* diff --git a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php index 6bb36813d..dffa7687a 100644 --- a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php +++ b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php @@ -26,8 +26,8 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration DB::table('services')->get(['id', 'author', 'uuid'])->each(function ($service) { DB::table('services')->where('id', $service->id)->update([ - 'author' => ($service->author === 'ptrdctyl-v040-11e6-8b77-86f30ca893d3') ? 'support@pterodactyl.io' : 'unknown@unknown-author.com', - 'uuid' => Uuid::uuid4()->toString(), + 'author' => ($service->author === 'ptrdctyl-v040-11e6-8b77-86f30ca893d3') ? 'support@pterodactyl.io' : 'unknown@unknown-author.com', + 'uuid' => Uuid::uuid4()->toString(), ]); }); diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 7cd0c5fce..621c9526b 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -44,12 +44,12 @@ class MergePermissionsTableIntoSubusers extends Migration { foreach (DB::select('SELECT id, permissions FROM subusers') as $datum) { $values = []; - foreach(json_decode($datum->permissions, true) as $permission) { + foreach (json_decode($datum->permissions, true) as $permission) { $values[] = $datum->id; $values[] = $permission; } - if (!empty($values)) { + if (! empty($values)) { $string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)')); DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values); diff --git a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php b/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php index 0371312de..9b0202cab 100644 --- a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php +++ b/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php @@ -14,7 +14,7 @@ class AddThreadsColumnToServersTable extends Migration public function up() { Schema::table('servers', function (Blueprint $table) { - $table->string('threads')->nullable(); + $table->string('threads')->nullable()->after('cpu'); }); } diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/2020_04_03_230614_create_backups_table.php index 63dad39a0..ead68105c 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/2020_04_03_230614_create_backups_table.php @@ -1,8 +1,8 @@ workshop.lua\r\n\r\ncd \/mnt\/server\/garrysmod\/cfg\r\necho '\r\n\/\/ Please do not set RCon in here, use the startup parameters.\r\n\r\nhostname\t\t\"New Gmod Server\"\r\nsv_password\t\t\"\"\r\nsv_loadingurl \"\"\r\n\r\n\/\/ Steam Server List Settings\r\nsv_region \"255\"\r\nsv_lan \"0\"\r\nsv_max_queries_sec_global \"30000\"\r\nsv_max_queries_window \"45\"\r\nsv_max_queries_sec \"5\"\r\n\r\n\/\/ Server Limits\r\nsbox_maxprops\t\t100\r\nsbox_maxragdolls\t5\r\nsbox_maxnpcs\t\t10\r\nsbox_maxballoons\t10\r\nsbox_maxeffects\t\t10\r\nsbox_maxdynamite\t10\r\nsbox_maxlamps\t\t10\r\nsbox_maxthrusters\t10\r\nsbox_maxwheels\t\t10\r\nsbox_maxhoverballs\t10\r\nsbox_maxvehicles\t20\r\nsbox_maxbuttons\t\t10\r\nsbox_maxsents\t\t20\r\nsbox_maxemitters\t5\r\nsbox_godmode\t\t0\r\nsbox_noclip\t\t 0\r\n\r\n\/\/ Network Settings - Please keep these set to default.\r\n\r\nsv_minrate\t\t75000\r\nsv_maxrate\t\t0\r\ngmod_physiterations\t2\r\nnet_splitpacket_maxrate\t45000\r\ndecalfrequency\t\t12 \r\n\r\n\/\/ Execute Ban Files - Please do not edit\r\nexec banned_ip.cfg \r\nexec banned_user.cfg \r\n\r\n\/\/ Add custom lines under here\r\n' > server.cfg", - "container": "ubuntu:16.04", + "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ubuntu:18.04'\r\napt -y update\r\napt -y --no-install-recommends install curl lib32gcc1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [ \"${STEAM_USER}\" == \"\" ]; then\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} +force_install_dir \/mnt\/server +app_update ${SRCDS_APPID} ${EXTRA_FLAGS} +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so\r\n\r\n# Creating needed default files for the game\r\ncd \/mnt\/server\/garrysmod\/lua\/autorun\/server\r\necho '\r\n-- Docs: https:\/\/wiki.garrysmod.com\/page\/resource\/AddWorkshop\r\n-- Place the ID of the workshop addon you want to be downloaded to people who join your server, not the collection ID\r\n-- Use https:\/\/beta.configcreator.com\/create\/gmod\/resources.lua to easily create a list based on your collection ID\r\n\r\nresource.AddWorkshop( \"\" )\r\n' > workshop.lua\r\n\r\ncd \/mnt\/server\/garrysmod\/cfg\r\necho '\r\n\/\/ Please do not set RCon in here, use the startup parameters.\r\n\r\nhostname\t\t\"New Gmod Server\"\r\nsv_password\t\t\"\"\r\nsv_loadingurl \"\"\r\n\r\n\/\/ Steam Server List Settings\r\nsv_region \"255\"\r\nsv_lan \"0\"\r\nsv_max_queries_sec_global \"30000\"\r\nsv_max_queries_window \"45\"\r\nsv_max_queries_sec \"5\"\r\n\r\n\/\/ Server Limits\r\nsbox_maxprops\t\t100\r\nsbox_maxragdolls\t5\r\nsbox_maxnpcs\t\t10\r\nsbox_maxballoons\t10\r\nsbox_maxeffects\t\t10\r\nsbox_maxdynamite\t10\r\nsbox_maxlamps\t\t10\r\nsbox_maxthrusters\t10\r\nsbox_maxwheels\t\t10\r\nsbox_maxhoverballs\t10\r\nsbox_maxvehicles\t20\r\nsbox_maxbuttons\t\t10\r\nsbox_maxsents\t\t20\r\nsbox_maxemitters\t5\r\nsbox_godmode\t\t0\r\nsbox_noclip\t\t 0\r\n\r\n\/\/ Network Settings - Please keep these set to default.\r\n\r\nsv_minrate\t\t75000\r\nsv_maxrate\t\t0\r\ngmod_physiterations\t2\r\nnet_splitpacket_maxrate\t45000\r\ndecalfrequency\t\t12 \r\n\r\n\/\/ Execute Ban Files - Please do not edit\r\nexec banned_ip.cfg \r\nexec banned_user.cfg \r\n\r\n\/\/ Add custom lines under here\r\n' > server.cfg", + "container": "ubuntu:18.04", "entrypoint": "bash" } }, @@ -87,4 +87,4 @@ "rules": "required|integer|max:100" } ] -} +} \ No newline at end of file diff --git a/database/seeds/eggs/source-engine/egg-insurgency.json b/database/seeds/eggs/source-engine/egg-insurgency.json index 950743fdd..7f0c76be2 100644 --- a/database/seeds/eggs/source-engine/egg-insurgency.json +++ b/database/seeds/eggs/source-engine/egg-insurgency.json @@ -3,7 +3,7 @@ "meta": { "version": "PTDL_v1" }, - "exported_at": "2018-01-21T16:59:48-06:00", + "exported_at": "2019-12-08T10:57:32-05:00", "name": "Insurgency", "author": "support@pterodactyl.io", "description": "Take to the streets for intense close quarters combat, where a team's survival depends upon securing crucial strongholds and destroying enemy supply in this multiplayer and cooperative Source Engine based experience.", @@ -17,8 +17,8 @@ }, "scripts": { "installation": { - "script": "#!\/bin\/bash\n# SRCDS Base Installation Script\n#\n# Server Files: \/mnt\/server\napt -y update\napt -y --no-install-recommends install curl lib32gcc1 ca-certificates\n\ncd \/tmp\ncurl -sSL -o steamcmd.tar.gz http:\/\/media.steampowered.com\/installer\/steamcmd_linux.tar.gz\n\nmkdir -p \/mnt\/server\/steamcmd\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\ncd \/mnt\/server\/steamcmd\n\n# SteamCMD fails otherwise for some reason, even running as root.\n# This is changed at the end of the install process anyways.\nchown -R root:root \/mnt\n\nexport HOME=\/mnt\/server\n.\/steamcmd.sh +login anonymous +force_install_dir \/mnt\/server +app_update ${SRCDS_APPID} +quit\n\nmkdir -p \/mnt\/server\/.steam\/sdk32\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so", - "container": "ubuntu:16.04", + "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ubuntu:18.04'\r\napt -y update\r\napt -y --no-install-recommends install curl lib32gcc1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [ \"${STEAM_USER}\" == \"\" ]; then\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} +force_install_dir \/mnt\/server +app_update ${SRCDS_APPID} ${EXTRA_FLAGS} +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so", + "container": "ubuntu:18.04", "entrypoint": "bash" } }, @@ -51,4 +51,4 @@ "rules": "required|regex:\/^(\\w{1,20})$\/" } ] -} +} \ No newline at end of file diff --git a/database/seeds/eggs/source-engine/egg-team-fortress2.json b/database/seeds/eggs/source-engine/egg-team-fortress2.json index ae443370c..159e7bf9b 100644 --- a/database/seeds/eggs/source-engine/egg-team-fortress2.json +++ b/database/seeds/eggs/source-engine/egg-team-fortress2.json @@ -3,7 +3,7 @@ "meta": { "version": "PTDL_v1" }, - "exported_at": "2018-01-21T16:59:45-06:00", + "exported_at": "2019-12-08T10:58:48-05:00", "name": "Team Fortress 2", "author": "support@pterodactyl.io", "description": "Team Fortress 2 is a team-based first-person shooter multiplayer video game developed and published by Valve Corporation. It is the sequel to the 1996 mod Team Fortress for Quake and its 1999 remake.", @@ -17,8 +17,8 @@ }, "scripts": { "installation": { - "script": "#!\/bin\/bash\n# SRCDS Base Installation Script\n#\n# Server Files: \/mnt\/server\napt -y update\napt -y --no-install-recommends install curl lib32gcc1 ca-certificates\n\ncd \/tmp\ncurl -sSL -o steamcmd.tar.gz http:\/\/media.steampowered.com\/installer\/steamcmd_linux.tar.gz\n\nmkdir -p \/mnt\/server\/steamcmd\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\ncd \/mnt\/server\/steamcmd\n\n# SteamCMD fails otherwise for some reason, even running as root.\n# This is changed at the end of the install process anyways.\nchown -R root:root \/mnt\n\nexport HOME=\/mnt\/server\n.\/steamcmd.sh +login anonymous +force_install_dir \/mnt\/server +app_update ${SRCDS_APPID} +quit\n\nmkdir -p \/mnt\/server\/.steam\/sdk32\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so", - "container": "ubuntu:16.04", + "script": "#!\/bin\/bash\r\n# steamcmd Base Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n# Image to install with is 'ubuntu:18.04'\r\napt -y update\r\napt -y --no-install-recommends install curl lib32gcc1 ca-certificates\r\n\r\n## just in case someone removed the defaults.\r\nif [ \"${STEAM_USER}\" == \"\" ]; then\r\n STEAM_USER=anonymous\r\n STEAM_PASS=\"\"\r\n STEAM_AUTH=\"\"\r\nfi\r\n\r\n## download and install steamcmd\r\ncd \/tmp\r\nmkdir -p \/mnt\/server\/steamcmd\r\ncurl -sSL -o steamcmd.tar.gz https:\/\/steamcdn-a.akamaihd.net\/client\/installer\/steamcmd_linux.tar.gz\r\ntar -xzvf steamcmd.tar.gz -C \/mnt\/server\/steamcmd\r\ncd \/mnt\/server\/steamcmd\r\n\r\n# SteamCMD fails otherwise for some reason, even running as root.\r\n# This is changed at the end of the install process anyways.\r\nchown -R root:root \/mnt\r\nexport HOME=\/mnt\/server\r\n\r\n## install game using steamcmd\r\n.\/steamcmd.sh +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} +force_install_dir \/mnt\/server +app_update ${SRCDS_APPID} ${EXTRA_FLAGS} +quit ## other flags may be needed depending on install. looking at you cs 1.6\r\n\r\n## set up 32 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk32\r\ncp -v linux32\/steamclient.so ..\/.steam\/sdk32\/steamclient.so\r\n\r\n## set up 64 bit libraries\r\nmkdir -p \/mnt\/server\/.steam\/sdk64\r\ncp -v linux64\/steamclient.so ..\/.steam\/sdk64\/steamclient.so", + "container": "ubuntu:18.04", "entrypoint": "bash" } }, diff --git a/public/themes/pterodactyl/js/admin/new-server.js b/public/themes/pterodactyl/js/admin/new-server.js index 5a7393b4f..3e0718a46 100644 --- a/public/themes/pterodactyl/js/admin/new-server.js +++ b/public/themes/pterodactyl/js/admin/new-server.js @@ -21,65 +21,29 @@ $(document).ready(function() { $('#pNestId').select2({ placeholder: 'Select a Nest', }).change(); + $('#pEggId').select2({ placeholder: 'Select a Nest Egg', }); + $('#pPackId').select2({ placeholder: 'Select a Service Pack', }); + $('#pNodeId').select2({ placeholder: 'Select a Node', }).change(); + $('#pAllocation').select2({ placeholder: 'Select a Default Allocation', }); + $('#pAllocationAdditional').select2({ placeholder: 'Select Additional Allocations', }); - - $('#pUserId').select2({ - ajax: { - url: '/admin/users/accounts.json', - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, // search term - page: params.page, - }; - }, - processResults: function (data, params) { - return { results: data }; - }, - cache: true, - }, - escapeMarkup: function (markup) { return markup; }, - minimumInputLength: 2, - templateResult: function (data) { - if (data.loading) return data.text; - - return '
\ - User Image \ - \ - ' + data.name_first + ' ' + data.name_last +' \ - \ - ' + data.email + ' - ' + data.username + ' \ -
'; - }, - templateSelection: function (data) { - return '
\ - \ - User Image \ - \ - \ - ' + data.name_first + ' ' + data.name_last + ' (' + data.email + ') \ - \ -
'; - } - }); }); -var lastActiveBox = null; +let lastActiveBox = null; $(document).on('click', function (event) { if (lastActiveBox !== null) { lastActiveBox.removeClass('box-primary'); @@ -97,10 +61,8 @@ $('#pNodeId').on('change', function () { data: v.allocations, placeholder: 'Select a Default Allocation', }); - $('#pAllocationAdditional').html('').select2({ - data: v.allocations, - placeholder: 'Select Additional Allocations', - }) + + updateAdditionalAllocations(); } }); }); @@ -117,8 +79,8 @@ $('#pNestId').on('change', function (event) { }); $('#pEggId').on('change', function (event) { - var parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null); - var objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null); + let parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null); + let objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null); $('#pDefaultContainer').val(_.get(objectChain, 'docker_image', 'not defined!')); @@ -139,10 +101,13 @@ $('#pEggId').on('change', function (event) { ), }); + const variableIds = {}; $('#appendVariablesTo').html(''); $.each(_.get(objectChain, 'variables', []), function (i, item) { - var isRequired = (item.required === 1) ? 'Required ' : ''; - var dataAppend = ' \ + variableIds[item.env_variable] = 'var_ref_' + item.id; + + let isRequired = (item.required === 1) ? 'Required ' : ''; + let dataAppend = ' \
\ \ \ @@ -153,4 +118,86 @@ $('#pEggId').on('change', function (event) { '; $('#appendVariablesTo').append(dataAppend); }); + + // If you receive a warning on this line, it should be fine to ignore. this function is + // defined in "resources/views/admin/servers/new.blade.php" near the bottom of the file. + serviceVariablesUpdated($('#pEggId').val(), variableIds); }); + +$('#pAllocation').on('change', function () { + updateAdditionalAllocations(); +}); + +function updateAdditionalAllocations() { + let currentAllocation = $('#pAllocation').val(); + let currentNode = $('#pNodeId').val(); + + $.each(Pterodactyl.nodeData, function (i, v) { + if (v.id == currentNode) { + let allocations = []; + + for (let i = 0; i < v.allocations.length; i++) { + const allocation = v.allocations[i]; + + if (allocation.id != currentAllocation) { + allocations.push(allocation); + } + } + + $('#pAllocationAdditional').html('').select2({ + data: allocations, + placeholder: 'Select Additional Allocations', + }); + } + }); +} + +function initUserIdSelect(data) { + $('#pUserId').select2({ + ajax: { + url: '/admin/users/accounts.json', + dataType: 'json', + delay: 250, + + data: function (params) { + return { + q: params.term, // search term + page: params.page, + }; + }, + + processResults: function (data, params) { + return { results: data }; + }, + + cache: true, + }, + + data: data, + escapeMarkup: function (markup) { return markup; }, + minimumInputLength: 2, + + templateResult: function (data) { + if (data.loading) return data.text; + + return '
\ + User Image \ + \ + ' + data.name_first + ' ' + data.name_last +' \ + \ + ' + data.email + ' - ' + data.username + ' \ +
'; + }, + + templateSelection: function (data) { + return '
\ + \ + User Image \ + \ + \ + ' + data.name_first + ' ' + data.name_last + ' (' + data.email + ') \ + \ +
'; + } + }); +} diff --git a/resources/scripts/components/server/ServerConsole.tsx b/resources/scripts/components/server/ServerConsole.tsx index 434589f10..8593216fc 100644 --- a/resources/scripts/components/server/ServerConsole.tsx +++ b/resources/scripts/components/server/ServerConsole.tsx @@ -6,6 +6,7 @@ import { faCircle } from '@fortawesome/free-solid-svg-icons/faCircle'; import classNames from 'classnames'; import { faMemory } from '@fortawesome/free-solid-svg-icons/faMemory'; import { faMicrochip } from '@fortawesome/free-solid-svg-icons/faMicrochip'; +import { faHdd } from '@fortawesome/free-solid-svg-icons/faHdd'; import { bytesToHuman } from '@/helpers'; import SuspenseSpinner from '@/components/elements/SuspenseSpinner'; import TitledGreyBox from '@/components/elements/TitledGreyBox'; @@ -42,6 +43,7 @@ const StopOrKillButton = ({ onPress }: { onPress: (action: PowerAction) => void export default () => { const [ memory, setMemory ] = useState(0); const [ cpu, setCpu ] = useState(0); + const [ disk, setDisk ] = useState(0); const server = ServerContext.useStoreState(state => state.server.data!); const status = ServerContext.useStoreState(state => state.status.value); @@ -58,6 +60,7 @@ export default () => { setMemory(stats.memory_bytes); setCpu(stats.cpu_absolute); + setDisk(stats.disk_bytes); }; const sendPowerCommand = (command: PowerAction) => { @@ -92,6 +95,14 @@ export default () => { />  {status}

+

+ +  {cpu.toFixed(2)} % +

{

-  {cpu.toFixed(2)} % +  {bytesToHuman(disk)} + / {server.limits.disk} MB

diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php index 7aa4477e9..1d61f1a50 100644 --- a/resources/views/admin/servers/new.blade.php +++ b/resources/views/admin/servers/new.blade.php @@ -26,6 +26,7 @@

Core Details

+
@@ -33,20 +34,23 @@

Character limits: a-z A-Z 0-9 _ - . and [Space] (max 200 characters).

+
- +
+
- - + +

A brief description of this server.

+
- +
@@ -55,6 +59,7 @@
+
@@ -62,6 +67,7 @@

Allocation Management

+
@@ -78,22 +84,26 @@ @endforeach +

The node which this server will be deployed to.

+
- +

The main allocation that will be assigned to this server.

+
- +

Additional allocations to assign to this server on creation.

+
@@ -101,18 +111,20 @@

Application Feature Limits

+
- +
- +

The total number of databases a user is allowed to create for this server. Leave blank to allow unlimited.

+
- +
- +

The total number of allocations a user is allowed to create for this server. Leave blank to allow unlimited.

@@ -126,71 +138,90 @@

Resource Management

+
+
- + %
-

If you do not want to limit CPU usage, set the value to 0. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400) there is 400% available. To limit a server to using half of a single core, you would set the value to 50. To allow a server to use up to two physical cores, set the value to 200. BlockIO should be a value between 10 and 1000. Please see this documentation for more information about it.

+ +

If you do not want to limit CPU usage, set the value to 0. To determine a value, take the number of physical cores and multiply it by 100. For example, on a quad core system (4 * 100 = 400) there is 400% available. To limit a server to using half of a single core, you would set the value to 50. To allow a server to use up to two physical cores, set the value to 200. BlockIO should be a value between 10 and 1000. Please see this documentation for more information about it.

+
+
- +
+

Advanced: Enter the specific CPU cores that this process can run on, or leave blank to allow all cores. This can be a single number, or a comma seperated list. Example: 0, 0-1,3, or 0,1,3,4.

+
+
- + MB
+
+
- + MB
+ +
+
- - MB + + MB
+
+
- +
-

Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10 and 1000.

+ +

Advanced: The IO performance of this server relative to other running containers on the system. Value should be between 10 and 1000.

+

Nest Configuration

+
- @foreach($nests as $nest) @endforeach +

Select the Nest that this server will be grouped under.

+
- +

Select the Egg that will define how this server should operate.

+
- +

Select a data pack to be automatically installed on this server when first created.

+
- +
+

If the selected Egg has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.

+

Docker Configuration

+
@@ -236,23 +274,28 @@
+

Startup Configuration

+
- +

The following data substitutes are available for the startup command: @{{SERVER_MEMORY}}, @{{SERVER_IP}}, and @{{SERVER_PORT}}. They will be replaced with the allocated memory, server IP, and server port respectively.

+

Service Variables

+
+ @section('footer-scripts') - {!! Theme::js('js/keyboard.polyfill.js') !!} + {!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!} @@ -185,7 +185,7 @@ {!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js?t={cache-version}') !!} {!! Theme::js('vendor/select2/select2.full.min.js?t={cache-version}') !!} {!! Theme::js('js/admin/functions.js?t={cache-version}') !!} - {!! Theme::js('js/autocomplete.js?t={cache-version}') !!} + @if(Auth::user()->root_admin) {!! Theme::js('vendor/particlesjs/particles.min.js?t={cache-version}') !!} {!! Theme::js('vendor/jquery/jquery.min.js?t={cache-version}') !!} @@ -284,7 +284,7 @@ {!! Theme::js('vendor/adminlte/app.min.js?t={cache-version}') !!} {!! Theme::js('vendor/socketio/socket.io.v203.min.js?t={cache-version}') !!} {!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js?t={cache-version}') !!} - {!! Theme::js('js/autocomplete.js?t={cache-version}') !!} + @if(Auth::user()->root_admin)