This breaks literally the entire panel.
This commit is contained in:
parent
344c1a9885
commit
df87ea0867
88 changed files with 1205 additions and 992 deletions
|
@ -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
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
interface OptionVariableRepositoryInterface extends RepositoryInterface
|
||||
interface EggVariableRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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.
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository;
|
||||
|
||||
interface ServiceVariableRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
}
|
|
@ -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')) {
|
||||
|
|
|
@ -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;
|
||||
|
|
32
app/Http/Controllers/Admin/Nests/EggController.php
Normal file
32
app/Http/Controllers/Admin/Nests/EggController.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -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]);
|
||||
}
|
||||
}
|
160
app/Http/Controllers/Admin/Nests/NestController.php
Normal file
160
app/Http/Controllers/Admin/Nests/NestController.php
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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');
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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', [
|
||||
|
|
|
@ -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 [
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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',
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
|
@ -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)
|
|
@ -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
|
||||
*/
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
76
app/Services/Eggs/Sharing/EggExporterService.php
Normal file
76
app/Services/Eggs/Sharing/EggExporterService.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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([
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
|
@ -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')
|
||||
|
|
|
@ -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'),
|
||||
]));
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* 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 <dane@daneeveritt.com>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue