2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
2016-01-20 00:10:39 +00:00
|
|
|
/**
|
2016-01-20 21:05:16 +00:00
|
|
|
* Pterodactyl - Panel
|
2017-01-24 22:57:08 +00:00
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
2016-01-20 00:10:39 +00:00
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2016-01-20 00:10:39 +00:00
|
|
|
*/
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
namespace Pterodactyl\Http\Controllers\Admin;
|
|
|
|
|
2017-02-24 23:19:03 +00:00
|
|
|
use Javascript;
|
2016-12-07 22:46:38 +00:00
|
|
|
use Illuminate\Http\Request;
|
2017-10-27 04:49:54 +00:00
|
|
|
use Pterodactyl\Models\User;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use Prologue\Alerts\AlertsMessageBag;
|
2016-12-07 22:46:38 +00:00
|
|
|
use Pterodactyl\Exceptions\DisplayException;
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
2017-08-31 02:14:20 +00:00
|
|
|
use Pterodactyl\Services\Servers\SuspensionService;
|
|
|
|
use Pterodactyl\Http\Requests\Admin\ServerFormRequest;
|
2017-08-27 20:10:51 +00:00
|
|
|
use Pterodactyl\Services\Servers\ServerCreationService;
|
|
|
|
use Pterodactyl\Services\Servers\ServerDeletionService;
|
|
|
|
use Pterodactyl\Services\Servers\ReinstallServerService;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Services\Servers\ContainerRebuildService;
|
|
|
|
use Pterodactyl\Services\Servers\BuildModificationService;
|
2017-10-19 03:32:19 +00:00
|
|
|
use Pterodactyl\Services\Databases\DatabasePasswordService;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Services\Servers\DetailsModificationService;
|
|
|
|
use Pterodactyl\Services\Servers\StartupModificationService;
|
2017-10-07 04:57:53 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
|
|
|
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
|
2017-10-19 03:32:19 +00:00
|
|
|
use Pterodactyl\Services\Databases\DatabaseManagementService;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
|
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|
|
|
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
|
|
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|
|
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
2018-05-21 00:11:52 +00:00
|
|
|
use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
|
2015-12-06 18:58:49 +00:00
|
|
|
|
|
|
|
class ServersController extends Controller
|
|
|
|
{
|
2017-07-23 01:15:01 +00:00
|
|
|
/**
|
|
|
|
* @var \Prologue\Alerts\AlertsMessageBag
|
|
|
|
*/
|
|
|
|
protected $alert;
|
|
|
|
|
2017-07-22 02:17:42 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $allocationRepository;
|
|
|
|
|
2017-07-24 00:57:43 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\BuildModificationService
|
|
|
|
*/
|
|
|
|
protected $buildModificationService;
|
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
/**
|
|
|
|
* @var \Illuminate\Contracts\Config\Repository
|
|
|
|
*/
|
|
|
|
protected $config;
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\ContainerRebuildService
|
|
|
|
*/
|
|
|
|
protected $containerRebuildService;
|
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $databaseRepository;
|
|
|
|
|
2017-07-22 18:55:30 +00:00
|
|
|
/**
|
2017-10-19 03:32:19 +00:00
|
|
|
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
|
2017-07-22 18:55:30 +00:00
|
|
|
*/
|
2017-07-25 02:34:10 +00:00
|
|
|
protected $databaseManagementService;
|
2017-07-22 18:55:30 +00:00
|
|
|
|
2017-10-19 03:32:19 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
|
|
|
|
*/
|
|
|
|
protected $databasePasswordService;
|
|
|
|
|
2017-07-22 02:17:42 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $databaseHostRepository;
|
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
2017-07-25 02:34:10 +00:00
|
|
|
*/
|
|
|
|
protected $deletionService;
|
|
|
|
|
2017-07-23 01:15:01 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\DetailsModificationService
|
|
|
|
*/
|
|
|
|
protected $detailsModificationService;
|
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $locationRepository;
|
|
|
|
|
2017-10-07 22:21:41 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $nestRepository;
|
|
|
|
|
2017-07-22 02:17:42 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $nodeRepository;
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
2017-07-23 19:51:18 +00:00
|
|
|
*/
|
|
|
|
protected $reinstallService;
|
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $repository;
|
|
|
|
|
2017-07-20 01:49:41 +00:00
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
2017-07-20 01:49:41 +00:00
|
|
|
*/
|
|
|
|
protected $service;
|
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\StartupModificationService
|
|
|
|
*/
|
|
|
|
private $startupModificationService;
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Servers\SuspensionService
|
|
|
|
*/
|
|
|
|
protected $suspensionService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ServersController constructor.
|
|
|
|
*
|
|
|
|
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
|
2017-07-24 00:57:43 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
|
2017-07-23 19:51:18 +00:00
|
|
|
* @param \Illuminate\Contracts\Config\Repository $config
|
|
|
|
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService
|
2017-08-27 20:10:51 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\ServerCreationService $service
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
|
|
|
|
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService
|
2017-07-23 19:51:18 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
|
|
|
|
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
|
2017-08-27 20:10:51 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService
|
2017-07-23 19:51:18 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository
|
2017-08-27 20:10:51 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService
|
2017-07-23 19:51:18 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
|
2017-10-07 22:21:41 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
|
2017-07-25 02:34:10 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
|
2017-07-23 19:51:18 +00:00
|
|
|
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
|
|
|
|
*/
|
2017-07-15 16:52:34 +00:00
|
|
|
public function __construct(
|
2017-07-23 01:15:01 +00:00
|
|
|
AlertsMessageBag $alert,
|
2017-07-22 02:17:42 +00:00
|
|
|
AllocationRepositoryInterface $allocationRepository,
|
2017-07-24 00:57:43 +00:00
|
|
|
BuildModificationService $buildModificationService,
|
2017-07-15 16:52:34 +00:00
|
|
|
ConfigRepository $config,
|
2017-07-23 19:51:18 +00:00
|
|
|
ContainerRebuildService $containerRebuildService,
|
2017-08-27 20:10:51 +00:00
|
|
|
ServerCreationService $service,
|
2017-07-25 02:34:10 +00:00
|
|
|
DatabaseManagementService $databaseManagementService,
|
2017-10-19 03:32:19 +00:00
|
|
|
DatabasePasswordService $databasePasswordService,
|
2017-07-15 16:52:34 +00:00
|
|
|
DatabaseRepositoryInterface $databaseRepository,
|
2017-07-22 02:17:42 +00:00
|
|
|
DatabaseHostRepository $databaseHostRepository,
|
2017-08-27 20:10:51 +00:00
|
|
|
ServerDeletionService $deletionService,
|
2017-07-23 01:15:01 +00:00
|
|
|
DetailsModificationService $detailsModificationService,
|
2017-07-15 16:52:34 +00:00
|
|
|
LocationRepositoryInterface $locationRepository,
|
2017-07-22 02:17:42 +00:00
|
|
|
NodeRepositoryInterface $nodeRepository,
|
2017-08-27 20:10:51 +00:00
|
|
|
ReinstallServerService $reinstallService,
|
2017-07-15 16:52:34 +00:00
|
|
|
ServerRepositoryInterface $repository,
|
2017-10-07 22:21:41 +00:00
|
|
|
NestRepositoryInterface $nestRepository,
|
2017-07-25 02:34:10 +00:00
|
|
|
StartupModificationService $startupModificationService,
|
2017-07-23 19:51:18 +00:00
|
|
|
SuspensionService $suspensionService
|
2017-07-15 16:52:34 +00:00
|
|
|
) {
|
2017-07-23 01:15:01 +00:00
|
|
|
$this->alert = $alert;
|
2017-07-22 02:17:42 +00:00
|
|
|
$this->allocationRepository = $allocationRepository;
|
2017-07-24 00:57:43 +00:00
|
|
|
$this->buildModificationService = $buildModificationService;
|
2017-07-15 16:52:34 +00:00
|
|
|
$this->config = $config;
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->containerRebuildService = $containerRebuildService;
|
2017-10-19 03:32:19 +00:00
|
|
|
$this->databaseHostRepository = $databaseHostRepository;
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->databaseManagementService = $databaseManagementService;
|
2017-10-19 03:32:19 +00:00
|
|
|
$this->databasePasswordService = $databasePasswordService;
|
2017-07-15 16:52:34 +00:00
|
|
|
$this->databaseRepository = $databaseRepository;
|
2017-07-23 01:15:01 +00:00
|
|
|
$this->detailsModificationService = $detailsModificationService;
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->deletionService = $deletionService;
|
2017-07-15 16:52:34 +00:00
|
|
|
$this->locationRepository = $locationRepository;
|
2017-10-07 22:21:41 +00:00
|
|
|
$this->nestRepository = $nestRepository;
|
2017-07-22 02:17:42 +00:00
|
|
|
$this->nodeRepository = $nodeRepository;
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->reinstallService = $reinstallService;
|
2017-07-15 16:52:34 +00:00
|
|
|
$this->repository = $repository;
|
2017-07-20 01:49:41 +00:00
|
|
|
$this->service = $service;
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->startupModificationService = $startupModificationService;
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->suspensionService = $suspensionService;
|
2017-07-15 16:52:34 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
/**
|
2017-03-05 00:03:49 +00:00
|
|
|
* Display the index page with all servers currently on the system.
|
|
|
|
*
|
2018-02-24 17:48:24 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
2015-12-06 18:58:49 +00:00
|
|
|
*/
|
2018-02-24 17:48:24 +00:00
|
|
|
public function index(Request $request)
|
2015-12-06 18:58:49 +00:00
|
|
|
{
|
2016-10-12 21:12:27 +00:00
|
|
|
return view('admin.servers.index', [
|
2018-02-24 17:48:24 +00:00
|
|
|
'servers' => $this->repository->setSearchTerm($request->input('query'))->getAllServers(
|
2017-07-15 16:52:34 +00:00
|
|
|
$this->config->get('pterodactyl.paginate.admin.servers')
|
|
|
|
),
|
2015-12-06 18:58:49 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Display create new server page.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
2017-07-15 16:52:34 +00:00
|
|
|
*
|
|
|
|
* @throws \Exception
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-15 16:52:34 +00:00
|
|
|
public function create()
|
2015-12-06 18:58:49 +00:00
|
|
|
{
|
2017-09-21 23:05:55 +00:00
|
|
|
$nodes = $this->nodeRepository->all();
|
|
|
|
if (count($nodes) < 1) {
|
|
|
|
$this->alert->warning(trans('admin/server.alerts.node_required'))->flash();
|
|
|
|
|
|
|
|
return redirect()->route('admin.nodes');
|
|
|
|
}
|
|
|
|
|
2017-10-07 22:21:41 +00:00
|
|
|
$nests = $this->nestRepository->getWithEggs();
|
2017-07-15 16:52:34 +00:00
|
|
|
|
2017-02-24 23:19:03 +00:00
|
|
|
Javascript::put([
|
2017-11-05 20:12:53 +00:00
|
|
|
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
2017-10-07 22:21:41 +00:00
|
|
|
'nests' => $nests->map(function ($item) {
|
2017-02-24 23:19:03 +00:00
|
|
|
return array_merge($item->toArray(), [
|
2017-10-07 22:21:41 +00:00
|
|
|
'eggs' => $item->eggs->keyBy('id')->toArray(),
|
2017-02-24 23:19:03 +00:00
|
|
|
]);
|
|
|
|
})->keyBy('id'),
|
|
|
|
]);
|
|
|
|
|
2015-12-07 05:47:19 +00:00
|
|
|
return view('admin.servers.new', [
|
2017-07-15 16:52:34 +00:00
|
|
|
'locations' => $this->locationRepository->all(),
|
2017-10-07 22:21:41 +00:00
|
|
|
'nests' => $nests,
|
2015-12-07 05:47:19 +00:00
|
|
|
]);
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
2017-07-22 02:17:42 +00:00
|
|
|
* Handle POST of server creation form.
|
2017-03-05 00:03:49 +00:00
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\ServerFormRequest $request
|
2017-07-22 02:17:42 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*
|
2018-01-28 23:14:14 +00:00
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2017-07-25 02:34:10 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
2018-01-28 23:14:14 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2017-07-22 02:17:42 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-09-30 17:06:16 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2018-01-28 23:14:14 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-22 02:17:42 +00:00
|
|
|
public function store(ServerFormRequest $request)
|
2015-12-10 23:30:47 +00:00
|
|
|
{
|
2018-01-28 23:14:14 +00:00
|
|
|
$server = $this->service->handle($request->except('_token'));
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.server_created'))->flash();
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
return redirect()->route('admin.servers.view', $server->id);
|
2015-12-10 23:30:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Display the index when viewing a specific server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function viewIndex(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-07-23 20:09:25 +00:00
|
|
|
return view('admin.servers.view.index', ['server' => $server]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the details page when viewing a specific server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-09-30 17:06:16 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function viewDetails($server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-07-22 02:17:42 +00:00
|
|
|
return view('admin.servers.view.details', [
|
|
|
|
'server' => $this->repository->findFirstWhere([
|
2017-07-23 20:09:25 +00:00
|
|
|
['id', '=', $server],
|
2017-07-22 02:17:42 +00:00
|
|
|
['installed', '=', 1],
|
|
|
|
]),
|
|
|
|
]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the build details page when viewing a specific server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-09-30 17:06:16 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function viewBuild($server)
|
2016-01-02 23:04:18 +00:00
|
|
|
{
|
2017-07-22 02:17:42 +00:00
|
|
|
$server = $this->repository->findFirstWhere([
|
2017-07-23 20:09:25 +00:00
|
|
|
['id', '=', $server],
|
2017-07-22 02:17:42 +00:00
|
|
|
['installed', '=', 1],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$allocations = $this->allocationRepository->getAllocationsForNode($server->node_id);
|
2017-03-05 00:03:49 +00:00
|
|
|
|
|
|
|
return view('admin.servers.view.build', [
|
|
|
|
'server' => $server,
|
2017-07-22 02:17:42 +00:00
|
|
|
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
|
|
|
|
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
|
2017-03-05 00:03:49 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display startup configuration page for a server.
|
|
|
|
*
|
2017-11-25 18:27:08 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-09-30 17:06:16 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-11-25 18:27:08 +00:00
|
|
|
public function viewStartup(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-11-25 18:27:08 +00:00
|
|
|
$parameters = $this->repository->getVariablesWithValues($server->id, true);
|
2017-07-22 02:17:42 +00:00
|
|
|
if (! $parameters->server->installed) {
|
|
|
|
abort(404);
|
|
|
|
}
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-10-07 22:21:41 +00:00
|
|
|
$nests = $this->nestRepository->getWithEggs();
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-04-21 21:52:44 +00:00
|
|
|
Javascript::put([
|
2017-11-25 18:27:08 +00:00
|
|
|
'server' => $server,
|
2017-10-07 22:21:41 +00:00
|
|
|
'nests' => $nests->map(function ($item) {
|
2017-04-21 21:52:44 +00:00
|
|
|
return array_merge($item->toArray(), [
|
2017-10-07 22:21:41 +00:00
|
|
|
'eggs' => $item->eggs->keyBy('id')->toArray(),
|
2017-04-21 21:52:44 +00:00
|
|
|
]);
|
|
|
|
})->keyBy('id'),
|
2017-07-22 02:17:42 +00:00
|
|
|
'server_variables' => $parameters->data,
|
2017-04-21 21:52:44 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
return view('admin.servers.view.startup', [
|
2017-07-22 02:17:42 +00:00
|
|
|
'server' => $parameters->server,
|
2017-10-07 22:21:41 +00:00
|
|
|
'nests' => $nests,
|
2017-04-21 21:52:44 +00:00
|
|
|
]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the database management page for a specific server.
|
|
|
|
*
|
2018-01-05 04:49:50 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function viewDatabase(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2018-01-05 04:49:50 +00:00
|
|
|
$this->repository->loadDatabaseRelations($server);
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-03-05 21:37:38 +00:00
|
|
|
return view('admin.servers.view.database', [
|
2017-07-22 02:17:42 +00:00
|
|
|
'hosts' => $this->databaseHostRepository->all(),
|
2017-03-06 01:28:29 +00:00
|
|
|
'server' => $server,
|
2017-03-05 21:37:38 +00:00
|
|
|
]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the management page when viewing a specific server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function viewManage(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-07-23 20:09:25 +00:00
|
|
|
return view('admin.servers.view.manage', ['server' => $server]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the deletion page for a server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-05 00:03:49 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function viewDelete(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-07-23 20:09:25 +00:00
|
|
|
return view('admin.servers.view.delete', ['server' => $server]);
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the details for a server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-23 01:15:01 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-09-30 17:06:16 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 01:15:01 +00:00
|
|
|
public function setDetails(Request $request, Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2018-01-20 22:03:23 +00:00
|
|
|
$this->detailsModificationService->handle($server, $request->only([
|
2018-02-24 17:57:12 +00:00
|
|
|
'owner_id', 'external_id', 'name', 'description',
|
2017-07-23 01:15:01 +00:00
|
|
|
]));
|
2016-09-18 00:14:36 +00:00
|
|
|
|
2017-07-23 01:15:01 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.details_updated'))->flash();
|
|
|
|
|
|
|
|
return redirect()->route('admin.servers.view.details', $server->id);
|
2016-09-18 00:14:36 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Toggles the install status for a server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-23 19:51:18 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-08-27 00:58:24 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 19:51:18 +00:00
|
|
|
public function toggleInstall(Server $server)
|
2017-03-05 00:03:49 +00:00
|
|
|
{
|
2017-07-23 19:51:18 +00:00
|
|
|
if ($server->installed > 1) {
|
|
|
|
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
|
2017-03-05 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->repository->update($server->id, [
|
|
|
|
'installed' => ! $server->installed,
|
2018-01-31 04:40:21 +00:00
|
|
|
], true, true);
|
2017-07-23 19:51:18 +00:00
|
|
|
|
|
|
|
$this->alert->success(trans('admin/server.alerts.install_toggled'))->flash();
|
|
|
|
|
|
|
|
return redirect()->route('admin.servers.view.manage', $server->id);
|
2016-01-02 23:04:18 +00:00
|
|
|
}
|
|
|
|
|
2017-04-20 22:52:43 +00:00
|
|
|
/**
|
|
|
|
* Reinstalls the server with the currently assigned pack and service.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-04-20 22:52:43 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-23 19:51:18 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-04-20 22:52:43 +00:00
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function reinstallServer(Server $server)
|
2017-04-20 22:52:43 +00:00
|
|
|
{
|
2017-07-23 20:09:25 +00:00
|
|
|
$this->reinstallService->reinstall($server);
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash();
|
2017-04-20 22:52:43 +00:00
|
|
|
|
2017-07-23 20:09:25 +00:00
|
|
|
return redirect()->route('admin.servers.view.manage', $server->id);
|
2017-04-20 22:52:43 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Setup a server to have a container rebuild.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2018-05-13 16:19:35 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 19:51:18 +00:00
|
|
|
public function rebuildContainer(Server $server)
|
2016-12-07 22:46:38 +00:00
|
|
|
{
|
2018-01-06 00:27:47 +00:00
|
|
|
$this->containerRebuildService->handle($server);
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.rebuild_on_boot'))->flash();
|
2016-01-03 04:21:22 +00:00
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
return redirect()->route('admin.servers.view.manage', $server->id);
|
2016-01-03 04:21:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Manage the suspension status for a server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-23 19:51:18 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-08-27 00:58:24 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-23 19:51:18 +00:00
|
|
|
public function manageSuspension(Request $request, Server $server)
|
2016-01-03 04:21:22 +00:00
|
|
|
{
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->suspensionService->toggle($server, $request->input('action'));
|
|
|
|
$this->alert->success(trans('admin/server.alerts.suspension_toggled', [
|
|
|
|
'status' => $request->input('action') . 'ed',
|
|
|
|
]))->flash();
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
return redirect()->route('admin.servers.view.manage', $server->id);
|
2016-01-03 04:21:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Update the build configuration for a server.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-07-24 00:57:43 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2018-03-03 01:49:09 +00:00
|
|
|
*
|
2017-07-24 00:57:43 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2018-03-03 01:49:09 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-24 00:57:43 +00:00
|
|
|
public function updateBuild(Request $request, Server $server)
|
2016-01-04 04:16:03 +00:00
|
|
|
{
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->buildModificationService->handle($server, $request->only([
|
|
|
|
'allocation_id', 'add_allocations', 'remove_allocations',
|
|
|
|
'memory', 'swap', 'io', 'cpu', 'disk',
|
2018-03-03 01:49:09 +00:00
|
|
|
'database_limit', 'allocation_limit',
|
2017-07-24 00:57:43 +00:00
|
|
|
]));
|
|
|
|
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2017-07-24 00:57:43 +00:00
|
|
|
return redirect()->route('admin.servers.view.build', $server->id);
|
2016-01-04 04:16:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Start the server deletion process.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-25 02:34:10 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
2017-08-27 00:58:24 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 00:03:49 +00:00
|
|
|
*/
|
2017-07-25 02:34:10 +00:00
|
|
|
public function delete(Request $request, Server $server)
|
2016-01-04 21:09:22 +00:00
|
|
|
{
|
2017-12-17 19:07:38 +00:00
|
|
|
$this->deletionService->withForce($request->filled('force_delete'))->handle($server);
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
return redirect()->route('admin.servers');
|
2016-10-28 00:05:29 +00:00
|
|
|
}
|
2017-03-05 00:03:49 +00:00
|
|
|
|
2017-03-05 04:45:22 +00:00
|
|
|
/**
|
|
|
|
* Update the startup command as well as variables.
|
|
|
|
*
|
2018-05-21 00:11:52 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-07-25 02:34:10 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-25 02:34:10 +00:00
|
|
|
*
|
2018-05-13 16:19:35 +00:00
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2017-07-25 02:34:10 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-08-27 00:58:24 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-05 04:45:22 +00:00
|
|
|
*/
|
2017-07-25 02:34:10 +00:00
|
|
|
public function saveStartup(Request $request, Server $server)
|
2017-03-05 04:45:22 +00:00
|
|
|
{
|
2017-10-27 04:49:54 +00:00
|
|
|
$this->startupModificationService->setUserLevel(User::USER_LEVEL_ADMIN);
|
|
|
|
$this->startupModificationService->handle($server, $request->except('_token'));
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->alert->success(trans('admin/server.alerts.startup_changed'))->flash();
|
2017-03-05 04:45:22 +00:00
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
return redirect()->route('admin.servers.view.startup', $server->id);
|
2017-03-05 04:45:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 21:37:38 +00:00
|
|
|
/**
|
|
|
|
* Creates a new database assigned to a specific server.
|
2017-03-19 23:36:50 +00:00
|
|
|
*
|
2018-05-21 00:11:52 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest $request
|
|
|
|
* @param int $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-22 19:07:51 +00:00
|
|
|
*
|
|
|
|
* @throws \Exception
|
2017-03-05 21:37:38 +00:00
|
|
|
*/
|
2018-05-21 00:11:52 +00:00
|
|
|
public function newDatabase(StoreServerDatabaseRequest $request, $server)
|
2017-03-05 21:37:38 +00:00
|
|
|
{
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->databaseManagementService->create($server, [
|
2017-07-22 18:55:30 +00:00
|
|
|
'database' => $request->input('database'),
|
|
|
|
'remote' => $request->input('remote'),
|
|
|
|
'database_host_id' => $request->input('database_host_id'),
|
|
|
|
]);
|
2017-03-05 21:37:38 +00:00
|
|
|
|
2017-07-23 20:09:25 +00:00
|
|
|
return redirect()->route('admin.servers.view.database', $server)->withInput();
|
2017-03-05 21:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the database password for a specific database on this server.
|
2017-03-19 23:36:50 +00:00
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $server
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-22 19:07:51 +00:00
|
|
|
*
|
|
|
|
* @throws \Exception
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-03-05 21:37:38 +00:00
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function resetDatabasePassword(Request $request, $server)
|
2017-03-05 21:37:38 +00:00
|
|
|
{
|
2017-07-22 19:07:51 +00:00
|
|
|
$database = $this->databaseRepository->findFirstWhere([
|
2017-07-23 20:09:25 +00:00
|
|
|
['server_id', '=', $server],
|
2017-07-22 19:07:51 +00:00
|
|
|
['id', '=', $request->input('database')],
|
|
|
|
]);
|
2017-03-05 21:37:38 +00:00
|
|
|
|
2017-10-19 03:32:19 +00:00
|
|
|
$this->databasePasswordService->handle($database, str_random(20));
|
2017-03-05 21:37:38 +00:00
|
|
|
|
2017-07-22 19:07:51 +00:00
|
|
|
return response('', 204);
|
2017-03-05 21:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a database from a server.
|
2017-03-19 23:36:50 +00:00
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $server
|
|
|
|
* @param int $database
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-07-22 19:07:51 +00:00
|
|
|
*
|
|
|
|
* @throws \Exception
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-03-05 21:37:38 +00:00
|
|
|
*/
|
2017-07-23 20:09:25 +00:00
|
|
|
public function deleteDatabase($server, $database)
|
2017-03-05 21:37:38 +00:00
|
|
|
{
|
2017-07-22 19:07:51 +00:00
|
|
|
$database = $this->databaseRepository->findFirstWhere([
|
2017-07-23 20:09:25 +00:00
|
|
|
['server_id', '=', $server],
|
2017-07-22 19:07:51 +00:00
|
|
|
['id', '=', $database],
|
|
|
|
]);
|
2017-03-05 21:37:38 +00:00
|
|
|
|
2017-07-25 02:34:10 +00:00
|
|
|
$this->databaseManagementService->delete($database->id);
|
2017-03-05 21:37:38 +00:00
|
|
|
|
2017-07-22 19:07:51 +00:00
|
|
|
return response('', 204);
|
2017-03-05 21:37:38 +00:00
|
|
|
}
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|