diff --git a/app/Contracts/Repository/ServiceOptionRepositoryInterface.php b/app/Contracts/Repository/EggRepositoryInterface.php similarity index 58% rename from app/Contracts/Repository/ServiceOptionRepositoryInterface.php rename to app/Contracts/Repository/EggRepositoryInterface.php index 310b385ea..364fd0c6d 100644 --- a/app/Contracts/Repository/ServiceOptionRepositoryInterface.php +++ b/app/Contracts/Repository/EggRepositoryInterface.php @@ -9,49 +9,49 @@ namespace Pterodactyl\Contracts\Repository; -use Pterodactyl\Models\ServiceOption; +use Pterodactyl\Models\Egg; use Illuminate\Database\Eloquent\Collection; -interface ServiceOptionRepositoryInterface extends RepositoryInterface +interface EggRepositoryInterface extends RepositoryInterface { /** - * Return a service option with the variables relation attached. + * Return an egg with the variables relation attached. * * @param int $id - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithVariables(int $id): ServiceOption; + public function getWithVariables(int $id): Egg; /** - * Return all of the service options and their relations to be used in the daemon API. + * Return all eggs and their relations to be used in the daemon API. * * @return \Illuminate\Database\Eloquent\Collection */ public function getAllWithCopyAttributes(): Collection; /** - * Return a service option with the scriptFrom and configFrom relations loaded onto the model. + * Return an egg with the scriptFrom and configFrom relations loaded onto the model. * * @param int|string $value * @param string $column - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg */ - public function getWithCopyAttributes($value, string $column = 'id'): ServiceOption; + public function getWithCopyAttributes($value, string $column = 'id'): Egg; /** * Return all of the data needed to export a service. * * @param int $id - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithExportAttributes(int $id): ServiceOption; + public function getWithExportAttributes(int $id): Egg; /** - * Confirm a copy script belongs to the same service as the item trying to use it. + * Confirm a copy script belongs to the same nest as the item trying to use it. * * @param int $copyFromId * @param int $service diff --git a/app/Contracts/Repository/OptionVariableRepositoryInterface.php b/app/Contracts/Repository/EggVariableRepositoryInterface.php similarity index 78% rename from app/Contracts/Repository/OptionVariableRepositoryInterface.php rename to app/Contracts/Repository/EggVariableRepositoryInterface.php index cb3bdc606..afaf7463b 100644 --- a/app/Contracts/Repository/OptionVariableRepositoryInterface.php +++ b/app/Contracts/Repository/EggVariableRepositoryInterface.php @@ -9,6 +9,6 @@ namespace Pterodactyl\Contracts\Repository; -interface OptionVariableRepositoryInterface extends RepositoryInterface +interface EggVariableRepositoryInterface extends RepositoryInterface { } diff --git a/app/Contracts/Repository/ServiceRepositoryInterface.php b/app/Contracts/Repository/NestRepositoryInterface.php similarity index 53% rename from app/Contracts/Repository/ServiceRepositoryInterface.php rename to app/Contracts/Repository/NestRepositoryInterface.php index c514c1cf7..b06f9730b 100644 --- a/app/Contracts/Repository/ServiceRepositoryInterface.php +++ b/app/Contracts/Repository/NestRepositoryInterface.php @@ -9,37 +9,37 @@ namespace Pterodactyl\Contracts\Repository; -use Pterodactyl\Models\Service; +use Pterodactyl\Models\Nest; -interface ServiceRepositoryInterface extends RepositoryInterface +interface NestRepositoryInterface extends RepositoryInterface { /** - * Return a service or all services with their associated options, variables, and packs. + * Return a nest or all nests with their associated eggs, variables, and packs. * * @param int $id - * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Service + * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithOptions(int $id = null); + public function getWithEggs(int $id = null); /** - * Return a service or all services and the count of options, packs, and servers for that service. + * Return a nest or all nests and the count of eggs, packs, and servers for that nest. * * @param int|null $id - * @return \Pterodactyl\Models\Service|\Illuminate\Database\Eloquent\Collection + * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithCounts(int $id = null); /** - * Return a service along with its associated options and the servers relation on those options. + * Return a nest along with its associated eggs and the servers relation on those eggs. * * @param int $id - * @return \Pterodactyl\Models\Service + * @return \Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithOptionServers(int $id): Service; + public function getWithEggServers(int $id): Nest; } diff --git a/app/Contracts/Repository/PackRepositoryInterface.php b/app/Contracts/Repository/PackRepositoryInterface.php index e634716c2..d6ad80785 100644 --- a/app/Contracts/Repository/PackRepositoryInterface.php +++ b/app/Contracts/Repository/PackRepositoryInterface.php @@ -14,12 +14,12 @@ use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface; interface PackRepositoryInterface extends RepositoryInterface, SearchableInterface { /** - * Return a paginated listing of packs with their associated option and server count. + * Return a paginated listing of packs with their associated egg and server count. * * @param int $paginate * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator */ - public function paginateWithOptionAndServerCount($paginate = 50); + public function paginateWithEggAndServerCount($paginate = 50); /** * Return a pack with the associated server models attached to it. diff --git a/app/Contracts/Repository/ServiceVariableRepositoryInterface.php b/app/Contracts/Repository/ServiceVariableRepositoryInterface.php deleted file mode 100644 index e65e8a45f..000000000 --- a/app/Contracts/Repository/ServiceVariableRepositoryInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Contracts\Repository; - -interface ServiceVariableRepositoryInterface extends RepositoryInterface -{ -} diff --git a/app/Exceptions/Service/ServiceOption/DuplicateOptionTagException.php b/app/Exceptions/Service/ServiceOption/DuplicateOptionTagException.php deleted file mode 100644 index 070beda42..000000000 --- a/app/Exceptions/Service/ServiceOption/DuplicateOptionTagException.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\ServiceOption; - -use Pterodactyl\Exceptions\DisplayException; - -class DuplicateOptionTagException extends DisplayException -{ -} diff --git a/app/Http/Controllers/API/Admin/ServiceController.php b/app/Http/Controllers/API/Admin/ServiceController.php index 2751e37a5..44e3565ee 100644 --- a/app/Http/Controllers/API/Admin/ServiceController.php +++ b/app/Http/Controllers/API/Admin/ServiceController.php @@ -11,7 +11,7 @@ namespace Pterodactyl\Http\Controllers\API\Admin; use Fractal; use Illuminate\Http\Request; -use Pterodactyl\Models\Service; +use Pterodactyl\Models\Nest; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Transformers\Admin\ServiceTransformer; @@ -28,7 +28,7 @@ class ServiceController extends Controller $this->authorize('service-list', $request->apiKey()); return Fractal::create() - ->collection(Service::all()) + ->collection(Nest::all()) ->transformWith(new ServiceTransformer($request)) ->withResourceName('service') ->toArray(); @@ -45,7 +45,7 @@ class ServiceController extends Controller { $this->authorize('service-view', $request->apiKey()); - $service = Service::findOrFail($id); + $service = Nest::findOrFail($id); $fractal = Fractal::create()->item($service); if ($request->input('include')) { diff --git a/app/Http/Controllers/API/Remote/OptionRetrievalController.php b/app/Http/Controllers/API/Remote/OptionRetrievalController.php index fdd715ca9..46b4dfb3e 100644 --- a/app/Http/Controllers/API/Remote/OptionRetrievalController.php +++ b/app/Http/Controllers/API/Remote/OptionRetrievalController.php @@ -11,7 +11,7 @@ namespace Pterodactyl\Http\Controllers\API\Remote; use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Services\Services\Options\OptionConfigurationFileService; class OptionRetrievalController extends Controller @@ -22,18 +22,18 @@ class OptionRetrievalController extends Controller protected $configurationFileService; /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; /** * OptionUpdateController constructor. * - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository * @param \Pterodactyl\Services\Services\Options\OptionConfigurationFileService $configurationFileService */ public function __construct( - ServiceOptionRepositoryInterface $repository, + EggRepositoryInterface $repository, OptionConfigurationFileService $configurationFileService ) { $this->configurationFileService = $configurationFileService; diff --git a/app/Http/Controllers/Admin/Nests/EggController.php b/app/Http/Controllers/Admin/Nests/EggController.php new file mode 100644 index 000000000..831305db4 --- /dev/null +++ b/app/Http/Controllers/Admin/Nests/EggController.php @@ -0,0 +1,32 @@ +. + * + * This software is licensed under the terms of the MIT license. + * https://opensource.org/licenses/MIT + */ + +namespace Pterodactyl\Http\Controllers\Admin\Nests; + +use Illuminate\View\View; +use Pterodactyl\Models\Egg; +use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; + +class EggController extends Controller +{ + protected $repository; + + public function __construct(EggRepositoryInterface $repository) + { + $this->repository = $repository; + } + + public function view(Egg $egg): View + { + return view('admin.eggs.view', [ + 'egg' => $egg, + ]); + } +} diff --git a/app/Http/Controllers/Admin/Services/Options/OptionShareController.php b/app/Http/Controllers/Admin/Nests/EggShareController.php similarity index 55% rename from app/Http/Controllers/Admin/Services/Options/OptionShareController.php rename to app/Http/Controllers/Admin/Nests/EggShareController.php index 76f58eb70..88d7883d7 100644 --- a/app/Http/Controllers/Admin/Services/Options/OptionShareController.php +++ b/app/Http/Controllers/Admin/Nests/EggShareController.php @@ -7,54 +7,54 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Http\Controllers\Admin\Services\Options; +namespace Pterodactyl\Http\Controllers\Admin\Nests; +use Pterodactyl\Models\Egg; use Illuminate\Http\RedirectResponse; -use Pterodactyl\Models\ServiceOption; use Pterodactyl\Http\Controllers\Controller; use Symfony\Component\HttpFoundation\Response; +use Pterodactyl\Services\Eggs\Sharing\EggExporterService; +use Pterodactyl\Services\Services\Sharing\EggImporterService; use Pterodactyl\Http\Requests\Admin\Service\OptionImportFormRequest; -use Pterodactyl\Services\Services\Sharing\ServiceOptionExporterService; -use Pterodactyl\Services\Services\Sharing\ServiceOptionImporterService; -class OptionShareController extends Controller +class EggShareController extends Controller { /** - * @var \Pterodactyl\Services\Services\Sharing\ServiceOptionExporterService + * @var \Pterodactyl\Services\Eggs\Sharing\EggExporterService */ protected $exporterService; /** - * @var \Pterodactyl\Services\Services\Sharing\ServiceOptionImporterService + * @var \Pterodactyl\Services\Services\Sharing\EggImporterService */ protected $importerService; /** * OptionShareController constructor. * - * @param \Pterodactyl\Services\Services\Sharing\ServiceOptionExporterService $exporterService - * @param \Pterodactyl\Services\Services\Sharing\ServiceOptionImporterService $importerService + * @param \Pterodactyl\Services\Eggs\Sharing\EggExporterService $exporterService + * @param \Pterodactyl\Services\Services\Sharing\EggImporterService $importerService */ public function __construct( - ServiceOptionExporterService $exporterService, - ServiceOptionImporterService $importerService + EggExporterService $exporterService, + EggImporterService $importerService ) { $this->exporterService = $exporterService; $this->importerService = $importerService; } /** - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Pterodactyl\Models\Egg $egg * @return \Symfony\Component\HttpFoundation\Response * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function export(ServiceOption $option): Response + public function export(Egg $egg): Response { - return response($this->exporterService->handle($option->id), 200, [ + return response($this->exporterService->handle($egg->id), 200, [ 'Content-Transfer-Encoding' => 'binary', 'Content-Description' => 'File Transfer', - 'Content-Disposition' => 'attachment; filename=' . kebab_case($option->name) . '.json', + 'Content-Disposition' => 'attachment; filename=egg-' . kebab_case($egg->name) . '.json', 'Content-Type' => 'application/json', ]); } @@ -71,8 +71,8 @@ class OptionShareController extends Controller */ public function import(OptionImportFormRequest $request): RedirectResponse { - $option = $this->importerService->handle($request->file('import_file'), $request->input('import_to_service')); + $egg = $this->importerService->handle($request->file('import_file'), $request->input('import_to_nest')); - return redirect()->route('admin.services.option.view', ['option' => $option->id]); + return redirect()->route('admin.nests.egg.view', ['egg' => $egg->id]); } } diff --git a/app/Http/Controllers/Admin/Nests/NestController.php b/app/Http/Controllers/Admin/Nests/NestController.php new file mode 100644 index 000000000..204236025 --- /dev/null +++ b/app/Http/Controllers/Admin/Nests/NestController.php @@ -0,0 +1,160 @@ +. + * + * This software is licensed under the terms of the MIT license. + * https://opensource.org/licenses/MIT + */ + +namespace Pterodactyl\Http\Controllers\Admin\Nests; + +use Illuminate\View\View; +use Illuminate\Http\RedirectResponse; +use Prologue\Alerts\AlertsMessageBag; +use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Services\Nests\NestUpdateService; +use Pterodactyl\Services\Nests\NestCreationService; +use Pterodactyl\Services\Nests\NestDeletionService; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; +use Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest; + +class NestController extends Controller +{ + /** + * @var \Prologue\Alerts\AlertsMessageBag + */ + protected $alert; + + /** + * @var \Pterodactyl\Services\Nests\NestCreationService + */ + protected $nestCreationService; + + /** + * @var \Pterodactyl\Services\Nests\NestDeletionService + */ + protected $nestDeletionService; + + /** + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface + */ + protected $repository; + + /** + * @var \Pterodactyl\Services\Nests\NestUpdateService + */ + protected $nestUpdateService; + + /** + * NestController constructor. + * + * @param \Prologue\Alerts\AlertsMessageBag $alert + * @param \Pterodactyl\Services\Nests\NestCreationService $nestCreationService + * @param \Pterodactyl\Services\Nests\NestDeletionService $nestDeletionService + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository + * @param \Pterodactyl\Services\Nests\NestUpdateService $nestUpdateService + */ + public function __construct( + AlertsMessageBag $alert, + NestCreationService $nestCreationService, + NestDeletionService $nestDeletionService, + NestRepositoryInterface $repository, + NestUpdateService $nestUpdateService + ) { + $this->alert = $alert; + $this->nestDeletionService = $nestDeletionService; + $this->nestCreationService = $nestCreationService; + $this->nestUpdateService = $nestUpdateService; + $this->repository = $repository; + } + + /** + * Render nest listing page. + * + * @return \Illuminate\View\View + * + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + */ + public function index(): View + { + return view('admin.nests.index', [ + 'nests' => $this->repository->getWithCounts(), + ]); + } + + /** + * Render nest creation page. + * + * @return \Illuminate\View\View + */ + public function create(): View + { + return view('admin.nests.new'); + } + + /** + * Handle the storage of a new nest. + * + * @param \Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest $request + * @return \Illuminate\Http\RedirectResponse + * + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + */ + public function store(StoreNestFormRequest $request): RedirectResponse + { + $nest = $this->nestCreationService->handle($request->normalize()); + $this->alert->success(trans('admin/nests.notices.created', ['name' => $nest->name]))->flash(); + + return redirect()->route('admin.nests.view', $nest->id); + } + + /** + * Return details about a nest including all of the eggs and servers per egg. + * + * @param int $nest + * @return \Illuminate\View\View + * + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + */ + public function view(int $nest): View + { + return view('admin.nests.view', [ + 'nest' => $this->repository->getWithEggServers($nest), + ]); + } + + /** + * Handle request to update a nest. + * + * @param \Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest $request + * @param int $nest + * + * @return \Illuminate\Http\RedirectResponse + * @throws \Pterodactyl\Exceptions\Model\DataValidationException + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + */ + public function update(StoreNestFormRequest $request, int $nest): RedirectResponse + { + $this->nestUpdateService->handle($nest, $request->normalize()); + $this->alert->success(trans('admin/nests.notices.updated'))->flash(); + + return redirect()->route('admin.nests.view', $nest); + } + + /** + * Handle request to delete a nest. + * + * @param \Pterodactyl\Models\Nest $nest + * @return \Illuminate\Http\RedirectResponse + * + * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException + */ + public function destroy($nest): RedirectResponse + { + $this->nestDeletionService->handle($nest); + $this->alert->success(trans('admin/nests.notices.deleted'))->flash(); + + return redirect()->route('admin.nests'); + } +} diff --git a/app/Http/Controllers/Admin/OptionController.php b/app/Http/Controllers/Admin/OptionController.php index 3919fe9bf..40e7b4f49 100644 --- a/app/Http/Controllers/Admin/OptionController.php +++ b/app/Http/Controllers/Admin/OptionController.php @@ -10,18 +10,18 @@ namespace Pterodactyl\Http\Controllers\Admin; use Javascript; +use Pterodactyl\Models\Egg; use Illuminate\Http\Request; use Prologue\Alerts\AlertsMessageBag; -use Pterodactyl\Models\ServiceOption; use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Http\Requests\Admin\Service\EditOptionScript; use Pterodactyl\Services\Services\Options\OptionUpdateService; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; use Pterodactyl\Services\Services\Options\OptionCreationService; use Pterodactyl\Services\Services\Options\OptionDeletionService; use Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest; use Pterodactyl\Services\Services\Options\InstallScriptUpdateService; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException; use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException; @@ -53,25 +53,25 @@ class OptionController extends Controller protected $optionUpdateService; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $serviceRepository; /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $serviceOptionRepository; /** * OptionController constructor. * - * @param \Prologue\Alerts\AlertsMessageBag $alert - * @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService - * @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService - * @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService - * @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $serviceOptionRepository + * @param \Prologue\Alerts\AlertsMessageBag $alert + * @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService + * @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService + * @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService + * @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $serviceOptionRepository */ public function __construct( AlertsMessageBag $alert, @@ -79,8 +79,8 @@ class OptionController extends Controller OptionCreationService $optionCreationService, OptionDeletionService $optionDeletionService, OptionUpdateService $optionUpdateService, - ServiceRepositoryInterface $serviceRepository, - ServiceOptionRepositoryInterface $serviceOptionRepository + NestRepositoryInterface $serviceRepository, + EggRepositoryInterface $serviceOptionRepository ) { $this->alert = $alert; $this->installScriptUpdateService = $installScriptUpdateService; @@ -129,12 +129,12 @@ class OptionController extends Controller /** * Delete a given option from the database. * - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Pterodactyl\Models\Egg $option * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ - public function destroy(ServiceOption $option) + public function destroy(Egg $option) { $this->optionDeletionService->handle($option->id); $this->alert->success(trans('admin/services.options.notices.option_deleted'))->flash(); @@ -145,10 +145,10 @@ class OptionController extends Controller /** * Display option overview page. * - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Pterodactyl\Models\Egg $option * @return \Illuminate\View\View */ - public function viewConfiguration(ServiceOption $option) + public function viewConfiguration(Egg $option) { return view('admin.services.options.view', ['option' => $option]); } @@ -181,14 +181,14 @@ class OptionController extends Controller /** * Handles POST when editing a configration for a service option. * - * @param \Illuminate\Http\Request $request - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Illuminate\Http\Request $request + * @param \Pterodactyl\Models\Egg $option * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function editConfiguration(Request $request, ServiceOption $option) + public function editConfiguration(Request $request, Egg $option) { try { $this->optionUpdateService->handle($option, $request->all()); @@ -204,13 +204,13 @@ class OptionController extends Controller * Handles POST when updating script for a service option. * * @param \Pterodactyl\Http\Requests\Admin\Service\EditOptionScript $request - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Pterodactyl\Models\Egg $option * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function updateScripts(EditOptionScript $request, ServiceOption $option) + public function updateScripts(EditOptionScript $request, Egg $option) { try { $this->installScriptUpdateService->handle($option, $request->normalize()); diff --git a/app/Http/Controllers/Admin/PackController.php b/app/Http/Controllers/Admin/PackController.php index 4ef6cbecf..e25e3d3b9 100644 --- a/app/Http/Controllers/Admin/PackController.php +++ b/app/Http/Controllers/Admin/PackController.php @@ -19,9 +19,9 @@ 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; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; class PackController extends Controller { @@ -61,7 +61,7 @@ class PackController extends Controller protected $updateService; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $serviceRepository; @@ -73,15 +73,15 @@ class PackController extends Controller /** * 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\ServiceRepositoryInterface $serviceRepository - * @param \Pterodactyl\Services\Packs\TemplateUploadService $templateUploadService + * @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, @@ -91,7 +91,7 @@ class PackController extends Controller PackDeletionService $deletionService, PackRepositoryInterface $repository, PackUpdateService $updateService, - ServiceRepositoryInterface $serviceRepository, + NestRepositoryInterface $serviceRepository, TemplateUploadService $templateUploadService ) { $this->alert = $alert; diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 529d692b3..0b46bb380 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -25,11 +25,11 @@ use Pterodactyl\Services\Servers\BuildModificationService; use Pterodactyl\Services\Database\DatabaseManagementService; use Pterodactyl\Services\Servers\DetailsModificationService; use Pterodactyl\Services\Servers\StartupModificationService; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Contracts\Repository\NodeRepositoryInterface; use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository; use Illuminate\Contracts\Config\Repository as ConfigRepository; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; @@ -112,7 +112,7 @@ class ServersController extends Controller protected $service; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $serviceRepository; @@ -144,7 +144,7 @@ class ServersController extends Controller * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository * @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository * @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService * @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService */ @@ -164,7 +164,7 @@ class ServersController extends Controller NodeRepositoryInterface $nodeRepository, ReinstallServerService $reinstallService, ServerRepositoryInterface $repository, - ServiceRepositoryInterface $serviceRepository, + NestRepositoryInterface $serviceRepository, StartupModificationService $startupModificationService, SuspensionService $suspensionService ) { diff --git a/app/Http/Controllers/Admin/ServiceController.php b/app/Http/Controllers/Admin/ServiceController.php index 72332c7b3..bdcfabaf2 100644 --- a/app/Http/Controllers/Admin/ServiceController.php +++ b/app/Http/Controllers/Admin/ServiceController.php @@ -10,15 +10,15 @@ namespace Pterodactyl\Http\Controllers\Admin; use Illuminate\View\View; -use Pterodactyl\Models\Service; +use Pterodactyl\Models\Nest; use Illuminate\Http\RedirectResponse; use Prologue\Alerts\AlertsMessageBag; use Pterodactyl\Http\Controllers\Controller; -use Pterodactyl\Services\Services\ServiceUpdateService; -use Pterodactyl\Services\Services\ServiceCreationService; -use Pterodactyl\Services\Services\ServiceDeletionService; -use Pterodactyl\Http\Requests\Admin\Service\ServiceFormRequest; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; +use Pterodactyl\Services\Services\NestUpdateService; +use Pterodactyl\Services\Services\NestCreationService; +use Pterodactyl\Services\Services\NestDeletionService; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; +use Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest; use Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest; class ServiceController extends Controller @@ -29,40 +29,40 @@ class ServiceController extends Controller protected $alert; /** - * @var \Pterodactyl\Services\Services\ServiceCreationService + * @var \Pterodactyl\Services\Services\NestCreationService */ protected $creationService; /** - * @var \Pterodactyl\Services\Services\ServiceDeletionService + * @var \Pterodactyl\Services\Services\NestDeletionService */ protected $deletionService; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $repository; /** - * @var \Pterodactyl\Services\Services\ServiceUpdateService + * @var \Pterodactyl\Services\Services\NestUpdateService */ protected $updateService; /** * ServiceController constructor. * - * @param \Prologue\Alerts\AlertsMessageBag $alert - * @param \Pterodactyl\Services\Services\ServiceCreationService $creationService - * @param \Pterodactyl\Services\Services\ServiceDeletionService $deletionService - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $repository - * @param \Pterodactyl\Services\Services\ServiceUpdateService $updateService + * @param \Prologue\Alerts\AlertsMessageBag $alert + * @param \Pterodactyl\Services\Services\NestCreationService $creationService + * @param \Pterodactyl\Services\Services\NestDeletionService $deletionService + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository + * @param \Pterodactyl\Services\Services\NestUpdateService $updateService */ public function __construct( AlertsMessageBag $alert, - ServiceCreationService $creationService, - ServiceDeletionService $deletionService, - ServiceRepositoryInterface $repository, - ServiceUpdateService $updateService + NestCreationService $creationService, + NestDeletionService $deletionService, + NestRepositoryInterface $repository, + NestUpdateService $updateService ) { $this->alert = $alert; $this->creationService = $creationService; @@ -109,10 +109,10 @@ class ServiceController extends Controller /** * Return function editing view for a service. * - * @param \Pterodactyl\Models\Service $service + * @param \Pterodactyl\Models\Nest $service * @return \Illuminate\View\View */ - public function viewFunctions(Service $service): View + public function viewFunctions(Nest $service): View { return view('admin.services.functions', ['service' => $service]); } @@ -120,12 +120,12 @@ class ServiceController extends Controller /** * Handle post action for new service. * - * @param \Pterodactyl\Http\Requests\Admin\Service\ServiceFormRequest $request + * @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function store(ServiceFormRequest $request): RedirectResponse + public function store(StoreNestFormRequest $request): RedirectResponse { $service = $this->creationService->handle($request->normalize()); $this->alert->success(trans('admin/services.notices.service_created', ['name' => $service->name]))->flash(); @@ -136,14 +136,14 @@ class ServiceController extends Controller /** * Edits configuration for a specific service. * - * @param \Pterodactyl\Http\Requests\Admin\Service\ServiceFormRequest $request - * @param \Pterodactyl\Models\Service $service + * @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request + * @param \Pterodactyl\Models\Nest $service * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function update(ServiceFormRequest $request, Service $service): RedirectResponse + public function update(StoreNestFormRequest $request, Nest $service): RedirectResponse { $this->updateService->handle($service->id, $request->normalize()); $this->alert->success(trans('admin/services.notices.service_updated'))->flash(); @@ -155,13 +155,13 @@ class ServiceController extends Controller * Update the functions file for a service. * * @param \Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest $request - * @param \Pterodactyl\Models\Service $service + * @param \Pterodactyl\Models\Nest $service * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function updateFunctions(ServiceFunctionsFormRequest $request, Service $service): RedirectResponse + public function updateFunctions(ServiceFunctionsFormRequest $request, Nest $service): RedirectResponse { $this->updateService->handle($service->id, $request->normalize()); $this->alert->success(trans('admin/services.notices.functions_updated'))->flash(); @@ -172,12 +172,12 @@ class ServiceController extends Controller /** * Delete a service from the panel. * - * @param \Pterodactyl\Models\Service $service + * @param \Pterodactyl\Models\Nest $service * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ - public function destroy(Service $service): RedirectResponse + public function destroy(Nest $service): RedirectResponse { $this->deletionService->handle($service->id); $this->alert->success(trans('admin/services.notices.service_deleted'))->flash(); diff --git a/app/Http/Controllers/Admin/VariableController.php b/app/Http/Controllers/Admin/VariableController.php index 786dd756b..dc62ee71f 100644 --- a/app/Http/Controllers/Admin/VariableController.php +++ b/app/Http/Controllers/Admin/VariableController.php @@ -9,15 +9,15 @@ namespace Pterodactyl\Http\Controllers\Admin; +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\EggVariable; use Prologue\Alerts\AlertsMessageBag; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest; use Pterodactyl\Repositories\Eloquent\ServiceVariableRepository; use Pterodactyl\Services\Services\Variables\VariableUpdateService; use Pterodactyl\Services\Services\Variables\VariableCreationService; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; class VariableController extends Controller { @@ -32,7 +32,7 @@ class VariableController extends Controller protected $creationService; /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $serviceOptionRepository; @@ -48,7 +48,7 @@ class VariableController extends Controller public function __construct( AlertsMessageBag $alert, - ServiceOptionRepositoryInterface $serviceOptionRepository, + EggRepositoryInterface $serviceOptionRepository, ServiceVariableRepository $serviceVariableRepository, VariableCreationService $creationService, VariableUpdateService $updateService @@ -64,13 +64,13 @@ class VariableController extends Controller * Handles POST request to create a new option variable. * * @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request - * @param \Pterodactyl\Models\ServiceOption $option + * @param \Pterodactyl\Models\Egg $option * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException */ - public function store(OptionVariableFormRequest $request, ServiceOption $option) + public function store(OptionVariableFormRequest $request, Egg $option) { $this->creationService->handle($option->id, $request->normalize()); $this->alert->success(trans('admin/services.variables.notices.variable_created'))->flash(); @@ -95,8 +95,8 @@ class VariableController extends Controller * Handles POST when editing a configration for a service variable. * * @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request - * @param \Pterodactyl\Models\ServiceOption $option - * @param \Pterodactyl\Models\ServiceVariable $variable + * @param \Pterodactyl\Models\Egg $option + * @param \Pterodactyl\Models\EggVariable $variable * @return \Illuminate\Http\RedirectResponse * * @throws \Pterodactyl\Exceptions\DisplayException @@ -104,7 +104,7 @@ class VariableController extends Controller * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException */ - public function update(OptionVariableFormRequest $request, ServiceOption $option, ServiceVariable $variable) + public function update(OptionVariableFormRequest $request, Egg $option, EggVariable $variable) { $this->updateService->handle($variable, $request->normalize()); $this->alert->success(trans('admin/services.variables.notices.variable_updated', [ @@ -117,11 +117,11 @@ class VariableController extends Controller /** * Delete a service variable from the system. * - * @param \Pterodactyl\Models\ServiceOption $option - * @param \Pterodactyl\Models\ServiceVariable $variable + * @param \Pterodactyl\Models\Egg $option + * @param \Pterodactyl\Models\EggVariable $variable * @return \Illuminate\Http\RedirectResponse */ - public function delete(ServiceOption $option, ServiceVariable $variable) + public function delete(Egg $option, EggVariable $variable) { $this->serviceVariableRepository->delete($variable->id); $this->alert->success(trans('admin/services.variables.notices.variable_deleted', [ diff --git a/app/Http/Controllers/Daemon/ServiceController.php b/app/Http/Controllers/Daemon/ServiceController.php index 62f379395..e37f76dac 100644 --- a/app/Http/Controllers/Daemon/ServiceController.php +++ b/app/Http/Controllers/Daemon/ServiceController.php @@ -9,9 +9,9 @@ namespace Pterodactyl\Http\Controllers\Daemon; +use Pterodactyl\Models\Egg; use Illuminate\Http\Request; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; +use Pterodactyl\Models\Nest; use Pterodactyl\Http\Controllers\Controller; class ServiceController extends Controller @@ -27,7 +27,7 @@ class ServiceController extends Controller public function listServices(Request $request) { $response = []; - foreach (Service::all() as $service) { + foreach (Nest::all() as $service) { $response[$service->folder] = [ 'main.json' => sha1($this->getConfiguration($service->id)->toJson()), 'index.js' => sha1($service->index_file), @@ -47,7 +47,7 @@ class ServiceController extends Controller */ public function pull(Request $request, $folder, $file) { - $service = Service::where('folder', $folder)->firstOrFail(); + $service = Nest::where('folder', $folder)->firstOrFail(); if ($file === 'index.js') { return response($service->index_file)->header('Content-Type', 'text/plain'); @@ -67,7 +67,7 @@ class ServiceController extends Controller */ protected function getConfiguration($id) { - $options = ServiceOption::where('service_id', $id)->get(); + $options = Egg::where('service_id', $id)->get(); return $options->mapWithKeys(function ($item) use ($options) { return [ diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index acaf582f4..9b4208319 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -54,7 +54,7 @@ class ServerController extends Controller $this->authorize('view-startup', $server); $server->load(['node', 'allocation', 'variables']); - $variables = Models\ServiceVariable::where('option_id', $server->option_id)->get(); + $variables = Models\EggVariable::where('option_id', $server->option_id)->get(); $replacements = [ '{{SERVER_MEMORY}}' => $server->memory, diff --git a/app/Http/Requests/Admin/Service/ServiceFormRequest.php b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php similarity index 76% rename from app/Http/Requests/Admin/Service/ServiceFormRequest.php rename to app/Http/Requests/Admin/Nest/StoreNestFormRequest.php index e469ecd54..56255e558 100644 --- a/app/Http/Requests/Admin/Service/ServiceFormRequest.php +++ b/app/Http/Requests/Admin/Nest/StoreNestFormRequest.php @@ -7,11 +7,11 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Http\Requests\Admin\Service; +namespace Pterodactyl\Http\Requests\Admin\Nest; use Pterodactyl\Http\Requests\Admin\AdminFormRequest; -class ServiceFormRequest extends AdminFormRequest +class StoreNestFormRequest extends AdminFormRequest { /** * @return array @@ -21,7 +21,6 @@ class ServiceFormRequest extends AdminFormRequest return [ 'name' => 'required|string|min:1|max:255', 'description' => 'required|nullable|string', - 'startup' => 'required|nullable|string', ]; } } diff --git a/app/Http/Requests/Admin/Service/OptionVariableFormRequest.php b/app/Http/Requests/Admin/Service/OptionVariableFormRequest.php index 54d8914e8..2076e8da5 100644 --- a/app/Http/Requests/Admin/Service/OptionVariableFormRequest.php +++ b/app/Http/Requests/Admin/Service/OptionVariableFormRequest.php @@ -9,7 +9,7 @@ namespace Pterodactyl\Http\Requests\Admin; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; class OptionVariableFormRequest extends AdminFormRequest { @@ -21,7 +21,7 @@ class OptionVariableFormRequest extends AdminFormRequest return [ 'name' => 'required|string|min:1|max:255', 'description' => 'sometimes|nullable|string', - 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . ServiceVariable::RESERVED_ENV_NAMES, + 'env_variable' => 'required|regex:/^[\w]{1,255}$/|notIn:' . EggVariable::RESERVED_ENV_NAMES, 'default_value' => 'string', 'options' => 'sometimes|required|array', 'rules' => 'bail|required|string', diff --git a/app/Http/Requests/Admin/Service/ServiceOptionFormRequest.php b/app/Http/Requests/Admin/Service/ServiceOptionFormRequest.php index 3099ac92d..065fef0f5 100644 --- a/app/Http/Requests/Admin/Service/ServiceOptionFormRequest.php +++ b/app/Http/Requests/Admin/Service/ServiceOptionFormRequest.php @@ -9,7 +9,7 @@ namespace Pterodactyl\Http\Requests\Admin\Service; -use Pterodactyl\Models\ServiceOption; +use Pterodactyl\Models\Egg; use Pterodactyl\Http\Requests\Admin\AdminFormRequest; class ServiceOptionFormRequest extends AdminFormRequest @@ -19,6 +19,6 @@ class ServiceOptionFormRequest extends AdminFormRequest */ public function rules() { - return ServiceOption::getCreateRules(); + return Egg::getCreateRules(); } } diff --git a/app/Models/ServiceOption.php b/app/Models/Egg.php similarity index 77% rename from app/Models/ServiceOption.php rename to app/Models/Egg.php index e424227fc..fd8740840 100644 --- a/app/Models/ServiceOption.php +++ b/app/Models/Egg.php @@ -15,7 +15,7 @@ use Illuminate\Database\Eloquent\Model; use Sofa\Eloquence\Contracts\CleansAttributes; use Sofa\Eloquence\Contracts\Validable as ValidableContract; -class ServiceOption extends Model implements CleansAttributes, ValidableContract +class Egg extends Model implements CleansAttributes, ValidableContract { use Eloquence, Validable; @@ -24,7 +24,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract * * @var string */ - protected $table = 'service_options'; + protected $table = 'eggs'; /** * Fields that are not mass assignable. @@ -67,9 +67,8 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract 'service_id' => 'required', 'name' => 'required', 'description' => 'required', - 'tag' => 'required', - 'docker_image' => 'sometimes', - 'startup' => 'sometimes', + 'docker_image' => 'required', + 'startup' => 'required', 'config_from' => 'sometimes', 'config_stop' => 'required_without:config_from', 'config_startup' => 'required_without:config_from', @@ -85,7 +84,6 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract 'uuid' => 'string|size:36', 'name' => 'string|max:255', 'description' => 'string', - 'tag' => 'bail|string|max:150', 'docker_image' => 'string|max:255', 'startup' => 'nullable|string', 'config_from' => 'bail|nullable|numeric|exists:service_options,id', @@ -103,12 +101,10 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract 'config_startup' => null, 'config_logs' => null, 'config_files' => null, - 'startup' => null, - 'docker_image' => null, ]; /** - * Returns the install script for the option; if option is copying from another + * Returns the install script for the egg; if egg is copying from another * it will return the copied script. * * @return string @@ -119,7 +115,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Returns the entry command for the option; if option is copying from another + * Returns the entry command for the egg; if egg is copying from another * it will return the copied entry command. * * @return string @@ -130,7 +126,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Returns the install container for the option; if option is copying from another + * Returns the install container for the egg; if egg is copying from another * it will return the copied install container. * * @return string @@ -141,7 +137,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Return the file configuration for a service option. + * Return the file configuration for an egg. * * @return string */ @@ -151,7 +147,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Return the startup configuration for a service option. + * Return the startup configuration for an egg. * * @return string */ @@ -161,7 +157,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Return the log reading configuration for a service option. + * Return the log reading configuration for an egg. * * @return string */ @@ -171,7 +167,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Return the stop command configuration for a service option. + * Return the stop command configuration for an egg. * * @return string */ @@ -181,47 +177,47 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Gets service associated with a service option. + * Gets nest associated with an egg. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function service() + public function nest() { - return $this->belongsTo(Service::class); + return $this->belongsTo(Nest::class); } /** - * Gets all servers associated with this service option. + * Gets all servers associated with this egg. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function servers() { - return $this->hasMany(Server::class, 'option_id'); + return $this->hasMany(Server::class, 'egg_id'); } /** - * Gets all variables associated with this service. + * Gets all variables associated with this egg. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function variables() { - return $this->hasMany(ServiceVariable::class, 'option_id'); + return $this->hasMany(EggVariable::class, 'egg_id'); } /** - * Gets all packs associated with this service. + * Gets all packs associated with this egg. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function packs() { - return $this->hasMany(Pack::class, 'option_id'); + return $this->hasMany(Pack::class, 'egg_id'); } /** - * Get the parent service option from which to copy scripts. + * Get the parent egg from which to copy scripts. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -231,7 +227,7 @@ class ServiceOption extends Model implements CleansAttributes, ValidableContract } /** - * Get the parent service option from which to copy configuration settings. + * Get the parent egg from which to copy configuration settings. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/ServiceVariable.php b/app/Models/EggVariable.php similarity index 86% rename from app/Models/ServiceVariable.php rename to app/Models/EggVariable.php index 52d475107..5341dd0dd 100644 --- a/app/Models/ServiceVariable.php +++ b/app/Models/EggVariable.php @@ -15,7 +15,7 @@ use Illuminate\Database\Eloquent\Model; use Sofa\Eloquence\Contracts\CleansAttributes; use Sofa\Eloquence\Contracts\Validable as ValidableContract; -class ServiceVariable extends Model implements CleansAttributes, ValidableContract +class EggVariable extends Model implements CleansAttributes, ValidableContract { use Eloquence, Validable; @@ -31,7 +31,7 @@ class ServiceVariable extends Model implements CleansAttributes, ValidableContra * * @var string */ - protected $table = 'service_variables'; + protected $table = 'egg_variables'; /** * Fields that are not mass assignable. @@ -46,7 +46,7 @@ class ServiceVariable extends Model implements CleansAttributes, ValidableContra * @var array */ protected $casts = [ - 'option_id' => 'integer', + 'egg_id' => 'integer', 'user_viewable' => 'integer', 'user_editable' => 'integer', ]; @@ -64,7 +64,7 @@ class ServiceVariable extends Model implements CleansAttributes, ValidableContra * @var array */ protected static $dataIntegrityRules = [ - 'option_id' => 'exists:service_options,id', + 'egg_id' => 'exists:eggs,id', 'name' => 'string|between:1,255', 'description' => 'nullable|string', 'env_variable' => 'regex:/^[\w]{1,255}$/|notIn:' . self::RESERVED_ENV_NAMES, @@ -83,9 +83,6 @@ class ServiceVariable extends Model implements CleansAttributes, ValidableContra ]; /** - * Returns the display executable for the option and will use the parent - * service one if the option does not have one defined. - * * @return bool */ public function getRequiredAttribute($value) diff --git a/app/Models/Service.php b/app/Models/Nest.php similarity index 75% rename from app/Models/Service.php rename to app/Models/Nest.php index e6c69bede..1be898c05 100644 --- a/app/Models/Service.php +++ b/app/Models/Nest.php @@ -15,7 +15,7 @@ use Illuminate\Database\Eloquent\Model; use Sofa\Eloquence\Contracts\CleansAttributes; use Sofa\Eloquence\Contracts\Validable as ValidableContract; -class Service extends Model implements CleansAttributes, ValidableContract +class Nest extends Model implements CleansAttributes, ValidableContract { use Eloquence, Validable; @@ -24,7 +24,7 @@ class Service extends Model implements CleansAttributes, ValidableContract * * @var string */ - protected $table = 'services'; + protected $table = 'nests'; /** * Fields that are mass assignable. @@ -55,27 +55,27 @@ class Service extends Model implements CleansAttributes, ValidableContract ]; /** - * Gets all service options associated with this service. + * Gets all eggs associated with this service. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function options() + public function eggs() { - return $this->hasMany(ServiceOption::class); + return $this->hasMany(Egg::class); } /** - * Returns all of the packs associated with a service, regardless of the service option. + * 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, ServiceOption::class, 'service_id', 'option_id'); + return $this->hasManyThrough(Pack::class, Egg::class, 'nest_id', 'egg_id'); } /** - * Gets all servers associated with this service. + * Gets all servers associated with this nest. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Models/Pack.php b/app/Models/Pack.php index a16c0336d..960199680 100644 --- a/app/Models/Pack.php +++ b/app/Models/Pack.php @@ -47,7 +47,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract 'selectable' => 'sometimes|required', 'visible' => 'sometimes|required', 'locked' => 'sometimes|required', - 'option_id' => 'required', + 'egg_id' => 'required', ]; /** @@ -60,7 +60,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract 'selectable' => 'boolean', 'visible' => 'boolean', 'locked' => 'boolean', - 'option_id' => 'exists:service_options,id', + 'egg_id' => 'exists:eggs,id', ]; /** @@ -69,7 +69,7 @@ class Pack extends Model implements CleansAttributes, ValidableContract * @var array */ protected $casts = [ - 'option_id' => 'integer', + 'egg_id' => 'integer', 'selectable' => 'boolean', 'visible' => 'boolean', 'locked' => 'boolean', @@ -83,9 +83,8 @@ class Pack extends Model implements CleansAttributes, ValidableContract protected $searchableColumns = [ 'name' => 10, 'uuid' => 8, - 'option.name' => 6, - 'option.tag' => 5, - 'option.docker_image' => 5, + 'egg.name' => 6, + 'egg.docker_image' => 5, 'version' => 2, ]; @@ -114,13 +113,13 @@ class Pack extends Model implements CleansAttributes, ValidableContract } /** - * Gets option associated with a service pack. + * Gets egg associated with a service pack. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function option() + public function egg() { - return $this->belongsTo(ServiceOption::class); + return $this->belongsTo(Egg::class); } /** diff --git a/app/Models/Server.php b/app/Models/Server.php index 9657296c2..09563baf1 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -68,8 +68,8 @@ class Server extends Model implements CleansAttributes, ValidableContract 'io' => 'required', 'cpu' => 'required', 'disk' => 'required', - 'service_id' => 'required', - 'option_id' => 'required', + 'nest_id' => 'required', + 'egg_id' => 'required', 'node_id' => 'required', 'allocation_id' => 'required', 'pack_id' => 'sometimes', @@ -92,8 +92,8 @@ class Server extends Model implements CleansAttributes, ValidableContract 'cpu' => 'numeric|min:0', 'disk' => 'numeric|min:0', 'allocation_id' => 'exists:allocations,id', - 'service_id' => 'exists:services,id', - 'option_id' => 'exists:service_options,id', + 'nest_id' => 'exists:nests,id', + 'egg_id' => 'exists:eggs,id', 'pack_id' => 'nullable|numeric|min:0', 'custom_container' => 'nullable|string', 'startup' => 'nullable|string', @@ -119,8 +119,8 @@ class Server extends Model implements CleansAttributes, ValidableContract 'cpu' => 'integer', 'oom_disabled' => 'integer', 'allocation_id' => 'integer', - 'service_id' => 'integer', - 'option_id' => 'integer', + 'nest_id' => 'integer', + 'egg_id' => 'integer', 'pack_id' => 'integer', 'installed' => 'integer', ]; @@ -202,23 +202,23 @@ class Server extends Model implements CleansAttributes, ValidableContract } /** - * Gets information for the service associated with this server. + * Gets information for the nest associated with this server. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function service() + public function nest() { - return $this->belongsTo(Service::class); + return $this->belongsTo(Nest::class); } /** - * Gets information for the service option associated with this server. + * Gets information for the egg associated with this server. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function option() + public function egg() { - return $this->belongsTo(ServiceOption::class); + return $this->belongsTo(Egg::class); } /** diff --git a/app/Models/ServerVariable.php b/app/Models/ServerVariable.php index 758044e4e..a17683ed6 100644 --- a/app/Models/ServerVariable.php +++ b/app/Models/ServerVariable.php @@ -74,6 +74,6 @@ class ServerVariable extends Model */ public function variable() { - return $this->belongsTo(ServiceVariable::class, 'variable_id'); + return $this->belongsTo(EggVariable::class, 'variable_id'); } } diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 4582b511c..bc393a883 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -12,6 +12,8 @@ namespace Pterodactyl\Providers; use Illuminate\Support\ServiceProvider; use Pterodactyl\Repositories\Daemon\FileRepository; use Pterodactyl\Repositories\Daemon\PowerRepository; +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; @@ -19,7 +21,6 @@ use Pterodactyl\Repositories\Eloquent\UserRepository; use Pterodactyl\Repositories\Daemon\CommandRepository; use Pterodactyl\Repositories\Eloquent\ApiKeyRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository; -use Pterodactyl\Repositories\Eloquent\ServiceRepository; use Pterodactyl\Repositories\Eloquent\SessionRepository; use Pterodactyl\Repositories\Eloquent\SubuserRepository; use Pterodactyl\Repositories\Eloquent\DatabaseRepository; @@ -28,22 +29,21 @@ use Pterodactyl\Repositories\Eloquent\ScheduleRepository; use Pterodactyl\Repositories\Eloquent\DaemonKeyRepository; use Pterodactyl\Repositories\Eloquent\AllocationRepository; use Pterodactyl\Repositories\Eloquent\PermissionRepository; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Repositories\Daemon\ConfigurationRepository; +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; use Pterodactyl\Repositories\Eloquent\ApiPermissionRepository; -use Pterodactyl\Repositories\Eloquent\ServiceOptionRepository; use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; -use Pterodactyl\Repositories\Eloquent\OptionVariableRepository; use Pterodactyl\Repositories\Eloquent\ServerVariableRepository; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; use Pterodactyl\Contracts\Repository\SessionRepositoryInterface; use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface; -use Pterodactyl\Repositories\Eloquent\ServiceVariableRepository; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface; @@ -51,14 +51,12 @@ use Pterodactyl\Contracts\Repository\DaemonKeyRepositoryInterface; use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; use Pterodactyl\Contracts\Repository\PermissionRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\FileRepositoryInterface; +use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\PowerRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface; use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\CommandRepositoryInterface; -use Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface; use Pterodactyl\Repositories\Daemon\ServerRepository as DaemonServerRepository; use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface as DaemonServerRepositoryInterface; @@ -77,17 +75,16 @@ class RepositoryServiceProvider extends ServiceProvider $this->app->bind(DaemonKeyRepositoryInterface::class, DaemonKeyRepository::class); $this->app->bind(DatabaseRepositoryInterface::class, DatabaseRepository::class); $this->app->bind(DatabaseHostRepositoryInterface::class, DatabaseHostRepository::class); + $this->app->bind(EggRepositoryInterface::class, EggRepository::class); + $this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class); $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class); + $this->app->bind(NestRepositoryInterface::class, NestRepository::class); $this->app->bind(NodeRepositoryInterface::class, NodeRepository::class); - $this->app->bind(OptionVariableRepositoryInterface::class, OptionVariableRepository::class); $this->app->bind(PackRepositoryInterface::class, PackRepository::class); $this->app->bind(PermissionRepositoryInterface::class, PermissionRepository::class); $this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class); $this->app->bind(ServerRepositoryInterface::class, ServerRepository::class); $this->app->bind(ServerVariableRepositoryInterface::class, ServerVariableRepository::class); - $this->app->bind(ServiceRepositoryInterface::class, ServiceRepository::class); - $this->app->bind(ServiceOptionRepositoryInterface::class, ServiceOptionRepository::class); - $this->app->bind(ServiceVariableRepositoryInterface::class, ServiceVariableRepository::class); $this->app->bind(SessionRepositoryInterface::class, SessionRepository::class); $this->app->bind(SubuserRepositoryInterface::class, SubuserRepository::class); $this->app->bind(TaskRepositoryInterface::class, TaskRepository::class); diff --git a/app/Repositories/Eloquent/ServiceOptionRepository.php b/app/Repositories/Eloquent/EggRepository.php similarity index 68% rename from app/Repositories/Eloquent/ServiceOptionRepository.php rename to app/Repositories/Eloquent/EggRepository.php index 852726e52..c1fcc583f 100644 --- a/app/Repositories/Eloquent/ServiceOptionRepository.php +++ b/app/Repositories/Eloquent/EggRepository.php @@ -9,33 +9,33 @@ namespace Pterodactyl\Repositories\Eloquent; +use Pterodactyl\Models\Egg; use Webmozart\Assert\Assert; -use Pterodactyl\Models\ServiceOption; use Illuminate\Database\Eloquent\Collection; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Exceptions\Repository\RecordNotFoundException; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; -class ServiceOptionRepository extends EloquentRepository implements ServiceOptionRepositoryInterface +class EggRepository extends EloquentRepository implements EggRepositoryInterface { /** * {@inheritdoc} */ public function model() { - return ServiceOption::class; + return Egg::class; } /** - * Return a service option with the variables relation attached. + * Return an egg with the variables relation attached. * * @param int $id - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithVariables(int $id): ServiceOption + public function getWithVariables(int $id): Egg { - /** @var \Pterodactyl\Models\ServiceOption $instance */ + /** @var \Pterodactyl\Models\Egg $instance */ $instance = $this->getBuilder()->with('variables')->find($id, $this->getColumns()); if (! $instance) { throw new RecordNotFoundException; @@ -45,7 +45,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio } /** - * Return all of the service options and their relations to be used in the daemon API. + * Return all eggs and their relations to be used in the daemon API. * * @return \Illuminate\Database\Eloquent\Collection */ @@ -55,19 +55,19 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio } /** - * Return a service option with the scriptFrom and configFrom relations loaded onto the model. + * Return an egg with the scriptFrom and configFrom relations loaded onto the model. * * @param int|string $value * @param string $column - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithCopyAttributes($value, string $column = 'id'): ServiceOption + public function getWithCopyAttributes($value, string $column = 'id'): Egg { Assert::true((is_digit($value) || is_string($value)), 'First argument passed to getWithCopyAttributes must be an integer or string, received %s.'); - /** @var \Pterodactyl\Models\ServiceOption $instance */ + /** @var \Pterodactyl\Models\Egg $instance */ $instance = $this->getBuilder()->with('scriptFrom', 'configFrom')->where($column, '=', $value)->first($this->getColumns()); if (! $instance) { throw new RecordNotFoundException; @@ -80,13 +80,13 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio * Return all of the data needed to export a service. * * @param int $id - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithExportAttributes(int $id): ServiceOption + public function getWithExportAttributes(int $id): Egg { - /** @var \Pterodactyl\Models\ServiceOption $instance */ + /** @var \Pterodactyl\Models\Egg $instance */ $instance = $this->getBuilder()->with('scriptFrom', 'configFrom', 'variables')->find($id, $this->getColumns()); if (! $instance) { throw new RecordNotFoundException; @@ -96,7 +96,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio } /** - * Confirm a copy script belongs to the same service as the item trying to use it. + * Confirm a copy script belongs to the same nest as the item trying to use it. * * @param int $copyFromId * @param int $service @@ -106,7 +106,7 @@ class ServiceOptionRepository extends EloquentRepository implements ServiceOptio { return $this->getBuilder()->whereNull('copy_script_from') ->where('id', '=', $copyFromId) - ->where('service_id', '=', $service) + ->where('nest_id', '=', $service) ->exists(); } } diff --git a/app/Repositories/Eloquent/OptionVariableRepository.php b/app/Repositories/Eloquent/EggVariableRepository.php similarity index 57% rename from app/Repositories/Eloquent/OptionVariableRepository.php rename to app/Repositories/Eloquent/EggVariableRepository.php index ced324fdf..9fe1174b4 100644 --- a/app/Repositories/Eloquent/OptionVariableRepository.php +++ b/app/Repositories/Eloquent/EggVariableRepository.php @@ -9,16 +9,16 @@ namespace Pterodactyl\Repositories\Eloquent; -use Pterodactyl\Models\ServiceVariable; -use Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface; +use Pterodactyl\Models\EggVariable; +use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; -class OptionVariableRepository extends EloquentRepository implements OptionVariableRepositoryInterface +class EggVariableRepository extends EloquentRepository implements EggVariableRepositoryInterface { /** * {@inheritdoc} */ public function model() { - return ServiceVariable::class; + return EggVariable::class; } } diff --git a/app/Repositories/Eloquent/ServiceRepository.php b/app/Repositories/Eloquent/NestRepository.php similarity index 60% rename from app/Repositories/Eloquent/ServiceRepository.php rename to app/Repositories/Eloquent/NestRepository.php index 1a4fe659c..923186c26 100644 --- a/app/Repositories/Eloquent/ServiceRepository.php +++ b/app/Repositories/Eloquent/NestRepository.php @@ -9,31 +9,31 @@ namespace Pterodactyl\Repositories\Eloquent; -use Pterodactyl\Models\Service; +use Pterodactyl\Models\Nest; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Exceptions\Repository\RecordNotFoundException; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; -class ServiceRepository extends EloquentRepository implements ServiceRepositoryInterface +class NestRepository extends EloquentRepository implements NestRepositoryInterface { /** * {@inheritdoc} */ public function model() { - return Service::class; + return Nest::class; } /** - * Return a service or all services with their associated options, variables, and packs. + * Return a nest or all nests with their associated eggs, variables, and packs. * * @param int $id - * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Service + * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithOptions(int $id = null) + public function getWithEggs(int $id = null) { - $instance = $this->getBuilder()->with('options.packs', 'options.variables'); + $instance = $this->getBuilder()->with('eggs.packs', 'eggs.variables'); if (! is_null($id)) { $instance = $instance->find($id, $this->getColumns()); @@ -48,16 +48,16 @@ class ServiceRepository extends EloquentRepository implements ServiceRepositoryI } /** - * Return a service or all services and the count of options, packs, and servers for that service. + * Return a nest or all nests and the count of eggs, packs, and servers for that nest. * * @param int|null $id - * @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Service + * @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function getWithCounts(int $id = null) { - $instance = $this->getBuilder()->withCount(['options', 'packs', 'servers']); + $instance = $this->getBuilder()->withCount(['eggs', 'packs', 'servers']); if (! is_null($id)) { $instance = $instance->find($id, $this->getColumns()); @@ -72,21 +72,21 @@ class ServiceRepository extends EloquentRepository implements ServiceRepositoryI } /** - * Return a service along with its associated options and the servers relation on those options. + * Return a nest along with its associated eggs and the servers relation on those eggs. * * @param int $id - * @return \Pterodactyl\Models\Service + * @return \Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function getWithOptionServers(int $id): Service + public function getWithEggServers(int $id): Nest { - $instance = $this->getBuilder()->with('options.servers')->find($id, $this->getColumns()); + $instance = $this->getBuilder()->with('eggs.servers')->find($id, $this->getColumns()); if (! $instance) { throw new RecordNotFoundException; } - /* @var Service $instance */ + /* @var Nest $instance */ return $instance; } } diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php index 9b48fc1d0..b6a94ec46 100644 --- a/app/Repositories/Eloquent/NodeRepository.php +++ b/app/Repositories/Eloquent/NodeRepository.php @@ -116,7 +116,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa */ public function getNodeServers($id) { - $instance = $this->getBuilder()->with('servers.user', 'servers.service', 'servers.option') + $instance = $this->getBuilder()->with('servers.user', 'servers.nest', 'servers.egg') ->find($id, $this->getColumns()); if (! $instance) { diff --git a/app/Repositories/Eloquent/PackRepository.php b/app/Repositories/Eloquent/PackRepository.php index ba88852fe..b2c555512 100644 --- a/app/Repositories/Eloquent/PackRepository.php +++ b/app/Repositories/Eloquent/PackRepository.php @@ -75,11 +75,11 @@ class PackRepository extends EloquentRepository implements PackRepositoryInterfa /** * {@inheritdoc} */ - public function paginateWithOptionAndServerCount($paginate = 50) + public function paginateWithEggAndServerCount($paginate = 50) { Assert::integer($paginate, 'First argument passed to paginateWithOptionAndServerCount must be integer, received %s.'); - return $this->getBuilder()->with('option')->withCount('servers') + return $this->getBuilder()->with('egg')->withCount('servers') ->search($this->searchTerm) ->paginate($paginate, $this->getColumns()); } diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index 2443f6b25..4a0a153ce 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -47,7 +47,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt Assert::nullOrIntegerish($server, 'First argument passed to getDataForRebuild must be null or integer, received %s.'); Assert::nullOrIntegerish($node, 'Second argument passed to getDataForRebuild must be null or integer, received %s.'); - $instance = $this->getBuilder()->with('allocation', 'allocations', 'pack', 'option', 'node'); + $instance = $this->getBuilder()->with('allocation', 'allocations', 'pack', 'egg', 'node'); if (! is_null($server) && is_null($node)) { $instance = $instance->where('id', '=', $server); @@ -66,7 +66,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt { Assert::integerish($id, 'First argument passed to findWithVariables must be integer, received %s.'); - $instance = $this->getBuilder()->with('option.variables', 'variables') + $instance = $this->getBuilder()->with('egg.variables', 'variables') ->where($this->getModel()->getKeyName(), '=', $id) ->first($this->getColumns()); @@ -82,7 +82,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getVariablesWithValues($id, $returnWithObject = false) { - $instance = $this->getBuilder()->with('variables', 'option.variables') + $instance = $this->getBuilder()->with('variables', 'egg.variables') ->find($id, $this->getColumns()); if (! $instance) { @@ -90,7 +90,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt } $data = []; - $instance->option->variables->each(function ($item) use (&$data, $instance) { + $instance->egg->variables->each(function ($item) use (&$data, $instance) { $display = $instance->variables->where('variable_id', $item->id)->pluck('variable_value')->first(); $data[$item->env_variable] = $display ?? $item->default_value; @@ -111,7 +111,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getDataForCreation($id) { - $instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'option'])->find($id, $this->getColumns()); + $instance = $this->getBuilder()->with(['allocation', 'allocations', 'pack', 'egg'])->find($id, $this->getColumns()); if (! $instance) { throw new RecordNotFoundException(); } @@ -140,15 +140,15 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function getDaemonServiceData($id) { - $instance = $this->getBuilder()->with('option.service', 'pack')->find($id, $this->getColumns()); + $instance = $this->getBuilder()->with('egg.nest', 'pack')->find($id, $this->getColumns()); if (! $instance) { throw new RecordNotFoundException(); } return [ - 'type' => $instance->option->service->folder, - 'option' => $instance->option->tag, + 'type' => $instance->egg->nest->folder, + 'option' => $instance->egg->tag, 'pack' => (! is_null($instance->pack_id)) ? $instance->pack->uuid : null, ]; } @@ -211,7 +211,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt { Assert::stringNotEmpty($uuid, 'First argument passed to getByUuid must be a non-empty string, received %s.'); - $instance = $this->getBuilder()->with('service', 'node')->where(function ($query) use ($uuid) { + $instance = $this->getBuilder()->with('nest', 'node')->where(function ($query) use ($uuid) { $query->where('uuidShort', $uuid)->orWhere('uuid', $uuid); })->first($this->getColumns()); diff --git a/app/Repositories/Eloquent/ServiceVariableRepository.php b/app/Repositories/Eloquent/ServiceVariableRepository.php deleted file mode 100644 index 6ec798827..000000000 --- a/app/Repositories/Eloquent/ServiceVariableRepository.php +++ /dev/null @@ -1,24 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Repositories\Eloquent; - -use Pterodactyl\Models\ServiceVariable; -use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface; - -class ServiceVariableRepository extends EloquentRepository implements ServiceVariableRepositoryInterface -{ - /** - * {@inheritdoc} - */ - public function model() - { - return ServiceVariable::class; - } -} diff --git a/app/Services/Eggs/Sharing/EggExporterService.php b/app/Services/Eggs/Sharing/EggExporterService.php new file mode 100644 index 000000000..82d68fe36 --- /dev/null +++ b/app/Services/Eggs/Sharing/EggExporterService.php @@ -0,0 +1,76 @@ +. + * + * This software is licensed under the terms of the MIT license. + * https://opensource.org/licenses/MIT + */ + +namespace Pterodactyl\Services\Eggs\Sharing; + +use Carbon\Carbon; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; + +class EggExporterService +{ + /** + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface + */ + protected $repository; + + /** + * EggExporterService constructor. + * + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository + */ + public function __construct(EggRepositoryInterface $repository) + { + $this->repository = $repository; + } + + /** + * Return a JSON representation of an egg and its variables. + * + * @param int $egg + * @return string + * + * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException + */ + public function handle(int $egg): string + { + $egg = $this->repository->getWithExportAttributes($egg); + + $struct = [ + '_comment' => 'DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO', + 'meta' => [ + 'version' => 'PTDL_v1', + ], + 'exported_at' => Carbon::now()->toIso8601String(), + 'name' => $egg->name, + 'author' => $egg->author, + 'description' => $egg->description, + 'image' => $egg->docker_image, + 'config' => [ + 'files' => $egg->inherit_config_files, + 'startup' => $egg->inherit_config_startup, + 'logs' => $egg->inherit_config_logs, + 'stop' => $egg->inherit_config_stop, + ], + 'scripts' => [ + 'installation' => [ + 'script' => $egg->copy_script_install, + 'container' => $egg->copy_script_container, + 'entrypoint' => $egg->copy_script_entry, + ], + ], + 'variables' => $egg->variables->transform(function ($item) { + return collect($item->toArray())->except([ + 'id', 'egg_id', 'created_at', 'updated_at', + ])->toArray(); + }), + ]; + + return json_encode($struct, JSON_PRETTY_PRINT); + } +} diff --git a/app/Services/Services/Sharing/ServiceOptionImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php similarity index 54% rename from app/Services/Services/Sharing/ServiceOptionImporterService.php rename to app/Services/Eggs/Sharing/EggImporterService.php index 4061af285..95776808f 100644 --- a/app/Services/Services/Sharing/ServiceOptionImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -10,16 +10,15 @@ namespace Pterodactyl\Services\Services\Sharing; use Ramsey\Uuid\Uuid; +use Pterodactyl\Models\Egg; use Illuminate\Http\UploadedFile; -use Pterodactyl\Models\ServiceOption; use Illuminate\Database\ConnectionInterface; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface; -use Pterodactyl\Exceptions\Service\ServiceOption\DuplicateOptionTagException; +use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; -class ServiceOptionImporterService +class EggImporterService { /** * @var \Illuminate\Database\ConnectionInterface @@ -27,77 +26,71 @@ class ServiceOptionImporterService protected $connection; /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface + */ + protected $eggVariableRepository; + + /** + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $serviceRepository; /** - * @var \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface - */ - protected $serviceVariableRepository; - - /** - * XMLImporterService constructor. + * EggImporterService constructor. * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository - * @param \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface $serviceVariableRepository + * @param \Illuminate\Database\ConnectionInterface $connection + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $eggVariableRepository + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository */ public function __construct( ConnectionInterface $connection, - ServiceRepositoryInterface $serviceRepository, - ServiceOptionRepositoryInterface $repository, - ServiceVariableRepositoryInterface $serviceVariableRepository + EggRepositoryInterface $repository, + EggVariableRepositoryInterface $eggVariableRepository, + NestRepositoryInterface $serviceRepository ) { $this->connection = $connection; $this->repository = $repository; $this->serviceRepository = $serviceRepository; - $this->serviceVariableRepository = $serviceVariableRepository; + $this->eggVariableRepository = $eggVariableRepository; } /** - * Take an uploaded XML file and parse it into a new service option. + * Take an uploaded JSON file and parse it into a new egg. * * @param \Illuminate\Http\UploadedFile $file - * @param int $service - * @return \Pterodactyl\Models\ServiceOption + * @param int $nest + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException */ - public function handle(UploadedFile $file, int $service): ServiceOption + public function handle(UploadedFile $file, int $nest): Egg { if (! $file->isValid() || ! $file->isFile()) { - throw new InvalidFileUploadException(trans('exceptions.service.exporter.import_file_error')); + throw new InvalidFileUploadException(trans('exceptions.egg.importer.file_error')); } $parsed = json_decode($file->openFile()->fread($file->getSize())); if (object_get($parsed, 'meta.version') !== 'PTDL_v1') { - throw new InvalidFileUploadException(trans('exceptions.service.exporter.invalid_json_provided')); + throw new InvalidFileUploadException(trans('exceptions.egg.importer.invalid_json_provided')); } - $service = $this->serviceRepository->getWithOptions($service); - $service->options->each(function ($option) use ($parsed) { - if ($option->tag === object_get($parsed, 'tag')) { - throw new DuplicateOptionTagException(trans('exceptions.service.options.duplicate_tag')); - } - }); - + $nest = $this->serviceRepository->getWithEggs($nest); $this->connection->beginTransaction(); - $option = $this->repository->create([ + + $egg = $this->repository->create([ 'uuid' => Uuid::uuid4()->toString(), - 'service_id' => $service->id, + 'nest_id' => $nest->id, 'name' => object_get($parsed, 'name'), 'description' => object_get($parsed, 'description'), - 'tag' => object_get($parsed, 'tag'), 'docker_image' => object_get($parsed, 'image'), 'config_files' => object_get($parsed, 'config.files'), 'config_startup' => object_get($parsed, 'config.startup'), @@ -110,14 +103,14 @@ class ServiceOptionImporterService 'copy_script_from' => null, ], true, true); - collect($parsed->variables)->each(function ($variable) use ($option) { - $this->serviceVariableRepository->create(array_merge((array) $variable, [ - 'option_id' => $option->id, + collect($parsed->variables)->each(function ($variable) use ($egg) { + $this->eggVariableRepository->create(array_merge((array) $variable, [ + 'egg_id' => $egg->id, ])); }); $this->connection->commit(); - return $option; + return $egg; } } diff --git a/app/Services/Services/ServiceCreationService.php b/app/Services/Nests/NestCreationService.php similarity index 59% rename from app/Services/Services/ServiceCreationService.php rename to app/Services/Nests/NestCreationService.php index b0ddc62fb..797ad8a42 100644 --- a/app/Services/Services/ServiceCreationService.php +++ b/app/Services/Nests/NestCreationService.php @@ -7,59 +7,54 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Services\Services; +namespace Pterodactyl\Services\Nests; use Ramsey\Uuid\Uuid; -use Pterodactyl\Models\Service; -use Pterodactyl\Traits\Services\CreatesServiceIndex; +use Pterodactyl\Models\Nest; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Illuminate\Contracts\Config\Repository as ConfigRepository; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; -class ServiceCreationService +class NestCreationService { - use CreatesServiceIndex; - /** * @var \Illuminate\Contracts\Config\Repository */ protected $config; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $repository; /** - * ServiceCreationService constructor. + * NestCreationService constructor. * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $repository + * @param \Illuminate\Contracts\Config\Repository $config + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ public function __construct( ConfigRepository $config, - ServiceRepositoryInterface $repository + NestRepositoryInterface $repository ) { $this->config = $config; $this->repository = $repository; } /** - * Create a new service on the system. + * Create a new nest on the system. * * @param array $data - * @return \Pterodactyl\Models\Service + * @return \Pterodactyl\Models\Nest * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function handle(array $data): Service + public function handle(array $data): Nest { return $this->repository->create([ 'uuid' => Uuid::uuid4()->toString(), 'author' => $this->config->get('pterodactyl.service.author'), 'name' => array_get($data, 'name'), 'description' => array_get($data, 'description'), - 'startup' => array_get($data, 'startup'), - 'index_file' => $this->getIndexScript(), ], true, true); } } diff --git a/app/Services/Services/ServiceDeletionService.php b/app/Services/Nests/NestDeletionService.php similarity index 59% rename from app/Services/Services/ServiceDeletionService.php rename to app/Services/Nests/NestDeletionService.php index 0a88b1209..6bdaf8de2 100644 --- a/app/Services/Services/ServiceDeletionService.php +++ b/app/Services/Nests/NestDeletionService.php @@ -7,13 +7,13 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Services\Services; +namespace Pterodactyl\Services\Nests; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; use Pterodactyl\Exceptions\Service\HasActiveServersException; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; -class ServiceDeletionService +class NestDeletionService { /** * @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface @@ -21,39 +21,39 @@ class ServiceDeletionService protected $serverRepository; /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $repository; /** - * ServiceDeletionService constructor. + * NestDeletionService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ public function __construct( ServerRepositoryInterface $serverRepository, - ServiceRepositoryInterface $repository + NestRepositoryInterface $repository ) { $this->serverRepository = $serverRepository; $this->repository = $repository; } /** - * Delete a service from the system only if there are no servers attached to it. + * Delete a nest from the system only if there are no servers attached to it. * - * @param int $service + * @param int $nest * @return int * * @throws \Pterodactyl\Exceptions\Service\HasActiveServersException */ - public function handle(int $service): int + public function handle(int $nest): int { - $count = $this->serverRepository->findCountWhere([['service_id', '=', $service]]); + $count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]); if ($count > 0) { throw new HasActiveServersException(trans('exceptions.service.delete_has_servers')); } - return $this->repository->delete($service); + return $this->repository->delete($nest); } } diff --git a/app/Services/Services/ServiceUpdateService.php b/app/Services/Nests/NestUpdateService.php similarity index 50% rename from app/Services/Services/ServiceUpdateService.php rename to app/Services/Nests/NestUpdateService.php index c6f5e322f..12f3a506a 100644 --- a/app/Services/Services/ServiceUpdateService.php +++ b/app/Services/Nests/NestUpdateService.php @@ -7,41 +7,41 @@ * https://opensource.org/licenses/MIT */ -namespace Pterodactyl\Services\Services; +namespace Pterodactyl\Services\Nests; -use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface; +use Pterodactyl\Contracts\Repository\NestRepositoryInterface; -class ServiceUpdateService +class NestUpdateService { /** - * @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface */ protected $repository; /** - * ServiceUpdateService constructor. + * NestUpdateService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository */ - public function __construct(ServiceRepositoryInterface $repository) + public function __construct(NestRepositoryInterface $repository) { $this->repository = $repository; } /** - * Update a service and prevent changing the author once it is set. + * Update a nest and prevent changing the author once it is set. * - * @param int $service + * @param int $nest * @param array $data * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ - public function handle(int $service, array $data) + public function handle(int $nest, array $data) { if (! is_null(array_get($data, 'author'))) { unset($data['author']); } - $this->repository->withoutFresh()->update($service, $data); + $this->repository->withoutFresh()->update($nest, $data); } } diff --git a/app/Services/Servers/VariableValidatorService.php b/app/Services/Servers/VariableValidatorService.php index 6c9efe32b..e890bfb93 100644 --- a/app/Services/Servers/VariableValidatorService.php +++ b/app/Services/Servers/VariableValidatorService.php @@ -12,7 +12,7 @@ namespace Pterodactyl\Services\Servers; use Pterodactyl\Exceptions\DisplayValidationException; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Illuminate\Contracts\Validation\Factory as ValidationFactory; -use Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface; +use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; class VariableValidatorService @@ -33,7 +33,7 @@ class VariableValidatorService protected $results = []; /** - * @var \Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface */ protected $optionVariableRepository; @@ -55,13 +55,13 @@ class VariableValidatorService /** * VariableValidatorService constructor. * - * @param \Pterodactyl\Contracts\Repository\OptionVariableRepositoryInterface $optionVariableRepository + * @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $optionVariableRepository * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository * @param \Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface $serverVariableRepository * @param \Illuminate\Contracts\Validation\Factory $validator */ public function __construct( - OptionVariableRepositoryInterface $optionVariableRepository, + EggVariableRepositoryInterface $optionVariableRepository, ServerRepositoryInterface $serverRepository, ServerVariableRepositoryInterface $serverVariableRepository, ValidationFactory $validator diff --git a/app/Services/Services/Options/InstallScriptUpdateService.php b/app/Services/Services/Options/InstallScriptUpdateService.php index 7b302190e..1d5a9a920 100644 --- a/app/Services/Services/Options/InstallScriptUpdateService.php +++ b/app/Services/Services/Options/InstallScriptUpdateService.php @@ -9,23 +9,23 @@ namespace Pterodactyl\Services\Services\Options; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; +use Pterodactyl\Models\Egg; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException; class InstallScriptUpdateService { /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; /** * InstallScriptUpdateService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ - public function __construct(ServiceOptionRepositoryInterface $repository) + public function __construct(EggRepositoryInterface $repository) { $this->repository = $repository; } @@ -33,8 +33,8 @@ class InstallScriptUpdateService /** * Modify the option install script for a given service option. * - * @param int|\Pterodactyl\Models\ServiceOption $option - * @param array $data + * @param int|\Pterodactyl\Models\Egg $option + * @param array $data * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -42,7 +42,7 @@ class InstallScriptUpdateService */ public function handle($option, array $data) { - if (! $option instanceof ServiceOption) { + if (! $option instanceof Egg) { $option = $this->repository->find($option); } diff --git a/app/Services/Services/Options/OptionConfigurationFileService.php b/app/Services/Services/Options/OptionConfigurationFileService.php index c21f435dd..e8656fdba 100644 --- a/app/Services/Services/Options/OptionConfigurationFileService.php +++ b/app/Services/Services/Options/OptionConfigurationFileService.php @@ -9,8 +9,8 @@ namespace Pterodactyl\Services\Services\Options; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; +use Pterodactyl\Models\Egg; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; class OptionConfigurationFileService { @@ -19,9 +19,9 @@ class OptionConfigurationFileService /** * OptionConfigurationFileService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ - public function __construct(ServiceOptionRepositoryInterface $repository) + public function __construct(EggRepositoryInterface $repository) { $this->repository = $repository; } @@ -29,14 +29,14 @@ class OptionConfigurationFileService /** * Return a service configuration file to be used by the daemon. * - * @param int|\Pterodactyl\Models\ServiceOption $option + * @param int|\Pterodactyl\Models\Egg $option * @return array * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function handle($option): array { - if (! $option instanceof ServiceOption) { + if (! $option instanceof Egg) { $option = $this->repository->getWithCopyAttributes($option); } diff --git a/app/Services/Services/Options/OptionCreationService.php b/app/Services/Services/Options/OptionCreationService.php index 8149a5596..05f4c639e 100644 --- a/app/Services/Services/Options/OptionCreationService.php +++ b/app/Services/Services/Options/OptionCreationService.php @@ -10,9 +10,9 @@ namespace Pterodactyl\Services\Services\Options; use Ramsey\Uuid\Uuid; -use Pterodactyl\Models\ServiceOption; +use Pterodactyl\Models\Egg; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Illuminate\Contracts\Config\Repository as ConfigRepository; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException; class OptionCreationService @@ -23,17 +23,17 @@ class OptionCreationService protected $config; /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; /** * CreationService constructor. * - * @param \Illuminate\Contracts\Config\Repository $config - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Illuminate\Contracts\Config\Repository $config + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ - public function __construct(ConfigRepository $config, ServiceOptionRepositoryInterface $repository) + public function __construct(ConfigRepository $config, EggRepositoryInterface $repository) { $this->config = $config; $this->repository = $repository; @@ -43,12 +43,12 @@ class OptionCreationService * Create a new service option and assign it to the given service. * * @param array $data - * @return \Pterodactyl\Models\ServiceOption + * @return \Pterodactyl\Models\Egg * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException */ - public function handle(array $data): ServiceOption + public function handle(array $data): Egg { if (! is_null(array_get($data, 'config_from'))) { $results = $this->repository->findCountWhere([ diff --git a/app/Services/Services/Options/OptionDeletionService.php b/app/Services/Services/Options/OptionDeletionService.php index 626c9d756..35c60cb93 100644 --- a/app/Services/Services/Options/OptionDeletionService.php +++ b/app/Services/Services/Options/OptionDeletionService.php @@ -9,15 +9,15 @@ namespace Pterodactyl\Services\Services\Options; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Exceptions\Service\HasActiveServersException; use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException; class OptionDeletionService { /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; @@ -29,12 +29,12 @@ class OptionDeletionService /** * OptionDeletionService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ public function __construct( ServerRepositoryInterface $serverRepository, - ServiceOptionRepositoryInterface $repository + EggRepositoryInterface $repository ) { $this->repository = $repository; $this->serverRepository = $serverRepository; diff --git a/app/Services/Services/Options/OptionUpdateService.php b/app/Services/Services/Options/OptionUpdateService.php index 1d2109de5..1daaf14ae 100644 --- a/app/Services/Services/Options/OptionUpdateService.php +++ b/app/Services/Services/Options/OptionUpdateService.php @@ -9,23 +9,23 @@ namespace Pterodactyl\Services\Services\Options; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; +use Pterodactyl\Models\Egg; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException; class OptionUpdateService { /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $repository; /** * OptionUpdateService constructor. * - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository + * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository */ - public function __construct(ServiceOptionRepositoryInterface $repository) + public function __construct(EggRepositoryInterface $repository) { $this->repository = $repository; } @@ -33,8 +33,8 @@ class OptionUpdateService /** * Update a service option. * - * @param int|\Pterodactyl\Models\ServiceOption $option - * @param array $data + * @param int|\Pterodactyl\Models\Egg $option + * @param array $data * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -42,7 +42,7 @@ class OptionUpdateService */ public function handle($option, array $data) { - if (! $option instanceof ServiceOption) { + if (! $option instanceof Egg) { $option = $this->repository->find($option); } diff --git a/app/Services/Services/Sharing/ServiceOptionExporterService.php b/app/Services/Services/Sharing/ServiceOptionExporterService.php deleted file mode 100644 index 8f2d1ebf5..000000000 --- a/app/Services/Services/Sharing/ServiceOptionExporterService.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\Services\Sharing; - -use Carbon\Carbon; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; - -class ServiceOptionExporterService -{ - /** - * @var \Carbon\Carbon - */ - protected $carbon; - - /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface - */ - protected $repository; - - /** - * XMLExporterService constructor. - * - * @param \Carbon\Carbon $carbon - * @param \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface $repository - */ - public function __construct( - Carbon $carbon, - ServiceOptionRepositoryInterface $repository - ) { - $this->carbon = $carbon; - $this->repository = $repository; - } - - /** - * Return an XML structure to represent this service option. - * - * @param int $option - * @return string - * - * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException - */ - public function handle(int $option): string - { - $option = $this->repository->getWithExportAttributes($option); - - $struct = [ - '_comment' => 'DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO', - 'meta' => [ - 'version' => 'PTDL_v1', - ], - 'exported_at' => $this->carbon->now()->toIso8601String(), - 'name' => $option->name, - 'author' => array_get(explode(':', $option->tag), 0), - 'description' => $option->description, - 'image' => $option->docker_image, - 'config' => [ - 'files' => $option->inherit_config_files, - 'startup' => $option->inherit_config_startup, - 'logs' => $option->inherit_config_logs, - 'stop' => $option->inherit_config_stop, - ], - 'scripts' => [ - 'installation' => [ - 'script' => $option->copy_script_install, - 'container' => $option->copy_script_container, - 'entrypoint' => $option->copy_script_entry, - ], - ], - 'variables' => $option->variables->transform(function ($item) { - return collect($item->toArray())->except([ - 'id', 'option_id', 'created_at', 'updated_at', - ])->toArray(); - }), - ]; - - return json_encode($struct, JSON_PRETTY_PRINT); - } -} diff --git a/app/Services/Services/Variables/VariableCreationService.php b/app/Services/Services/Variables/VariableCreationService.php index 110224888..f6891df26 100644 --- a/app/Services/Services/Variables/VariableCreationService.php +++ b/app/Services/Services/Variables/VariableCreationService.php @@ -9,16 +9,16 @@ namespace Pterodactyl\Services\Services\Variables; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; -use Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface; +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\EggVariable; +use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException; class VariableCreationService { /** - * @var \Pterodactyl\Contracts\Repository\ServiceOptionRepositoryInterface + * @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface */ protected $serviceOptionRepository; @@ -28,7 +28,7 @@ class VariableCreationService protected $serviceVariableRepository; public function __construct( - ServiceOptionRepositoryInterface $serviceOptionRepository, + EggRepositoryInterface $serviceOptionRepository, ServiceVariableRepositoryInterface $serviceVariableRepository ) { $this->serviceOptionRepository = $serviceOptionRepository; @@ -38,20 +38,20 @@ class VariableCreationService /** * Create a new variable for a given service option. * - * @param int|\Pterodactyl\Models\ServiceOption $option - * @param array $data - * @return \Pterodactyl\Models\ServiceVariable + * @param int|\Pterodactyl\Models\Egg $option + * @param array $data + * @return \Pterodactyl\Models\EggVariable * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException */ public function handle($option, array $data) { - if ($option instanceof ServiceOption) { + if ($option instanceof Egg) { $option = $option->id; } - if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', ServiceVariable::RESERVED_ENV_NAMES))) { + if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { throw new ReservedVariableNameException(sprintf( 'Cannot use the protected name %s for this environment variable.', array_get($data, 'env_variable') diff --git a/app/Services/Services/Variables/VariableUpdateService.php b/app/Services/Services/Variables/VariableUpdateService.php index 08bb35dc0..28573785d 100644 --- a/app/Services/Services/Variables/VariableUpdateService.php +++ b/app/Services/Services/Variables/VariableUpdateService.php @@ -9,7 +9,7 @@ namespace Pterodactyl\Services\Services\Variables; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface; use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException; @@ -34,8 +34,8 @@ class VariableUpdateService /** * Update a specific service variable. * - * @param int|\Pterodactyl\Models\ServiceVariable $variable - * @param array $data + * @param int|\Pterodactyl\Models\EggVariable $variable + * @param array $data * @return mixed * * @throws \Pterodactyl\Exceptions\DisplayException @@ -45,12 +45,12 @@ class VariableUpdateService */ public function handle($variable, array $data) { - if (! $variable instanceof ServiceVariable) { + if (! $variable instanceof EggVariable) { $variable = $this->repository->find($variable); } if (! is_null(array_get($data, 'env_variable'))) { - if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', ServiceVariable::RESERVED_ENV_NAMES))) { + if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) { throw new ReservedVariableNameException(trans('exceptions.service.variables.reserved_name', [ 'name' => array_get($data, 'env_variable'), ])); diff --git a/app/Traits/Services/CreatesServiceIndex.php b/app/Traits/Services/CreatesServiceIndex.php deleted file mode 100644 index 13c925a8b..000000000 --- a/app/Traits/Services/CreatesServiceIndex.php +++ /dev/null @@ -1,56 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -namespace Pterodactyl\Traits\Services; - -trait CreatesServiceIndex -{ - /** - * Returns the default index.js file that is used for services on the daemon. - * - * @return string - */ - public function getIndexScript() - { - return <<<'EOF' -'use strict'; - -/** - * Pterodactyl - Daemon - * Copyright (c) 2015 - 2017 Dane Everitt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -const rfr = require('rfr'); -const _ = require('lodash'); - -const Core = rfr('src/services/index.js'); - -class Service extends Core {} - -module.exports = Service; -EOF; - } -} diff --git a/app/Transformers/Admin/OptionTransformer.php b/app/Transformers/Admin/OptionTransformer.php index d9af33c09..089f880ec 100644 --- a/app/Transformers/Admin/OptionTransformer.php +++ b/app/Transformers/Admin/OptionTransformer.php @@ -9,8 +9,8 @@ namespace Pterodactyl\Transformers\Admin; +use Pterodactyl\Models\Egg; use Illuminate\Http\Request; -use Pterodactyl\Models\ServiceOption; use League\Fractal\TransformerAbstract; class OptionTransformer extends TransformerAbstract @@ -53,7 +53,7 @@ class OptionTransformer extends TransformerAbstract * * @return array */ - public function transform(ServiceOption $option) + public function transform(Egg $option) { return $option->toArray(); } @@ -63,7 +63,7 @@ class OptionTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeService(ServiceOption $option) + public function includeService(Egg $option) { if ($this->request && ! $this->request->apiKeyHasPermission('service-view')) { return; @@ -77,7 +77,7 @@ class OptionTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includePacks(ServiceOption $option) + public function includePacks(Egg $option) { if ($this->request && ! $this->request->apiKeyHasPermission('pack-list')) { return; @@ -91,7 +91,7 @@ class OptionTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeServers(ServiceOption $option) + public function includeServers(Egg $option) { if ($this->request && ! $this->request->apiKeyHasPermission('server-list')) { return; @@ -105,7 +105,7 @@ class OptionTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeVariables(ServiceOption $option) + public function includeVariables(Egg $option) { if ($this->request && ! $this->request->apiKeyHasPermission('option-view')) { return; diff --git a/app/Transformers/Admin/ServiceTransformer.php b/app/Transformers/Admin/ServiceTransformer.php index 2fd4b79c4..5f8497cf7 100644 --- a/app/Transformers/Admin/ServiceTransformer.php +++ b/app/Transformers/Admin/ServiceTransformer.php @@ -10,7 +10,7 @@ namespace Pterodactyl\Transformers\Admin; use Illuminate\Http\Request; -use Pterodactyl\Models\Service; +use Pterodactyl\Models\Nest; use League\Fractal\TransformerAbstract; class ServiceTransformer extends TransformerAbstract @@ -52,7 +52,7 @@ class ServiceTransformer extends TransformerAbstract * * @return array */ - public function transform(Service $service) + public function transform(Nest $service) { return $service->toArray(); } @@ -62,7 +62,7 @@ class ServiceTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeOptions(Service $service) + public function includeOptions(Nest $service) { if ($this->request && ! $this->request->apiKeyHasPermission('option-list')) { return; @@ -76,7 +76,7 @@ class ServiceTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeServers(Service $service) + public function includeServers(Nest $service) { if ($this->request && ! $this->request->apiKeyHasPermission('server-list')) { return; @@ -90,7 +90,7 @@ class ServiceTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includePacks(Service $service) + public function includePacks(Nest $service) { if ($this->request && ! $this->request->apiKeyHasPermission('pack-list')) { return; diff --git a/app/Transformers/Admin/ServiceVariableTransformer.php b/app/Transformers/Admin/ServiceVariableTransformer.php index 507cf1bc8..49f5e449a 100644 --- a/app/Transformers/Admin/ServiceVariableTransformer.php +++ b/app/Transformers/Admin/ServiceVariableTransformer.php @@ -10,8 +10,8 @@ namespace Pterodactyl\Transformers\Admin; use Illuminate\Http\Request; +use Pterodactyl\Models\EggVariable; use League\Fractal\TransformerAbstract; -use Pterodactyl\Models\ServiceVariable; class ServiceVariableTransformer extends TransformerAbstract { @@ -48,7 +48,7 @@ class ServiceVariableTransformer extends TransformerAbstract * * @return array */ - public function transform(ServiceVariable $variable) + public function transform(EggVariable $variable) { return $variable->toArray(); } @@ -58,7 +58,7 @@ class ServiceVariableTransformer extends TransformerAbstract * * @return \Leauge\Fractal\Resource\Collection */ - public function includeVariables(ServiceVariable $variable) + public function includeVariables(EggVariable $variable) { if ($this->request && ! $this->request->apiKeyHasPermission('server-view')) { return; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 46895d70d..5be190075 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -88,7 +88,7 @@ $factory->define(Pterodactyl\Models\Node::class, function (Faker\Generator $fake ]; }); -$factory->define(Pterodactyl\Models\Service::class, function (Faker\Generator $faker) { +$factory->define(Pterodactyl\Models\Nest::class, function (Faker\Generator $faker) { return [ 'id' => $faker->unique()->randomNumber(), 'uuid' => $faker->unique()->uuid, @@ -98,7 +98,7 @@ $factory->define(Pterodactyl\Models\Service::class, function (Faker\Generator $f ]; }); -$factory->define(Pterodactyl\Models\ServiceOption::class, function (Faker\Generator $faker) { +$factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker) { return [ 'id' => $faker->unique()->randomNumber(), 'uuid' => $faker->unique()->uuid, @@ -109,7 +109,7 @@ $factory->define(Pterodactyl\Models\ServiceOption::class, function (Faker\Genera ]; }); -$factory->define(Pterodactyl\Models\ServiceVariable::class, function (Faker\Generator $faker) { +$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker\Generator $faker) { return [ 'id' => $faker->unique()->randomNumber(), 'name' => $faker->firstName, @@ -122,11 +122,11 @@ $factory->define(Pterodactyl\Models\ServiceVariable::class, function (Faker\Gene ]; }); -$factory->state(Pterodactyl\Models\ServiceVariable::class, 'viewable', function () { +$factory->state(Pterodactyl\Models\EggVariable::class, 'viewable', function () { return ['user_viewable' => 1]; }); -$factory->state(Pterodactyl\Models\ServiceVariable::class, 'editable', function () { +$factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () { return ['user_editable' => 1]; }); diff --git a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php index 2d6413ede..2918e1afd 100644 --- a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php +++ b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php @@ -1,6 +1,5 @@ get() as $option) { - $option->servers->each(function ($s) use ($option) { - $prepend = $option->display_executable; - $prepend = ($prepend === './ShooterGameServer') ? './ShooterGame/Binaries/Linux/ShooterGameServer' : $prepend; - $prepend = ($prepend === 'TerrariaServer.exe') ? 'mono TerrariaServer.exe' : $prepend; - - $s->startup = $prepend . ' ' . $s->startup; - - $container = $s->container; - if (starts_with($container, 'quay.io/pterodactyl/minecraft')) { - $s->container = 'quay.io/pterodactyl/core:java'; - } elseif (starts_with($container, 'quay.io/pterodactyl/srcds')) { - $s->container = 'quay.io/pterodactyl/core:source'; - } elseif (starts_with($container, 'quay.io/pterodactyl/voice')) { - $s->container = 'quay.io/pterodactyl/core:glibc'; - } elseif (starts_with($container, 'quay.io/pterodactyl/terraria')) { - $s->container = 'quay.io/pterodactyl/core:mono'; - } - - $s->save(); - }); - } - Schema::table('services', function (Blueprint $table) { $table->renameColumn('file', 'folder'); $table->dropColumn('executable'); diff --git a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php index ca92c2f69..039976352 100644 --- a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php +++ b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php @@ -6,8 +6,6 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; use Illuminate\Database\Migrations\Migration; class MigrateToNewServiceSystem extends Migration @@ -18,12 +16,12 @@ class MigrateToNewServiceSystem extends Migration public function up() { DB::transaction(function () { - $service = Service::where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); + $service = DB::table('services')->where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); if (! $service) { return; } - $options = ServiceOption::where('service_id', $service->id)->get(); + $options = DB::table('service_options')->where('service_id', $service->id)->get(); $options->each(function ($item) use ($options) { if ($item->tag === 'srcds' && $item->name === 'Insurgency') { $item->tag = 'insurgency'; diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index 7784083a1..21fa51465 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -1,7 +1,6 @@ get() as $variable) { $variable->rules = ($variable->required) ? 'required|regex:' . $variable->rules : 'regex:' . $variable->rules; $variable->save(); } @@ -39,7 +38,7 @@ class ChangeServiceVariablesValidationRules extends Migration }); DB::transaction(function () { - foreach (ServiceVariable::all() as $variable) { + foreach (DB::table('service_variables')->get() as $variable) { $variable->regex = str_replace(['required|regex:', 'regex:'], '', $variable->regex); $variable->save(); } diff --git a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php b/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php index 5d5a3d164..3628ba7a4 100644 --- a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php +++ b/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php @@ -1,6 +1,5 @@ where('folder', '!=', 'minecraft')->update([ + DB::table('services')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', '!=', 'minecraft')->update([ 'index_file' => $this->default, ]); - Service::where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', 'minecraft')->update([ + DB::table('services')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', 'minecraft')->update([ 'index_file' => $this->default_mc, ]); }); diff --git a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php b/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php index 7ce854c56..5c9df79a5 100644 --- a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php +++ b/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php @@ -15,6 +15,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration { Schema::table('service_options', function (Blueprint $table) { $table->char('uuid', 36)->after('id'); + $table->string('author')->after('service_id'); $table->dropColumn('tag'); }); @@ -25,6 +26,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration 'services.author AS service_author', ])->join('services', 'services.id', '=', 'service_options.service_id')->get()->each(function ($option) { DB::table('service_options')->where('id', $option->id)->update([ + 'author' => $option->service_author, 'uuid' => Uuid::uuid4()->toString(), ]); }); @@ -42,6 +44,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration { Schema::table('service_options', function (Blueprint $table) { $table->dropColumn('uuid'); + $table->dropColumn('author'); $table->string('tag'); }); diff --git a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php new file mode 100644 index 000000000..e7b70136c --- /dev/null +++ b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php @@ -0,0 +1,59 @@ +dropForeign(['service_id']); + $table->renameColumn('service_id', 'nest_id'); + + $table->foreign('nest_id')->references('id')->on('nests'); + }); + + Schema::table('service_options', function (Blueprint $table) { + $table->dropForeign(['service_id']); + $table->renameColumn('service_id', 'nest_id'); + + $table->foreign('nest_id')->references('id')->on('nests')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::disableForeignKeyConstraints(); + + Schema::rename('nests', 'services'); + + Schema::table('servers', function (Blueprint $table) { + $table->dropForeign(['nest_id']); + $table->renameColumn('nest_id', 'service_id'); + + $table->foreign('service_id')->references('id')->on('services'); + }); + + Schema::table('service_options', function (Blueprint $table) { + $table->dropForeign(['nest_id']); + $table->renameColumn('nest_id', 'service_id'); + + $table->foreign('service_id')->references('id')->on('services')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } +} diff --git a/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php b/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php new file mode 100644 index 000000000..d2c55c057 --- /dev/null +++ b/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php @@ -0,0 +1,93 @@ +dropForeign(['config_from']); + $table->dropForeign(['copy_script_from']); + }); + + Schema::rename('service_options', 'eggs'); + + Schema::table('packs', function (Blueprint $table) { + $table->dropForeign(['option_id']); + $table->renameColumn('option_id', 'egg_id'); + + $table->foreign('egg_id')->references('id')->on('eggs')->onDelete('CASCADE'); + }); + + Schema::table('servers', function (Blueprint $table) { + $table->dropForeign(['option_id']); + $table->renameColumn('option_id', 'egg_id'); + + $table->foreign('egg_id')->references('id')->on('eggs'); + }); + + Schema::table('eggs', function (Blueprint $table) { + $table->foreign('config_from')->references('id')->on('eggs')->onDelete('SET NULL'); + $table->foreign('copy_script_from')->references('id')->on('eggs')->onDelete('SET NULL'); + }); + + Schema::table('service_variables', function (Blueprint $table) { + $table->dropForeign(['option_id']); + $table->renameColumn('option_id', 'egg_id'); + + $table->foreign('egg_id')->references('id')->on('eggs')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::disableForeignKeyConstraints(); + + Schema::table('eggs', function (Blueprint $table) { + $table->dropForeign(['config_from']); + $table->dropForeign(['copy_script_from']); + }); + + Schema::rename('eggs', 'service_options'); + + Schema::table('packs', function (Blueprint $table) { + $table->dropForeign(['egg_id']); + $table->renameColumn('egg_id', 'option_id'); + + $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); + }); + + Schema::table('servers', function (Blueprint $table) { + $table->dropForeign(['egg_id']); + $table->renameColumn('egg_id', 'option_id'); + + $table->foreign('option_id')->references('id')->on('service_options'); + }); + + Schema::table('service_options', function (Blueprint $table) { + $table->foreign('config_from')->references('id')->on('service_options')->onDelete('SET NULL'); + $table->foreign('copy_script_from')->references('id')->on('service_options')->onDelete('SET NULL'); + }); + + Schema::table('service_variables', function (Blueprint $table) { + $table->dropForeign(['egg_id']); + $table->renameColumn('egg_id', 'option_id'); + + $table->foreign('option_id')->references('id')->on('options')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } +} diff --git a/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php b/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php new file mode 100644 index 000000000..ef7d3811d --- /dev/null +++ b/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php @@ -0,0 +1,43 @@ +dropForeign(['variable_id']); + + $table->foreign('variable_id')->references('id')->on('egg_variables')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::disableForeignKeyConstraints(); + + Schema::rename('egg_variables', 'service_variables'); + + Schema::table('server_variables', function (Blueprint $table) { + $table->dropForeign(['variable_id']); + + $table->foreign('variable_id')->references('id')->on('service_variables')->onDelete('CASCADE'); + }); + + Schema::enableForeignKeyConstraints(); + } +} diff --git a/database/seeds/MinecraftServiceTableSeeder.php b/database/seeds/MinecraftServiceTableSeeder.php index 114fc8457..d10c93213 100644 --- a/database/seeds/MinecraftServiceTableSeeder.php +++ b/database/seeds/MinecraftServiceTableSeeder.php @@ -6,17 +6,17 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\Nest; use Illuminate\Database\Seeder; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; class MinecraftServiceTableSeeder extends Seeder { /** * The core service ID. * - * @var \Pterodactyl\Models\Service + * @var \Pterodactyl\Models\Nest */ protected $service; @@ -80,7 +80,7 @@ EOF; private function addCoreService() { - $this->service = Service::updateOrCreate([ + $this->service = Nest::updateOrCreate([ 'author' => config('pterodactyl.service.core'), 'folder' => 'minecraft', ], [ @@ -114,7 +114,7 @@ fi curl -o ${SERVER_JARFILE} https://s3.amazonaws.com/Minecraft.Download/versions/${DL_VERSION}/minecraft_server.${DL_VERSION}.jar EOF; - $this->option['vanilla'] = ServiceOption::updateOrCreate([ + $this->option['vanilla'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'vanilla', ], [ @@ -148,7 +148,7 @@ if [ ! -z "${DL_PATH}" ]; then fi EOF; - $this->option['spigot'] = ServiceOption::updateOrCreate([ + $this->option['spigot'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'spigot', ], [ @@ -178,7 +178,7 @@ cd /mnt/server curl -sSL "https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/${SPONGE_VERSION}/spongevanilla-${SPONGE_VERSION}.jar" -o ${SERVER_JARFILE} EOF; - $this->option['sponge'] = ServiceOption::updateOrCreate([ + $this->option['sponge'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'sponge', ], [ @@ -211,7 +211,7 @@ fi curl -o ${SERVER_JARFILE} https://ci.md-5.net/job/BungeeCord/${BUNGEE_VERSION}/artifact/bootstrap/target/BungeeCord.jar EOF; - $this->option['bungeecord'] = ServiceOption::updateOrCreate([ + $this->option['bungeecord'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'bungeecord', ], [ @@ -247,7 +247,7 @@ java -jar installer.jar --installServer rm -rf installer.jar EOF; - $this->option['forge'] = ServiceOption::updateOrCreate([ + $this->option['forge'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'forge', ], [ @@ -276,7 +276,7 @@ EOF; private function addVanillaVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['vanilla']->id, 'env_variable' => 'SERVER_JARFILE', ], [ @@ -288,7 +288,7 @@ EOF; 'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['vanilla']->id, 'env_variable' => 'VANILLA_VERSION', ], [ @@ -303,7 +303,7 @@ EOF; private function addSpigotVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['spigot']->id, 'env_variable' => 'SERVER_JARFILE', ], [ @@ -315,7 +315,7 @@ EOF; 'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['spigot']->id, 'env_variable' => 'DL_VERSION', ], [ @@ -327,7 +327,7 @@ EOF; 'rules' => 'required|string|between:3,7', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['spigot']->id, 'env_variable' => 'DL_PATH', ], [ @@ -342,7 +342,7 @@ EOF; private function addSpongeVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['sponge']->id, 'env_variable' => 'SPONGE_VERSION', ], [ @@ -354,7 +354,7 @@ EOF; 'rules' => 'required|regex:/^([a-zA-Z0-9.\-_]+)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['sponge']->id, 'env_variable' => 'SERVER_JARFILE', ], [ @@ -369,7 +369,7 @@ EOF; private function addBungeecordVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['bungeecord']->id, 'env_variable' => 'BUNGEE_VERSION', ], [ @@ -381,7 +381,7 @@ EOF; 'rules' => 'required|alpha_num|between:1,6', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['bungeecord']->id, 'env_variable' => 'SERVER_JARFILE', ], [ @@ -396,7 +396,7 @@ EOF; private function addForgeVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['forge']->id, 'env_variable' => 'SERVER_JARFILE', ], [ diff --git a/database/seeds/RustServiceTableSeeder.php b/database/seeds/RustServiceTableSeeder.php index 5b1b49f81..39e54032e 100644 --- a/database/seeds/RustServiceTableSeeder.php +++ b/database/seeds/RustServiceTableSeeder.php @@ -6,10 +6,10 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\Nest; use Illuminate\Database\Seeder; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\CreatesServiceIndex; class RustServiceTableSeeder extends Seeder @@ -42,7 +42,7 @@ class RustServiceTableSeeder extends Seeder private function addCoreService() { - $this->service = Service::updateOrCreate([ + $this->service = Nest::updateOrCreate([ 'author' => config('pterodactyl.service.core'), 'folder' => 'rust', ], [ @@ -75,7 +75,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so EOF; - $this->option['rustvanilla'] = ServiceOption::updateOrCreate([ + $this->option['rustvanilla'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'rustvanilla', ], [ @@ -119,7 +119,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v /mnt/server/steam/linux32/steamclient.so /mnt/server/.steam/sdk32/steamclient.so EOF; - $this->option['rustoxide'] = ServiceOption::updateOrCreate([ + $this->option['rustoxide'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'rustoxide', ], [ @@ -146,7 +146,7 @@ EOF; private function addVanillaVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'HOSTNAME', ], [ @@ -158,7 +158,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'LEVEL', ], [ @@ -170,7 +170,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'DESCRIPTION', ], [ @@ -182,7 +182,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'URL', ], [ @@ -194,7 +194,7 @@ EOF; 'rules' => 'url', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'WORLD_SIZE', ], [ @@ -206,7 +206,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'SEED', ], [ @@ -218,7 +218,7 @@ EOF; 'rules' => 'present', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'MAX_PLAYERS', ], [ @@ -230,7 +230,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'SERVER_IMG', ], [ @@ -242,7 +242,7 @@ EOF; 'rules' => 'url', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'RCON_PORT', ], [ @@ -254,7 +254,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'RCON_PASS', ], [ @@ -266,7 +266,7 @@ EOF; 'rules' => 'required', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustvanilla']->id, 'env_variable' => 'ADDITIONAL_ARGS', ], [ @@ -281,7 +281,7 @@ EOF; private function addOxideVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'HOSTNAME', ], [ @@ -293,7 +293,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'LEVEL', ], [ @@ -305,7 +305,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'DESCRIPTION', ], [ @@ -317,7 +317,7 @@ EOF; 'rules' => 'required|string', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'URL', ], [ @@ -329,7 +329,7 @@ EOF; 'rules' => 'url', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'WORLD_SIZE', ], [ @@ -341,7 +341,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'SEED', ], [ @@ -353,7 +353,7 @@ EOF; 'rules' => 'present', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'MAX_PLAYERS', ], [ @@ -365,7 +365,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'SERVER_IMG', ], [ @@ -377,7 +377,7 @@ EOF; 'rules' => 'url', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'RCON_PORT', ], [ @@ -389,7 +389,7 @@ EOF; 'rules' => 'required|integer', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'RCON_PASS', ], [ @@ -401,7 +401,7 @@ EOF; 'rules' => 'required', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['rustoxide']->id, 'env_variable' => 'ADDITIONAL_ARGS', ], [ diff --git a/database/seeds/SourceServiceTableSeeder.php b/database/seeds/SourceServiceTableSeeder.php index efeec5ec9..c8394444b 100644 --- a/database/seeds/SourceServiceTableSeeder.php +++ b/database/seeds/SourceServiceTableSeeder.php @@ -6,10 +6,10 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\Nest; use Illuminate\Database\Seeder; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\CreatesServiceIndex; class SourceServiceTableSeeder extends Seeder @@ -42,7 +42,7 @@ class SourceServiceTableSeeder extends Seeder private function addCoreService() { - $this->service = Service::updateOrCreate([ + $this->service = Nest::updateOrCreate([ 'author' => config('pterodactyl.service.core'), 'folder' => 'srcds', ], [ @@ -81,7 +81,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so EOF; - $this->option['source'] = ServiceOption::updateOrCreate([ + $this->option['source'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'source', ], [ @@ -99,7 +99,7 @@ EOF; 'script_container' => 'ubuntu:16.04', ]); - $this->option['insurgency'] = ServiceOption::updateOrCreate([ + $this->option['insurgency'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'insurgency', ], [ @@ -115,7 +115,7 @@ EOF; 'copy_script_from' => $this->option['source']->id, ]); - $this->option['tf2'] = ServiceOption::updateOrCreate([ + $this->option['tf2'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'tf2', ], [ @@ -161,7 +161,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so EOF; - $this->option['ark'] = ServiceOption::updateOrCreate([ + $this->option['ark'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'ark', ], [ @@ -205,7 +205,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so EOF; - $this->option['csgo'] = ServiceOption::updateOrCreate([ + $this->option['csgo'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'csgo', ], [ @@ -249,7 +249,7 @@ mkdir -p /mnt/server/.steam/sdk32 cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so EOF; - $this->option['gmod'] = ServiceOption::updateOrCreate([ + $this->option['gmod'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'gmod', ], [ @@ -280,7 +280,7 @@ EOF; private function addInsurgencyVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['insurgency']->id, 'env_variable' => 'SRCDS_APPID', ], [ @@ -292,7 +292,7 @@ EOF; 'rules' => 'required|regex:/^(17705)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['insurgency']->id, 'env_variable' => 'SRCDS_GAME', ], [ @@ -304,7 +304,7 @@ EOF; 'rules' => 'required|regex:/^(insurgency)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['insurgency']->id, 'env_variable' => 'SRCDS_MAP', ], [ @@ -319,7 +319,7 @@ EOF; private function addTF2Variables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['tf2']->id, 'env_variable' => 'SRCDS_APPID', ], [ @@ -331,7 +331,7 @@ EOF; 'rules' => 'required|regex:/^(232250)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['tf2']->id, 'env_variable' => 'SRCDS_GAME', ], [ @@ -343,7 +343,7 @@ EOF; 'rules' => 'required|regex:/^(tf)$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['tf2']->id, 'env_variable' => 'SRCDS_MAP', ], [ @@ -358,7 +358,7 @@ EOF; private function addArkVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['ark']->id, 'env_variable' => 'ARK_PASSWORD', ], [ @@ -370,7 +370,7 @@ EOF; 'rules' => 'alpha_dash|between:1,100', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['ark']->id, 'env_variable' => 'ARK_ADMIN_PASSWORD', ], [ @@ -382,7 +382,7 @@ EOF; 'rules' => 'alpha_dash|between:1,100', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['ark']->id, 'env_variable' => 'SERVER_MAX_PLAYERS', ], [ @@ -397,7 +397,7 @@ EOF; private function addCSGOVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['csgo']->id, 'env_variable' => 'SRCDS_MAP', ], [ @@ -409,7 +409,7 @@ EOF; 'rules' => 'required|string|alpha_dash', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['csgo']->id, 'env_variable' => 'STEAM_ACC', ], [ @@ -424,7 +424,7 @@ EOF; private function addGMODVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['gmod']->id, 'env_variable' => 'SRCDS_MAP', ], [ @@ -436,7 +436,7 @@ EOF; 'rules' => 'required|string|alpha_dash', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['gmod']->id, 'env_variable' => 'STEAM_ACC', ], [ @@ -451,7 +451,7 @@ EOF; private function addCustomVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['source']->id, 'env_variable' => 'SRCDS_APPID', ], [ @@ -463,7 +463,7 @@ EOF; 'rules' => 'required|numeric|digits_between:1,6', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['source']->id, 'env_variable' => 'SRCDS_GAME', ], [ diff --git a/database/seeds/TerrariaServiceTableSeeder.php b/database/seeds/TerrariaServiceTableSeeder.php index 46b7bb67e..1e0303e55 100644 --- a/database/seeds/TerrariaServiceTableSeeder.php +++ b/database/seeds/TerrariaServiceTableSeeder.php @@ -6,10 +6,10 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\Nest; use Illuminate\Database\Seeder; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\CreatesServiceIndex; class TerrariaServiceTableSeeder extends Seeder @@ -42,7 +42,7 @@ class TerrariaServiceTableSeeder extends Seeder private function addCoreService() { - $this->service = Service::updateOrCreate([ + $this->service = Nest::updateOrCreate([ 'author' => config('pterodactyl.service.core'), 'folder' => 'terraria', ], [ @@ -70,7 +70,7 @@ curl -sSLO https://github.com/NyxStudios/TShock/releases/download/v${T_VERSION}/ unzip -o tshock_${T_VERSION}.zip -d /mnt/server EOF; - $this->option['tshock'] = ServiceOption::updateOrCreate([ + $this->option['tshock'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'tshock', ], [ @@ -89,7 +89,7 @@ EOF; private function addVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['tshock']->id, 'env_variable' => 'T_VERSION', ], [ @@ -101,7 +101,7 @@ EOF; 'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['tshock']->id, 'env_variable' => 'MAX_SLOTS', ], [ diff --git a/database/seeds/VoiceServiceTableSeeder.php b/database/seeds/VoiceServiceTableSeeder.php index 193e45741..f7c786c73 100644 --- a/database/seeds/VoiceServiceTableSeeder.php +++ b/database/seeds/VoiceServiceTableSeeder.php @@ -6,10 +6,10 @@ * This software is licensed under the terms of the MIT license. * https://opensource.org/licenses/MIT */ +use Pterodactyl\Models\Egg; +use Pterodactyl\Models\Nest; use Illuminate\Database\Seeder; -use Pterodactyl\Models\Service; -use Pterodactyl\Models\ServiceOption; -use Pterodactyl\Models\ServiceVariable; +use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\CreatesServiceIndex; class VoiceServiceTableSeeder extends Seeder @@ -19,7 +19,7 @@ class VoiceServiceTableSeeder extends Seeder /** * The core service ID. * - * @var Service + * @var Nest */ protected $service; @@ -42,7 +42,7 @@ class VoiceServiceTableSeeder extends Seeder private function addCoreService() { - $this->service = Service::updateOrCreate([ + $this->service = Nest::updateOrCreate([ 'author' => config('pterodactyl.service.core'), 'folder' => 'voice', ], [ @@ -71,7 +71,7 @@ tar -xjvf murmur-static_x86-${MUMBLE_VERSION}.tar.bz2 cp -r murmur-static_x86-${MUMBLE_VERSION}/* /mnt/server EOF; - $this->option['mumble'] = ServiceOption::updateOrCreate([ + $this->option['mumble'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'mumble', ], [ @@ -124,7 +124,7 @@ logappend=0 query_skipbruteforcecheck=0" > /mnt/server/ts3server.ini EOF; - $this->option['ts3'] = ServiceOption::updateOrCreate([ + $this->option['ts3'] = Egg::updateOrCreate([ 'service_id' => $this->service->id, 'tag' => 'ts3', ], [ @@ -143,7 +143,7 @@ EOF; private function addVariables() { - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['mumble']->id, 'env_variable' => 'MAX_USERS', ], [ @@ -155,7 +155,7 @@ EOF; 'rules' => 'required|numeric|digits_between:1,5', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['mumble']->id, 'env_variable' => 'MUMBLE_VERSION', ], [ @@ -167,7 +167,7 @@ EOF; 'rules' => 'required|regex:/^([0-9_\.-]{5,8})$/', ]); - ServiceVariable::updateOrCreate([ + EggVariable::updateOrCreate([ 'option_id' => $this->option['ts3']->id, 'env_variable' => 'TS_VERSION', ], [ diff --git a/resources/lang/en/admin/nests.php b/resources/lang/en/admin/nests.php new file mode 100644 index 000000000..6ddb44fac --- /dev/null +++ b/resources/lang/en/admin/nests.php @@ -0,0 +1,31 @@ +. + * + * This software is licensed under the terms of the MIT license. + * https://opensource.org/licenses/MIT + */ + +return [ + 'notices' => [ + 'created' => 'A new nest, :name, has been successfully created.', + 'deleted' => 'Successfully deleted the requested nest from the Panel.', + 'updated' => 'Successfully updated the nest configuration options.', + ], + 'eggs' => [ + 'notices' => [ + 'deleted' => 'Successfully deleted the requested egg from the Panel.', + 'updated' => 'Egg configuration has been updated successfully.', + 'script_updated' => 'Egg install script has been updated and will run whenever servers are installed.', + 'egg_created' => 'A new egg was laid successfully. You will need to restart any running daemons to apply this new egg.', + ], + ], + 'variables' => [ + 'notices' => [ + 'variable_deleted' => 'The variable ":variable" has been deleted and will no longer be available to servers once rebuilt.', + 'variable_updated' => 'The variable ":variable" has been updated. You will need to rebuild any servers using this variable in order to apply changes.', + 'variable_created' => 'New variable has successfully been created and assigned to this egg.', + ], + ], +]; diff --git a/resources/lang/en/admin/services.php b/resources/lang/en/admin/services.php deleted file mode 100644 index 86db21509..000000000 --- a/resources/lang/en/admin/services.php +++ /dev/null @@ -1,32 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ - -return [ - 'notices' => [ - 'service_created' => 'A new service, :name, has been successfully created.', - 'service_deleted' => 'Successfully deleted the requested service from the Panel.', - 'service_updated' => 'Successfully updated the service configuration options.', - 'functions_updated' => 'The service functions file has been updated. You will need to reboot your Nodes in order for these changes to be applied.', - ], - 'options' => [ - 'notices' => [ - 'option_deleted' => 'Successfully deleted the requested service option from the Panel.', - 'option_updated' => 'Service option configuration has been updated successfully.', - 'script_updated' => 'Service option install script has been updated and will run whenever servers are installed.', - 'option_created' => 'New service option was created successfully. You will need to restart any running daemons to apply this new service.', - ], - ], - 'variables' => [ - 'notices' => [ - 'variable_deleted' => 'The variable ":variable" has been deleted and will no longer be available to servers once rebuilt.', - 'variable_updated' => 'The variable ":variable" has been updated. You will need to rebuild any servers using this variable in order to apply changes.', - 'variable_created' => 'New variable has successfully been created and assigned to this service option.', - ], - ], -]; diff --git a/resources/lang/en/exceptions.php b/resources/lang/en/exceptions.php index 7d42e1621..c700b62ff 100644 --- a/resources/lang/en/exceptions.php +++ b/resources/lang/en/exceptions.php @@ -18,21 +18,20 @@ return [ 'invalid_mapping' => 'The mapping provided for :port was invalid and could not be processed.', 'cidr_out_of_range' => 'CIDR notation only allows masks between /25 and /32.', ], - 'service' => [ - 'delete_has_servers' => 'A service with active servers attached to it cannot be deleted from the Panel.', - 'options' => [ - 'duplicate_tag' => 'A service option with that tag already exists for this service.', - 'delete_has_servers' => 'A service option with active servers attached to it cannot be deleted from the Panel.', - 'invalid_copy_id' => 'The service option selected for copying a script from either does not exist, or is copying a script itself.', - 'must_be_child' => 'The "Copy Settings From" directive for this option must be a child option for the selected service.', - 'has_children' => 'This service option is a parent to one or more other options. Please delete those options before deleting this option.', + 'nest' => [ + 'delete_has_servers' => 'A Nest with active servers attached to it cannot be deleted from the Panel.', + 'egg' => [ + 'delete_has_servers' => 'An Egg with active servers attached to it cannot be deleted from the Panel.', + 'invalid_copy_id' => 'The Egg selected for copying a script from either does not exist, or is copying a script itself.', + 'must_be_child' => 'The "Copy Settings From" directive for this Egg must be a child option for the selected Nest.', + 'has_children' => 'This Egg is a parent to one or more other Eggs. Please delete those Eggs before deleting this Egg.', ], 'variables' => [ - 'env_not_unique' => 'The environment variable :name must be unique to this service option.', + 'env_not_unique' => 'The environment variable :name must be unique to this Egg.', 'reserved_name' => 'The environment variable :name is protected and cannot be assigned to a variable.', ], - 'exporter' => [ - 'import_file_error' => 'The XML file provided was not valid.', + 'importer' => [ + 'file_error' => 'The JSON file provided was not valid.', 'invalid_json_provided' => 'The JSON file provided is not in a format that can be recognized.', ], ], diff --git a/resources/themes/pterodactyl/admin/services/options/view.blade.php b/resources/themes/pterodactyl/admin/eggs/view.blade.php similarity index 66% rename from resources/themes/pterodactyl/admin/services/options/view.blade.php rename to resources/themes/pterodactyl/admin/eggs/view.blade.php index 641a28be7..dc99434eb 100644 --- a/resources/themes/pterodactyl/admin/services/options/view.blade.php +++ b/resources/themes/pterodactyl/admin/eggs/view.blade.php @@ -6,16 +6,16 @@ @extends('layouts.admin') @section('title') - Service → Option: {{ $option->name }} + Nests → Egg: {{ $egg->name }} @endsection @section('content-header') -

{{ $option->name }}{{ str_limit($option->description, 50) }}

+

{{ $egg->name }}{{ str_limit($egg->description, 50) }}

@endsection @@ -24,18 +24,18 @@
-
+
- Notice: Editing the Option Tag or any of the Process Management fields requires that each daemon be rebooted to apply the changes. + Notice: Editing an Egg or any of the Process Management fields requires that each Daemon be rebooted in order to apply the changes.
@@ -47,30 +47,26 @@
- - -

A simple, human-readable name to use as an identifier for this service.

+ + +

A simple, human-readable name to use as an identifier for this Egg.

- - -

A description of this service that will be displayed throughout the panel as needed.

+ + +

A description of this Egg that will be displayed throughout the Panel as needed.

- - + + +

The default docker image that should be used for new servers using this Egg. This can be changed per-server as needed.

- - -

The default docker image that should be used for new servers under this service option. This can be left blank to use the parent service's defined image, and can also be changed per-server.

-
-
- - -

The default statup command that should be used for new servers under this service option. This can be left blank to use the parent service's startup, and can also be changed per-server.

+ + +

The default statup command that should be used for new servers using this Egg.

@@ -87,7 +83,7 @@

The following configuration options should not be edited unless you understand how this system works. If wrongly modified it is possible for the daemon to break.

-

All fields are required unless you select a seperate option from the 'Copy Settings From' dropdown, in which case fields may be left blank to use the values from that option.

+

All fields are required unless you select a seperate option from the 'Copy Settings From' dropdown, in which case fields may be left blank to use the values from that Egg.

@@ -95,32 +91,32 @@ -

If you would like to default to settings from another option select the option from the menu above.

+

If you would like to default to settings from another Egg select it from the menu above.

- +

The command that should be sent to server processes to stop them gracefully. If you need to send a SIGINT you should enter ^C here.

- +

This should be a JSON representation of where log files are stored, and wether or not the daemon should be creating custom logs.

- +

This should be a JSON representation of configuration files to modify and what parts should be changed.

- +

This should be a JSON representation of what values the daemon should be looking for when booting a server to determine completion.

@@ -131,8 +127,8 @@ - - Export Option Configuration + + Export
diff --git a/resources/themes/pterodactyl/admin/services/index.blade.php b/resources/themes/pterodactyl/admin/nests/index.blade.php similarity index 63% rename from resources/themes/pterodactyl/admin/services/index.blade.php rename to resources/themes/pterodactyl/admin/nests/index.blade.php index a1cd88212..c19a8099c 100644 --- a/resources/themes/pterodactyl/admin/services/index.blade.php +++ b/resources/themes/pterodactyl/admin/nests/index.blade.php @@ -6,14 +6,14 @@ @extends('layouts.admin') @section('title') - Service + Nests @endsection @section('content-header') -

ServiceAll services currently available on this system.

+

NestsAll nests currently available on this system.

@endsection @@ -21,7 +21,7 @@
- Services are a powerful feature of Pterodactyl Panel that allow for extreme flexibility and configuration. Please note that while powerful, modifing a service wrongly can very easily brick your servers and cause more problems. Please avoid editing our default services — those provided by support@pterodactyl.io — unless you are absolutely sure of what you are doing. + Eggs are a powerful feature of Pterodactyl Panel that allow for extreme flexibility and configuration. Please note that while powerful, modifing an egg wrongly can very easily brick your servers and cause more problems. Please avoid editing our default eggs — those provided by support@pterodactyl.io — unless you are absolutely sure of what you are doing.
@@ -29,10 +29,10 @@
-

Configured Service

+

Configured Nests

@@ -40,17 +40,17 @@ Name Description - Options + Eggs Packs Servers - @foreach($services as $service) + @foreach($nests as $nest) - {{ $service->name }} - {{ $service->description }} - {{ $service->options_count }} - {{ $service->packs_count }} - {{ $service->servers_count }} + {{ $nest->name }} + {{ $nest->description }} + {{ $nest->eggs_count }} + {{ $nest->packs_count }} + {{ $nest->servers_count }} @endforeach @@ -63,26 +63,26 @@