diff --git a/app/Contracts/Repository/NestRepositoryInterface.php b/app/Contracts/Repository/NestRepositoryInterface.php index b06f9730b..e457262f6 100644 --- a/app/Contracts/Repository/NestRepositoryInterface.php +++ b/app/Contracts/Repository/NestRepositoryInterface.php @@ -14,7 +14,7 @@ use Pterodactyl\Models\Nest; interface NestRepositoryInterface extends RepositoryInterface { /** - * Return a nest or all nests with their associated eggs, variables, and packs. + * Return a nest or all nests with their associated eggs and variables. * * @param int $id * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest @@ -24,7 +24,7 @@ interface NestRepositoryInterface extends RepositoryInterface public function getWithEggs(int $id = null); /** - * Return a nest or all nests and the count of eggs, packs, and servers for that nest. + * Return a nest or all nests and the count of eggs and servers for that nest. * * @param int|null $id * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection diff --git a/app/Contracts/Repository/PackRepositoryInterface.php b/app/Contracts/Repository/PackRepositoryInterface.php deleted file mode 100644 index a0e9f7a5d..000000000 --- a/app/Contracts/Repository/PackRepositoryInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Exceptions\Service\Pack; - -use Pterodactyl\Exceptions\DisplayException; - -class InvalidFileMimeTypeException extends DisplayException -{ -} diff --git a/app/Exceptions/Service/Pack/InvalidPackArchiveFormatException.php b/app/Exceptions/Service/Pack/InvalidPackArchiveFormatException.php deleted file mode 100644 index 5e216fed4..000000000 --- a/app/Exceptions/Service/Pack/InvalidPackArchiveFormatException.php +++ /dev/null @@ -1,16 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Exceptions\Service\Pack; - -use Pterodactyl\Exceptions\DisplayException; - -class InvalidPackArchiveFormatException extends DisplayException -{ -} diff --git a/app/Exceptions/Service/Pack/UnreadableZipArchiveException.php b/app/Exceptions/Service/Pack/UnreadableZipArchiveException.php deleted file mode 100644 index f1608936c..000000000 --- a/app/Exceptions/Service/Pack/UnreadableZipArchiveException.php +++ /dev/null @@ -1,16 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Exceptions\Service\Pack; - -use Pterodactyl\Exceptions\DisplayException; - -class UnreadableZipArchiveException extends DisplayException -{ -} diff --git a/app/Exceptions/Service/Pack/ZipArchiveCreationException.php b/app/Exceptions/Service/Pack/ZipArchiveCreationException.php deleted file mode 100644 index 62b11136d..000000000 --- a/app/Exceptions/Service/Pack/ZipArchiveCreationException.php +++ /dev/null @@ -1,16 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Exceptions\Service\Pack; - -use Exception; - -class ZipArchiveCreationException extends Exception -{ -} diff --git a/app/Exceptions/Service/Pack/ZipExtractionException.php b/app/Exceptions/Service/Pack/ZipExtractionException.php deleted file mode 100644 index 8a6a82c20..000000000 --- a/app/Exceptions/Service/Pack/ZipExtractionException.php +++ /dev/null @@ -1,16 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Exceptions\Service\Pack; - -use Pterodactyl\Exceptions\DisplayException; - -class ZipExtractionException extends DisplayException -{ -} diff --git a/app/Http/Controllers/Admin/PackController.php b/app/Http/Controllers/Admin/PackController.php deleted file mode 100644 index 454d6a55d..000000000 --- a/app/Http/Controllers/Admin/PackController.php +++ /dev/null @@ -1,251 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Http\Controllers\Admin; - -use Illuminate\Http\Request; -use Pterodactyl\Models\Pack; -use Prologue\Alerts\AlertsMessageBag; -use Spatie\QueryBuilder\QueryBuilder; -use Pterodactyl\Http\Controllers\Controller; -use Pterodactyl\Services\Packs\ExportPackService; -use Pterodactyl\Services\Packs\PackUpdateService; -use Pterodactyl\Services\Packs\PackCreationService; -use Pterodactyl\Services\Packs\PackDeletionService; -use Pterodactyl\Http\Requests\Admin\PackFormRequest; -use Pterodactyl\Services\Packs\TemplateUploadService; -use Pterodactyl\Contracts\Repository\NestRepositoryInterface; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; -use Illuminate\Contracts\Config\Repository as ConfigRepository; - -class PackController extends Controller -{ - /** - * @var \Prologue\Alerts\AlertsMessageBag - */ - protected $alert; - - /** - * @var \Illuminate\Contracts\Config\Repository - */ - protected $config; - - /** - * @var \Pterodactyl\Services\Packs\PackCreationService - */ - protected $creationService; - - /** - * @var \Pterodactyl\Services\Packs\PackDeletionService - */ - protected $deletionService; - - /** - * @var \Pterodactyl\Services\Packs\ExportPackService - */ - protected $exportService; - - /** - * @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface - */ - protected $repository; - - /** - * @var \Pterodactyl\Services\Packs\PackUpdateService - */ - protected $updateService; - - /** - * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface - */ - protected $serviceRepository; - - /** - * @var \Pterodactyl\Services\Packs\TemplateUploadService - */ - protected $templateUploadService; - - /** - * PackController constructor. - * - * @param \Prologue\Alerts\AlertsMessageBag $alert - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Services\Packs\ExportPackService $exportService - * @param \Pterodactyl\Services\Packs\PackCreationService $creationService - * @param \Pterodactyl\Services\Packs\PackDeletionService $deletionService - * @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository - * @param \Pterodactyl\Services\Packs\PackUpdateService $updateService - * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository - * @param \Pterodactyl\Services\Packs\TemplateUploadService $templateUploadService - */ - public function __construct( - AlertsMessageBag $alert, - ConfigRepository $config, - ExportPackService $exportService, - PackCreationService $creationService, - PackDeletionService $deletionService, - PackRepositoryInterface $repository, - PackUpdateService $updateService, - NestRepositoryInterface $serviceRepository, - TemplateUploadService $templateUploadService - ) { - $this->alert = $alert; - $this->config = $config; - $this->creationService = $creationService; - $this->deletionService = $deletionService; - $this->exportService = $exportService; - $this->repository = $repository; - $this->updateService = $updateService; - $this->serviceRepository = $serviceRepository; - $this->templateUploadService = $templateUploadService; - } - - /** - * Display listing of all packs on the system. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\View\View - */ - public function index(Request $request) - { - return view('admin.packs.index', [ - 'packs' => $this->repository->paginateWithEggAndServerCount(), - ]); - } - - /** - * Display new pack creation form. - * - * @return \Illuminate\View\View - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function create() - { - return view('admin.packs.new', [ - 'nests' => $this->serviceRepository->getWithEggs(), - ]); - } - - /** - * Display new pack creation modal for use with template upload. - * - * @return \Illuminate\View\View - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function newTemplate() - { - return view('admin.packs.modal', [ - 'nests' => $this->serviceRepository->getWithEggs(), - ]); - } - - /** - * Handle create pack request and route user to location. - * - * @param \Pterodactyl\Http\Requests\Admin\PackFormRequest $request - * @return \Illuminate\View\View - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException - * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException - * @throws \Pterodactyl\Exceptions\Service\Pack\ZipExtractionException - */ - public function store(PackFormRequest $request) - { - if ($request->filled('from_template')) { - $pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload')); - } else { - $pack = $this->creationService->handle($request->normalize(), $request->file('file_upload')); - } - - $this->alert->success(trans('admin/pack.notices.pack_created'))->flash(); - - return redirect()->route('admin.packs.view', $pack->id); - } - - /** - * Display pack view template to user. - * - * @param \Pterodactyl\Models\Pack $pack - * @return \Illuminate\View\View - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function view(Pack $pack) - { - return view('admin.packs.view', [ - 'pack' => $this->repository->loadServerData($pack), - 'nests' => $this->serviceRepository->getWithEggs(), - ]); - } - - /** - * Handle updating or deleting pack information. - * - * @param \Pterodactyl\Http\Requests\Admin\PackFormRequest $request - * @param \Pterodactyl\Models\Pack $pack - * @return \Illuminate\Http\RedirectResponse - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - */ - public function update(PackFormRequest $request, Pack $pack) - { - $this->updateService->handle($pack, $request->normalize()); - $this->alert->success(trans('admin/pack.notices.pack_updated'))->flash(); - - return redirect()->route('admin.packs.view', $pack->id); - } - - /** - * Delete a pack if no servers are attached to it currently. - * - * @param \Pterodactyl\Models\Pack $pack - * @return \Illuminate\Http\RedirectResponse - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - */ - public function destroy(Pack $pack) - { - $this->deletionService->handle($pack->id); - $this->alert->success(trans('admin/pack.notices.pack_deleted', [ - 'name' => $pack->name, - ]))->flash(); - - return redirect()->route('admin.packs'); - } - - /** - * Creates an archive of the pack and downloads it to the browser. - * - * @param \Pterodactyl\Models\Pack $pack - * @param bool|string $files - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Pack\ZipArchiveCreationException - */ - public function export(Pack $pack, $files = false) - { - $filename = $this->exportService->handle($pack, is_string($files)); - - if (is_string($files)) { - return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true); - } - - return response()->download($filename, 'pack-' . $pack->name . '.json', [ - 'Content-Type' => 'application/json', - ])->deleteFileAfterSend(true); - } -} diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index f914013bb..94df5dc21 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -240,7 +240,7 @@ class ServersController extends Controller } /** - * Reinstalls the server with the currently assigned pack and service. + * Reinstalls the server with the currently assigned service. * * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\RedirectResponse diff --git a/app/Http/Requests/Admin/PackFormRequest.php b/app/Http/Requests/Admin/PackFormRequest.php deleted file mode 100644 index 68b3a8d36..000000000 --- a/app/Http/Requests/Admin/PackFormRequest.php +++ /dev/null @@ -1,49 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Http\Requests\Admin; - -use Pterodactyl\Models\Pack; -use Pterodactyl\Services\Packs\PackCreationService; - -class PackFormRequest extends AdminFormRequest -{ - /** - * @return array - */ - public function rules() - { - if ($this->method() === 'PATCH') { - return Pack::getRulesForUpdate($this->route()->parameter('pack')->id); - } - - return Pack::getRules(); - } - - /** - * Run validation after the rules above have been applied. - * - * @param \Illuminate\Validation\Validator $validator - */ - public function withValidator($validator) - { - if ($this->method() !== 'POST') { - return; - } - - $validator->after(function ($validator) { - $mimetypes = implode(',', PackCreationService::VALID_UPLOAD_TYPES); - - /* @var $validator \Illuminate\Validation\Validator */ - $validator->sometimes('file_upload', 'sometimes|required|file|mimetypes:' . $mimetypes, function () { - return true; - }); - }); - } -} diff --git a/app/Http/Requests/Admin/ServerFormRequest.php b/app/Http/Requests/Admin/ServerFormRequest.php index 96e0eebe4..6f930615c 100644 --- a/app/Http/Requests/Admin/ServerFormRequest.php +++ b/app/Http/Requests/Admin/ServerFormRequest.php @@ -62,15 +62,6 @@ class ServerFormRequest extends AdminFormRequest ], function ($input) { return ! ($input->auto_deploy); }); - - $validator->sometimes('pack_id', [ - Rule::exists('packs', 'id')->where(function ($query) { - $query->where('selectable', 1); - $query->where('egg_id', $this->input('egg_id')); - }), - ], function ($input) { - return $input->pack_id !== 0 && $input->pack_id !== null; - }); }); } } diff --git a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php index 32f68bd23..15780d695 100644 --- a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php +++ b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php @@ -36,7 +36,6 @@ class StoreServerRequest extends ApplicationApiRequest 'description' => array_merge(['nullable'], $rules['description']), 'user' => $rules['owner_id'], 'egg' => $rules['egg_id'], - 'pack' => $rules['pack_id'], 'docker_image' => $rules['image'], 'startup' => $rules['startup'], 'environment' => 'present|array', @@ -88,7 +87,6 @@ class StoreServerRequest extends ApplicationApiRequest 'description' => array_get($data, 'description'), 'owner_id' => array_get($data, 'user'), 'egg_id' => array_get($data, 'egg'), - 'pack_id' => array_get($data, 'pack'), 'image' => array_get($data, 'docker_image'), 'startup' => array_get($data, 'startup'), 'environment' => array_get($data, 'environment'), diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php index 532ae1c35..fc367cdaf 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php @@ -31,7 +31,6 @@ class UpdateServerStartupRequest extends ApplicationApiRequest 'startup' => $data['startup'], 'environment' => 'present|array', 'egg' => $data['egg_id'], - 'pack' => $data['pack_id'], 'image' => $data['image'], 'skip_scripts' => 'present|boolean', ]; @@ -48,7 +47,6 @@ class UpdateServerStartupRequest extends ApplicationApiRequest return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([ 'egg_id' => array_get($data, 'egg'), - 'pack_id' => array_get($data, 'pack'), 'docker_image' => array_get($data, 'image'), ])->toArray(); } diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php index 59517621a..072a74f9b 100644 --- a/app/Models/ApiKey.php +++ b/app/Models/ApiKey.php @@ -63,7 +63,6 @@ class ApiKey extends Model 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'int', 'r_' . AdminAcl::RESOURCE_NESTS => 'int', 'r_' . AdminAcl::RESOURCE_NODES => 'int', - 'r_' . AdminAcl::RESOURCE_PACKS => 'int', 'r_' . AdminAcl::RESOURCE_SERVERS => 'int', ]; @@ -110,7 +109,6 @@ class ApiKey extends Model 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_NESTS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_NODES => 'integer|min:0|max:3', - 'r_' . AdminAcl::RESOURCE_PACKS => 'integer|min:0|max:3', 'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3', ]; diff --git a/app/Models/Egg.php b/app/Models/Egg.php index 2c53c8536..143fe95a8 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -35,7 +35,6 @@ namespace Pterodactyl\Models; * @property \Pterodactyl\Models\Nest $nest * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\EggVariable[] $variables - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Pack[] $packs * @property \Pterodactyl\Models\Egg|null $scriptFrom * @property \Pterodactyl\Models\Egg|null $configFrom */ @@ -247,16 +246,6 @@ class Egg extends Model return $this->hasMany(EggVariable::class, 'egg_id'); } - /** - * Gets all packs associated with this egg. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function packs() - { - return $this->hasMany(Pack::class, 'egg_id'); - } - /** * Get the parent egg from which to copy scripts. * diff --git a/app/Models/Nest.php b/app/Models/Nest.php index 8cce56f3a..5def1c833 100644 --- a/app/Models/Nest.php +++ b/app/Models/Nest.php @@ -13,7 +13,6 @@ namespace Pterodactyl\Models; * * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Server[] $servers * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Egg[] $eggs - * @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Pack[] $packs */ class Nest extends Model { @@ -59,16 +58,6 @@ class Nest extends Model return $this->hasMany(Egg::class); } - /** - * Returns all of the packs associated with a nest, regardless of the egg. - * - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough - */ - public function packs() - { - return $this->hasManyThrough(Pack::class, Egg::class, 'nest_id', 'egg_id'); - } - /** * Gets all servers associated with this nest. * diff --git a/app/Models/Pack.php b/app/Models/Pack.php deleted file mode 100644 index 3846d74eb..000000000 --- a/app/Models/Pack.php +++ /dev/null @@ -1,106 +0,0 @@ - 'required|string', - 'version' => 'required|string', - 'description' => 'sometimes|nullable|string', - 'selectable' => 'sometimes|required|boolean', - 'visible' => 'sometimes|required|boolean', - 'locked' => 'sometimes|required|boolean', - 'egg_id' => 'required|exists:eggs,id', - ]; - - /** - * Cast values to correct type. - * - * @var array - */ - protected $casts = [ - 'egg_id' => 'integer', - 'selectable' => 'boolean', - 'visible' => 'boolean', - 'locked' => 'boolean', - ]; - - /** - * Parameters for search querying. - * - * @var array - */ - protected $searchableColumns = [ - 'name' => 10, - 'uuid' => 8, - 'egg.name' => 6, - 'egg.docker_image' => 5, - 'version' => 2, - ]; - - /** - * Gets egg associated with a service pack. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function egg() - { - return $this->belongsTo(Egg::class); - } - - /** - * Gets servers associated with a pack. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function servers() - { - return $this->hasMany(Server::class); - } -} diff --git a/app/Models/Server.php b/app/Models/Server.php index 225a04be1..4684ece65 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -28,7 +28,6 @@ use Znck\Eloquent\Traits\BelongsToThrough; * @property int $allocation_id * @property int $nest_id * @property int $egg_id - * @property int|null $pack_id * @property string $startup * @property string $image * @property int $installed @@ -42,7 +41,6 @@ use Znck\Eloquent\Traits\BelongsToThrough; * @property \Pterodactyl\Models\Subuser[]|\Illuminate\Database\Eloquent\Collection $subusers * @property \Pterodactyl\Models\Allocation $allocation * @property \Pterodactyl\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations - * @property \Pterodactyl\Models\Pack|null $pack * @property \Pterodactyl\Models\Node $node * @property \Pterodactyl\Models\Nest $nest * @property \Pterodactyl\Models\Egg $egg @@ -122,7 +120,6 @@ class Server extends Model 'allocation_id' => 'required|bail|unique:servers|exists:allocations,id', 'nest_id' => 'required|exists:nests,id', 'egg_id' => 'required|exists:eggs,id', - 'pack_id' => 'sometimes|nullable|numeric|min:0', 'startup' => 'required|string', 'skip_scripts' => 'sometimes|boolean', 'image' => 'required|string|max:255', @@ -151,7 +148,6 @@ class Server extends Model 'allocation_id' => 'integer', 'nest_id' => 'integer', 'egg_id' => 'integer', - 'pack_id' => 'integer', 'installed' => 'integer', 'database_limit' => 'integer', 'allocation_limit' => 'integer', @@ -171,7 +167,6 @@ class Server extends Model 'user.email' => 40, 'user.username' => 30, 'node.name' => 10, - 'pack.name' => 10, ]; /** @@ -234,16 +229,6 @@ class Server extends Model return $this->hasMany(Allocation::class, 'server_id'); } - /** - * Gets information for the pack associated with this server. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function pack() - { - return $this->belongsTo(Pack::class); - } - /** * Gets information for the nest associated with this server. * diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index ef8e6cb0a..4f1797edc 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; use Pterodactyl\Repositories\Eloquent\EggRepository; use Pterodactyl\Repositories\Eloquent\NestRepository; use Pterodactyl\Repositories\Eloquent\NodeRepository; -use Pterodactyl\Repositories\Eloquent\PackRepository; use Pterodactyl\Repositories\Eloquent\TaskRepository; use Pterodactyl\Repositories\Eloquent\UserRepository; use Pterodactyl\Repositories\Eloquent\ApiKeyRepository; @@ -23,7 +22,6 @@ use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Repositories\Eloquent\EggVariableRepository; use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; use Pterodactyl\Contracts\Repository\TaskRepositoryInterface; use Pterodactyl\Contracts\Repository\UserRepositoryInterface; use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository; @@ -60,7 +58,6 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); $this->app->bind(NestRepositoryInterface::class, NestRepository::class); $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); - $this->app->bind(PackRepositoryInterface::class, PackRepository::class); $this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class); $this->app->bind(ServerRepositoryInterface::class, ServerRepository::class); $this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class); diff --git a/app/Repositories/Eloquent/NestRepository.php b/app/Repositories/Eloquent/NestRepository.php index 9c0fcf73c..96b3df36f 100644 --- a/app/Repositories/Eloquent/NestRepository.php +++ b/app/Repositories/Eloquent/NestRepository.php @@ -26,7 +26,7 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa } /** - * Return a nest or all nests with their associated eggs, variables, and packs. + * Return a nest or all nests with their associated eggs and variables. * * @param int $id * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest @@ -35,7 +35,7 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa */ public function getWithEggs(int $id = null) { - $instance = $this->getBuilder()->with('eggs.packs', 'eggs.variables'); + $instance = $this->getBuilder()->with('eggs', 'eggs.variables'); if (! is_null($id)) { $instance = $instance->find($id, $this->getColumns()); @@ -50,7 +50,7 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa } /** - * Return a nest or all nests and the count of eggs, packs, and servers for that nest. + * Return a nest or all nests and the count of eggs and servers for that nest. * * @param int|null $id * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection @@ -59,7 +59,7 @@ class NestRepository extends EloquentRepository implements NestRepositoryInterfa */ public function getWithCounts(int $id = null) { - $instance = $this->getBuilder()->withCount(['eggs', 'packs', 'servers']); + $instance = $this->getBuilder()->withCount(['eggs', 'servers']); if (! is_null($id)) { $instance = $instance->find($id, $this->getColumns()); diff --git a/app/Repositories/Eloquent/PackRepository.php b/app/Repositories/Eloquent/PackRepository.php deleted file mode 100644 index 6cf3996bd..000000000 --- a/app/Repositories/Eloquent/PackRepository.php +++ /dev/null @@ -1,52 +0,0 @@ -load(['servers.node', 'servers.user']); - } - - $pack->loadMissing(['servers.node', 'servers.user']); - - return $pack; - } - - /** - * Return a paginated listing of packs with their associated egg and server count. - * - * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator - */ - public function paginateWithEggAndServerCount(): LengthAwarePaginator - { - return $this->getBuilder()->with('egg')->withCount('servers') - ->paginate(50, $this->getColumns()); - } -} diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index f749d0d18..73bf85733 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -63,7 +63,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getDataForRebuild(int $server = null, int $node = null): Collection { - $instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'egg', 'node']); + $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); if (! is_null($server) && is_null($node)) { $instance = $instance->where('id', '=', $server); @@ -83,7 +83,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getDataForReinstall(int $server = null, int $node = null): Collection { - $instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'egg', 'node']); + $instance = $this->getBuilder()->with(['allocation', 'allocations', 'egg', 'node']); if (! is_null($server) && is_null($node)) { $instance = $instance->where('id', '=', $server); @@ -140,7 +140,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getDataForCreation(Server $server, bool $refresh = false): Server { - foreach (['allocation', 'allocations', 'pack', 'egg'] as $relation) { + foreach (['allocation', 'allocations', 'egg'] as $relation) { if (! $server->relationLoaded($relation) || $refresh) { $server->load($relation); } @@ -167,7 +167,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt /** * Get data for use when updating a server on the Daemon. Returns an array of - * the egg and pack UUID which are used for build and rebuild. Only loads relations + * the egg which is used for build and rebuild. Only loads relations * if they are missing, or refresh is set to true. * * @param \Pterodactyl\Models\Server $server @@ -180,13 +180,8 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt $server->load('egg'); } - if (! $server->relationLoaded('pack') || $refresh) { - $server->load('pack'); - } - return [ 'egg' => $server->getRelation('egg')->uuid, - 'pack' => is_null($server->getRelation('pack')) ? null : $server->getRelation('pack')->uuid, ]; } diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php index 77e30be4f..96085e152 100644 --- a/app/Services/Acl/Api/AdminAcl.php +++ b/app/Services/Acl/Api/AdminAcl.php @@ -34,7 +34,6 @@ class AdminAcl const RESOURCE_EGGS = 'eggs'; const RESOURCE_DATABASE_HOSTS = 'database_hosts'; const RESOURCE_SERVER_DATABASES = 'server_databases'; - const RESOURCE_PACKS = 'packs'; /** * Determine if an API key has permission to perform a specific read/write operation. diff --git a/app/Services/Packs/ExportPackService.php b/app/Services/Packs/ExportPackService.php deleted file mode 100644 index 1403bfdca..000000000 --- a/app/Services/Packs/ExportPackService.php +++ /dev/null @@ -1,97 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Services\Packs; - -use ZipArchive; -use Pterodactyl\Models\Pack; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; -use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; -use Pterodactyl\Exceptions\Service\Pack\ZipArchiveCreationException; - -class ExportPackService -{ - /** - * @var \ZipArchive - */ - protected $archive; - - /** - * @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface - */ - protected $repository; - - /** - * @var \Illuminate\Contracts\Filesystem\Factory - */ - protected $storage; - - /** - * ExportPackService constructor. - * - * @param \Illuminate\Contracts\Filesystem\Factory $storage - * @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository - * @param \ZipArchive $archive - */ - public function __construct( - FilesystemFactory $storage, - PackRepositoryInterface $repository, - ZipArchive $archive - ) { - $this->archive = $archive; - $this->repository = $repository; - $this->storage = $storage; - } - - /** - * Prepare a pack for export. - * - * @param int|\Pterodactyl\Models\Pack $pack - * @param bool $files - * @return string - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - * @throws \Pterodactyl\Exceptions\Service\Pack\ZipArchiveCreationException - */ - public function handle($pack, $files = false) - { - if (! $pack instanceof Pack) { - $pack = $this->repository->find($pack); - } - - $json = [ - 'name' => $pack->name, - 'version' => $pack->version, - 'description' => $pack->description, - 'selectable' => $pack->selectable, - 'visible' => $pack->visible, - 'locked' => $pack->locked, - ]; - - $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_'); - if ($files) { - if (! $this->archive->open($filename, $this->archive::CREATE)) { - throw new ZipArchiveCreationException; - } - - foreach ($this->storage->disk()->files('packs/' . $pack->uuid) as $file) { - $this->archive->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file))); - } - - $this->archive->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT)); - $this->archive->close(); - } else { - $fp = fopen($filename, 'a+'); - fwrite($fp, json_encode($json, JSON_PRETTY_PRINT)); - fclose($fp); - } - - return $filename; - } -} diff --git a/app/Services/Packs/PackCreationService.php b/app/Services/Packs/PackCreationService.php deleted file mode 100644 index 5179ea0dd..000000000 --- a/app/Services/Packs/PackCreationService.php +++ /dev/null @@ -1,104 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Services\Packs; - -use Ramsey\Uuid\Uuid; -use Illuminate\Http\UploadedFile; -use Illuminate\Database\ConnectionInterface; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; -use Pterodactyl\Exceptions\Service\InvalidFileUploadException; -use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; -use Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException; - -class PackCreationService -{ - const VALID_UPLOAD_TYPES = [ - 'application/gzip', - 'application/x-gzip', - ]; - - /** - * @var \Illuminate\Database\ConnectionInterface - */ - protected $connection; - - /** - * @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface - */ - protected $repository; - - /** - * @var \Illuminate\Contracts\Filesystem\Factory - */ - protected $storage; - - /** - * PackCreationService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Filesystem\Factory $storage - * @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository - */ - public function __construct( - ConnectionInterface $connection, - FilesystemFactory $storage, - PackRepositoryInterface $repository - ) { - $this->connection = $connection; - $this->repository = $repository; - $this->storage = $storage; - } - - /** - * Add a new service pack to the system. - * - * @param array $data - * @param \Illuminate\Http\UploadedFile|null $file - * @return \Pterodactyl\Models\Pack - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - */ - public function handle(array $data, UploadedFile $file = null) - { - if (! is_null($file)) { - if (! $file->isValid()) { - throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload')); - } - - if (! in_array($file->getMimeType(), self::VALID_UPLOAD_TYPES)) { - throw new InvalidFileMimeTypeException(trans('exceptions.packs.invalid_mime', [ - 'type' => implode(', ', self::VALID_UPLOAD_TYPES), - ])); - } - } - - // Transform values to boolean - $data['selectable'] = isset($data['selectable']); - $data['visible'] = isset($data['visible']); - $data['locked'] = isset($data['locked']); - - $this->connection->beginTransaction(); - $pack = $this->repository->create(array_merge( - ['uuid' => Uuid::uuid4()], - $data - )); - - $this->storage->disk()->makeDirectory('packs/' . $pack->uuid); - if (! is_null($file)) { - $file->storeAs('packs/' . $pack->uuid, 'archive.tar.gz'); - } - - $this->connection->commit(); - - return $pack; - } -} diff --git a/app/Services/Packs/PackDeletionService.php b/app/Services/Packs/PackDeletionService.php deleted file mode 100644 index cd9be47b6..000000000 --- a/app/Services/Packs/PackDeletionService.php +++ /dev/null @@ -1,85 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Services\Packs; - -use Pterodactyl\Models\Pack; -use Illuminate\Database\ConnectionInterface; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; -use Pterodactyl\Exceptions\Service\HasActiveServersException; -use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; -use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory; - -class PackDeletionService -{ - /** - * @var \Illuminate\Database\ConnectionInterface - */ - protected $connection; - - /** - * @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface - */ - protected $repository; - - /** - * @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface - */ - protected $serverRepository; - - /** - * @var \Illuminate\Contracts\Filesystem\Factory - */ - protected $storage; - - /** - * PackDeletionService constructor. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Illuminate\Contracts\Filesystem\Factory $storage - * @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - */ - public function __construct( - ConnectionInterface $connection, - FilesystemFactory $storage, - PackRepositoryInterface $repository, - ServerRepositoryInterface $serverRepository - ) { - $this->connection = $connection; - $this->repository = $repository; - $this->serverRepository = $serverRepository; - $this->storage = $storage; - } - - /** - * Delete a pack from the database as well as the archive stored on the server. - * - * @param int|\Pterodactyl\Models\Pack $pack - * - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function handle($pack) - { - if (! $pack instanceof Pack) { - $pack = $this->repository->setColumns(['id', 'uuid'])->find($pack); - } - - $count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]); - if ($count !== 0) { - throw new HasActiveServersException(trans('exceptions.packs.delete_has_servers')); - } - - $this->connection->beginTransaction(); - $this->repository->delete($pack->id); - $this->storage->disk()->deleteDirectory('packs/' . $pack->uuid); - $this->connection->commit(); - } -} diff --git a/app/Services/Packs/PackUpdateService.php b/app/Services/Packs/PackUpdateService.php deleted file mode 100644 index 52c32818c..000000000 --- a/app/Services/Packs/PackUpdateService.php +++ /dev/null @@ -1,75 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Services\Packs; - -use Pterodactyl\Models\Pack; -use Pterodactyl\Contracts\Repository\PackRepositoryInterface; -use Pterodactyl\Exceptions\Service\HasActiveServersException; -use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; - -class PackUpdateService -{ - /** - * @var \Pterodactyl\Contracts\Repository\PackRepositoryInterface - */ - protected $repository; - - /** - * @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface - */ - protected $serverRepository; - - /** - * PackUpdateService constructor. - * - * @param \Pterodactyl\Contracts\Repository\PackRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - */ - public function __construct( - PackRepositoryInterface $repository, - ServerRepositoryInterface $serverRepository - ) { - $this->repository = $repository; - $this->serverRepository = $serverRepository; - } - - /** - * Update a pack. - * - * @param int|\Pterodactyl\Models\Pack $pack - * @param array $data - * @return bool - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function handle($pack, array $data) - { - if (! $pack instanceof Pack) { - $pack = $this->repository->setColumns(['id', 'egg_id'])->find($pack); - } - - if ((int) array_get($data, 'egg_id', $pack->egg_id) !== $pack->egg_id) { - $count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]); - - if ($count !== 0) { - throw new HasActiveServersException(trans('exceptions.packs.update_has_servers')); - } - } - - // Transform values to boolean - $data['selectable'] = isset($data['selectable']); - $data['visible'] = isset($data['visible']); - $data['locked'] = isset($data['locked']); - - return $this->repository->withoutFreshModel()->update($pack->id, $data); - } -} diff --git a/app/Services/Packs/TemplateUploadService.php b/app/Services/Packs/TemplateUploadService.php deleted file mode 100644 index dbefd89a1..000000000 --- a/app/Services/Packs/TemplateUploadService.php +++ /dev/null @@ -1,125 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Services\Packs; - -use ZipArchive; -use Illuminate\Http\UploadedFile; -use Pterodactyl\Exceptions\Service\InvalidFileUploadException; -use Pterodactyl\Exceptions\Service\Pack\ZipExtractionException; -use Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException; -use Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException; -use Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException; - -class TemplateUploadService -{ - const VALID_UPLOAD_TYPES = [ - 'application/zip', - 'text/plain', - 'application/json', - ]; - - /** - * @var \ZipArchive - */ - protected $archive; - - /** - * @var \Pterodactyl\Services\Packs\PackCreationService - */ - protected $creationService; - - /** - * TemplateUploadService constructor. - * - * @param \Pterodactyl\Services\Packs\PackCreationService $creationService - * @param \ZipArchive $archive - */ - public function __construct( - PackCreationService $creationService, - ZipArchive $archive - ) { - $this->archive = $archive; - $this->creationService = $creationService; - } - - /** - * Process an uploaded file to create a new pack from a JSON or ZIP format. - * - * @param int $egg - * @param \Illuminate\Http\UploadedFile $file - * @return \Pterodactyl\Models\Pack - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Pack\ZipExtractionException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException - * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException - */ - public function handle($egg, UploadedFile $file) - { - if (! $file->isValid()) { - throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload')); - } - - if (! in_array($file->getMimeType(), self::VALID_UPLOAD_TYPES)) { - throw new InvalidFileMimeTypeException(trans('exceptions.packs.invalid_mime', [ - 'type' => implode(', ', self::VALID_UPLOAD_TYPES), - ])); - } - - if ($file->getMimeType() === 'application/zip') { - return $this->handleArchive($egg, $file); - } else { - $json = json_decode($file->openFile()->fread($file->getSize()), true); - $json['egg_id'] = $egg; - - return $this->creationService->handle($json); - } - } - - /** - * Process a ZIP file to create a pack and stored archive. - * - * @param int $egg - * @param \Illuminate\Http\UploadedFile $file - * @return \Pterodactyl\Models\Pack - * - * @throws \Pterodactyl\Exceptions\Model\DataValidationException - * @throws \Pterodactyl\Exceptions\Service\Pack\ZipExtractionException - * @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileMimeTypeException - * @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException - * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException - */ - protected function handleArchive($egg, $file) - { - if (! $this->archive->open($file->getRealPath())) { - throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable')); - } - - if (! $this->archive->locateName('import.json') || ! $this->archive->locateName('archive.tar.gz')) { - throw new InvalidPackArchiveFormatException(trans('exceptions.packs.invalid_archive_exception')); - } - - $json = json_decode($this->archive->getFromName('import.json'), true); - $json['egg_id'] = $egg; - - $pack = $this->creationService->handle($json); - if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) { - // @todo delete the pack that was created. - throw new ZipExtractionException(trans('exceptions.packs.zip_extraction')); - } - - $this->archive->close(); - - return $pack; - } -} diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 60630d064..f17405fad 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -15,7 +15,7 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; class ServerConfigurationStructureService { - const REQUIRED_RELATIONS = ['allocation', 'allocations', 'pack', 'egg']; + const REQUIRED_RELATIONS = ['allocation', 'allocations', 'egg']; /** * @var \Pterodactyl\Services\Servers\EnvironmentService @@ -139,7 +139,6 @@ class ServerConfigurationStructureService ], 'service' => [ 'egg' => $server->egg->uuid, - 'pack' => $server->pack ? $server->pack->uuid : null, 'skip_scripts' => $server->skip_scripts, ], 'rebuild' => false, diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php index 6d70d23e4..589a790e9 100644 --- a/app/Services/Servers/ServerCreationService.php +++ b/app/Services/Servers/ServerCreationService.php @@ -246,7 +246,6 @@ class ServerCreationService 'allocation_id' => Arr::get($data, 'allocation_id'), 'nest_id' => Arr::get($data, 'nest_id'), 'egg_id' => Arr::get($data, 'egg_id'), - 'pack_id' => empty($data['pack_id']) ? null : $data['pack_id'], 'startup' => Arr::get($data, 'startup'), 'image' => Arr::get($data, 'image'), 'database_limit' => Arr::get($data, 'database_limit') ?? 0, diff --git a/app/Services/Servers/StartupModificationService.php b/app/Services/Servers/StartupModificationService.php index 405fee47b..7bec8fac6 100644 --- a/app/Services/Servers/StartupModificationService.php +++ b/app/Services/Servers/StartupModificationService.php @@ -140,7 +140,6 @@ class StartupModificationService 'startup' => array_get($data, 'startup', $server->startup), 'nest_id' => array_get($data, 'nest_id', $server->nest_id), 'egg_id' => array_get($data, 'egg_id', $server->egg_id), - 'pack_id' => array_get($data, 'pack_id', $server->pack_id) > 0 ? array_get($data, 'pack_id', $server->pack_id) : null, 'skip_scripts' => array_get($data, 'skip_scripts') ?? isset($data['skip_scripts']), 'image' => array_get($data, 'docker_image', $server->image), ]); diff --git a/app/Transformers/Api/Application/LocationTransformer.php b/app/Transformers/Api/Application/LocationTransformer.php index d54e77d20..7d24cc974 100644 --- a/app/Transformers/Api/Application/LocationTransformer.php +++ b/app/Transformers/Api/Application/LocationTransformer.php @@ -25,7 +25,7 @@ class LocationTransformer extends BaseTransformer } /** - * Return a generic transformed pack array. + * Return a generic transformed location array. * * @param \Pterodactyl\Models\Location $location * @return array diff --git a/app/Transformers/Api/Application/PackTransformer.php b/app/Transformers/Api/Application/PackTransformer.php deleted file mode 100644 index e77bdd459..000000000 --- a/app/Transformers/Api/Application/PackTransformer.php +++ /dev/null @@ -1,40 +0,0 @@ - $pack->id, - 'uuid' => $pack->uuid, - 'egg' => $pack->egg_id, - 'name' => $pack->name, - 'description' => $pack->description, - 'is_selectable' => (bool) $pack->selectable, - 'is_visible' => (bool) $pack->visible, - 'is_locked' => (bool) $pack->locked, - 'created_at' => $this->formatTimestamp($pack->created_at), - 'updated_at' => $this->formatTimestamp($pack->updated_at), - ]; - } -} diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index d9df4263a..e2c32eb76 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -22,7 +22,6 @@ class ServerTransformer extends BaseTransformer 'allocations', 'user', 'subusers', - 'pack', 'nest', 'egg', 'variables', @@ -87,7 +86,6 @@ class ServerTransformer extends BaseTransformer 'allocation' => $server->allocation_id, 'nest' => $server->nest_id, 'egg' => $server->egg_id, - 'pack' => $server->pack_id, 'container' => [ 'startup_command' => $server->startup, 'image' => $server->image, @@ -156,28 +154,6 @@ class ServerTransformer extends BaseTransformer return $this->item($server->getRelation('user'), $this->makeTransformer(UserTransformer::class), 'user'); } - /** - * Return a generic array with pack information for this server. - * - * @param \Pterodactyl\Models\Server $server - * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource - * - * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException - */ - public function includePack(Server $server) - { - if (! $this->authorize(AdminAcl::RESOURCE_PACKS)) { - return $this->null(); - } - - $server->loadMissing('pack'); - if (is_null($server->getRelation('pack'))) { - return $this->null(); - } - - return $this->item($server->getRelation('pack'), $this->makeTransformer(PackTransformer::class), 'pack'); - } - /** * Return a generic array with nest information for this server. * @@ -236,7 +212,7 @@ class ServerTransformer extends BaseTransformer } /** - * Return a generic array with pack information for this server. + * Return a generic array with location information for this server. * * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource @@ -255,7 +231,7 @@ class ServerTransformer extends BaseTransformer } /** - * Return a generic array with pack information for this server. + * Return a generic array with node information for this server. * * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource diff --git a/config/pterodactyl.php b/config/pterodactyl.php index 5721277cf..aba0d729a 100644 --- a/config/pterodactyl.php +++ b/config/pterodactyl.php @@ -56,7 +56,6 @@ return [ 'admin' => [ 'servers' => env('APP_PAGINATE_ADMIN_SERVERS', 25), 'users' => env('APP_PAGINATE_ADMIN_USERS', 25), - 'packs' => env('APP_PAGINATE_ADMIN_PACKS', 50), ], 'api' => [ 'nodes' => env('APP_PAGINATE_API_NODES', 25), diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 6d6208f4f..60e068941 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -32,7 +32,6 @@ $factory->define(Pterodactyl\Models\Server::class, function (Faker $faker) { 'io' => 500, 'cpu' => 0, 'oom_disabled' => 0, - 'pack_id' => null, 'installed' => 1, 'database_limit' => null, 'allocation_limit' => null, @@ -132,18 +131,6 @@ $factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () { return ['user_editable' => 1]; }); -$factory->define(Pterodactyl\Models\Pack::class, function (Faker $faker) { - return [ - 'uuid' => $faker->uuid, - 'name' => $faker->word, - 'description' => null, - 'version' => $faker->randomNumber(), - 'selectable' => 1, - 'visible' => 1, - 'locked' => 0, - ]; -}); - $factory->define(Pterodactyl\Models\Subuser::class, function (Faker $faker) { return []; }); diff --git a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php new file mode 100644 index 000000000..b1d2c1bf1 --- /dev/null +++ b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php @@ -0,0 +1,34 @@ +dropForeign(['pack_id']); + $table->dropColumn('pack_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('servers', function (Blueprint $table) { + $table->unsignedInteger('pack_id')->after('egg_id')->nullable(); + $table->foreign('pack_id')->references('id')->on('packs'); + }); + } +} diff --git a/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php b/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php new file mode 100644 index 000000000..879a64bdf --- /dev/null +++ b/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php @@ -0,0 +1,32 @@ +dropColumn('r_packs'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('api_keys', function (Blueprint $table) { + $table->unsignedTinyInteger('r_packs')->default(0); + }); + } +} diff --git a/database/migrations/2020_09_13_110047_drop_packs_table.php b/database/migrations/2020_09_13_110047_drop_packs_table.php new file mode 100644 index 000000000..2ab85a5de --- /dev/null +++ b/database/migrations/2020_09_13_110047_drop_packs_table.php @@ -0,0 +1,43 @@ +increments('id'); + $table->unsignedInteger('egg_id'); + $table->char('uuid', 36)->unique(); + $table->string('name'); + $table->string('version'); + $table->text('description')->nullable(); + $table->tinyInteger('selectable')->default(1); + $table->tinyInteger('visible')->default(1); + $table->tinyInteger('locked')->default(0); + $table->timestamps(); + }); + + Schema::table('packs', function (Blueprint $table) { + $table->foreign('egg_id')->references('id')->on('eggs')->cascadeOnDelete(); + }); + } +} diff --git a/resources/lang/en/admin/pack.php b/resources/lang/en/admin/pack.php deleted file mode 100644 index e3a175f62..000000000 --- a/resources/lang/en/admin/pack.php +++ /dev/null @@ -1,16 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -return [ - 'notices' => [ - 'pack_updated' => 'Pack has been successfully updated.', - 'pack_deleted' => 'Successfully deleted the pack ":name" from the system.', - 'pack_created' => 'A new pack was successfully created on the system and is now available for deployment to servers.', - ], -]; diff --git a/resources/lang/en/exceptions.php b/resources/lang/en/exceptions.php index d8dcd559b..4d44c4ff9 100644 --- a/resources/lang/en/exceptions.php +++ b/resources/lang/en/exceptions.php @@ -32,15 +32,6 @@ return [ 'invalid_json_provided' => 'The JSON file provided is not in a format that can be recognized.', ], ], - 'packs' => [ - 'delete_has_servers' => 'Cannot delete a pack that is attached to active servers.', - 'update_has_servers' => 'Cannot modify the associated option ID when servers are currently attached to a pack.', - 'invalid_upload' => 'The file provided does not appear to be valid.', - 'invalid_mime' => 'The file provided does not meet the required type :type', - 'unreadable' => 'The archive provided could not be opened by the server.', - 'zip_extraction' => 'An exception was encountered while attempting to extract the archive provided onto the server.', - 'invalid_archive_exception' => 'The pack archive provided appears to be missing a required archive.tar.gz or import.json file in the base directory.', - ], 'subusers' => [ 'editing_self' => 'Editing your own subuser account is not permitted.', 'user_is_owner' => 'You cannot add the server owner as a subuser for this server.', diff --git a/resources/views/admin/nests/index.blade.php b/resources/views/admin/nests/index.blade.php index 3c726964b..b45f1187f 100644 --- a/resources/views/admin/nests/index.blade.php +++ b/resources/views/admin/nests/index.blade.php @@ -42,7 +42,6 @@ Name Description Eggs - Packs Servers @foreach($nests as $nest) @@ -51,7 +50,6 @@ {{ $nest->name }} {{ $nest->description }} {{ $nest->eggs_count }} - {{ $nest->packs_count }} {{ $nest->servers_count }} @endforeach diff --git a/resources/views/admin/packs/index.blade.php b/resources/views/admin/packs/index.blade.php deleted file mode 100644 index 9c57d41ca..000000000 --- a/resources/views/admin/packs/index.blade.php +++ /dev/null @@ -1,70 +0,0 @@ -{{-- Pterodactyl - Panel --}} -{{-- Copyright (c) 2015 - 2017 Dane Everitt --}} - -{{-- This software is licensed under the terms of the MIT license. --}} -{{-- https://opensource.org/licenses/MIT --}} -@extends('layouts.admin') - -@section('title') - List Packs -@endsection - -@section('content-header') -

PacksAll service packs available on the system.

- -@endsection - -@section('content') -
-
-
-
-

Pack List

-
-
-
- -
- - -
-
-
-
-
-
- - - - - - - - - - - @foreach ($packs as $pack) - - - - - - - - - @endforeach - -
IDPack NameVersionDescriptionEggServers
{{ $pack->id }}{{ $pack->name }}{{ $pack->version }}{{ str_limit($pack->description, 150) }}{{ $pack->egg->name }}{{ $pack->servers_count }}
-
- @if ($packs->hasPages()) - - @endif -
-
-
-@endsection diff --git a/resources/views/admin/packs/modal.blade.php b/resources/views/admin/packs/modal.blade.php deleted file mode 100644 index 551e6fde2..000000000 --- a/resources/views/admin/packs/modal.blade.php +++ /dev/null @@ -1,47 +0,0 @@ - diff --git a/resources/views/admin/packs/new.blade.php b/resources/views/admin/packs/new.blade.php deleted file mode 100644 index 8cff53c14..000000000 --- a/resources/views/admin/packs/new.blade.php +++ /dev/null @@ -1,144 +0,0 @@ -{{-- Pterodactyl - Panel --}} -{{-- Copyright (c) 2015 - 2017 Dane Everitt --}} - -{{-- This software is licensed under the terms of the MIT license. --}} -{{-- https://opensource.org/licenses/MIT --}} -@extends('layouts.admin') - -@section('title') - Packs → New -@endsection - -@section('content-header') -

New PackCreate a new pack on the system.

- -@endsection - -@section('content') - -
-
-
-
-
-

Pack Details

-
-
-
- - -

A short but descriptive name of what this pack is. For example, Counter Strike: Source if it is a Counter Strike package.

-
-
- - -
-
- - -

The version of this package, or the version of the files contained within the package.

-
-
- - -

The option that this pack is associated with. Only servers that are assigned this option will be able to access this pack.

-
-
-
-
-
-
-
-

Pack Configuration

-
-
-
-
- - -
-

Check this box if user should be able to select this pack to install on their servers.

-
-
-
- - -
-

Check this box if this pack is visible in the dropdown menu. If this pack is assigned to a server it will be visible regardless of this setting.

-
-
-
- - -
-

Check this box if servers assigned this pack should not be able to switch to a different pack.

-
-
-
- - -

This package file must be a .tar.gz archive of pack files to be decompressed into the server folder.

-

If your file is larger than 50MB it is recommended to upload it using SFTP. Once you have added this pack to the system, a path will be provided where you should upload the file.

-
-

This node is currently configured with the following limits:
upload_max_filesize={{ ini_get('upload_max_filesize') }}
post_max_size={{ ini_get('post_max_size') }}

If your file is larger than either of those values this request will fail.

-
-
-
- -
-
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/packs/view.blade.php b/resources/views/admin/packs/view.blade.php deleted file mode 100644 index 63382a21c..000000000 --- a/resources/views/admin/packs/view.blade.php +++ /dev/null @@ -1,154 +0,0 @@ -{{-- Pterodactyl - Panel --}} -{{-- Copyright (c) 2015 - 2017 Dane Everitt --}} - -{{-- This software is licensed under the terms of the MIT license. --}} -{{-- https://opensource.org/licenses/MIT --}} -@extends('layouts.admin') - -@section('title') - Packs → View → {{ $pack->name }} -@endsection - -@section('content-header') -

{{ $pack->name }}{{ str_limit($pack->description, 60) }}

- -@endsection - -@section('content') -
-
-
-
-
-

Pack Details

-
-
-
- - -

A short but descriptive name of what this pack is. For example, Counter Strike: Source if it is a Counter Strike package.

-
-
- - -
-
- - -

The version of this package, or the version of the files contained within the package.

-
-
- - -

If you would like to modify the stored pack you will need to upload a new archive.tar.gz to the location defined above.

-
-
-
-
-
-
-
-

Pack Configuration

-
-
-
- - -

The option that this pack is associated with. Only servers that are assigned this option will be able to access this pack. This assigned option cannot be changed if servers are attached to this pack.

-
-
-
- selectable ?: 'checked' }}/> - -
-

Check this box if user should be able to select this pack to install on their servers.

-
-
-
- visible ?: 'checked' }}/> - -
-

Check this box if this pack is visible in the dropdown menu. If this pack is assigned to a server it will be visible regardless of this setting.

-
-
-
- locked ?: 'checked' }}/> - -
-

Check this box if servers assigned this pack should not be able to switch to a different pack.

-
-
- -
-
-
-
-
-
-
-
-

Servers Using This Pack

-
-
- - - - - - - - @foreach($pack->servers as $server) - - - - - - - @endforeach -
IDServer NameNodeOwner
{{ $server->uuidShort }}{{ $server->name }}{{ $server->node->name }}{{ $server->user->email }}
-
-
-
-
-
-
-
- {!! csrf_field() !!} - -
-
- {!! csrf_field() !!} - -
-
-
-@endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php index 026be8be3..fe9c7be24 100644 --- a/resources/views/admin/servers/new.blade.php +++ b/resources/views/admin/servers/new.blade.php @@ -244,20 +244,13 @@

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.

+

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

@@ -384,12 +377,6 @@ $('#pEggId').val('{{ old('egg_id') }}').change(); @endif // END Persist 'Egg' select2 - - // Persist 'Data Pack' select2 - @if (old('pack_id')) - $('#pPackId').val('{{ old('pack_id') }}').change(); - @endif - // END Persist 'Data Pack' select2 @endif // END Persist 'Nest' select2 }); diff --git a/resources/views/admin/servers/view/manage.blade.php b/resources/views/admin/servers/view/manage.blade.php index 8c41fc503..aad14209b 100644 --- a/resources/views/admin/servers/view/manage.blade.php +++ b/resources/views/admin/servers/view/manage.blade.php @@ -28,7 +28,7 @@

Reinstall Server

-

This will reinstall the server with the assigned pack and service scripts. Danger! This could overwrite server data.

+

This will reinstall the server with the assigned service scripts. Danger! This could overwrite server data.

@@ -117,7 +112,6 @@ {!! Theme::js('vendor/lodash/lodash.js') !!}