More code updates

This commit is contained in:
Dane Everitt 2017-10-07 17:21:41 -05:00
parent cc297eea09
commit 17642bffe7
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
32 changed files with 209 additions and 2863 deletions

View file

@ -1,36 +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\Http\Controllers\API\Admin;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Location;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Transformers\Admin\LocationTransformer;
class LocationController extends Controller
{
/**
* Controller to handle returning all locations on the system.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('location-list', $request->apiKey());
return Fractal::create()
->collection(Location::all())
->transformWith(new LocationTransformer($request))
->withResourceName('location')
->toArray();
}
}

View file

@ -1,159 +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\Http\Controllers\API\Admin;
use Log;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Node;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\NodeRepository;
use Pterodactyl\Transformers\Admin\NodeTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
class NodeController extends Controller
{
/**
* Controller to handle returning all nodes on the system.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('node-list', $request->apiKey());
$nodes = Node::paginate(config('pterodactyl.paginate.api.nodes'));
$fractal = Fractal::create()->collection($nodes)
->transformWith(new NodeTransformer($request))
->withResourceName('user')
->paginateWith(new IlluminatePaginatorAdapter($nodes));
if (config('pterodactyl.api.include_on_list') && $request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->toArray();
}
/**
* Display information about a single node on the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return array
*/
public function view(Request $request, $id)
{
$this->authorize('node-view', $request->apiKey());
$fractal = Fractal::create()->item(Node::findOrFail($id));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->transformWith(new NodeTransformer($request))
->withResourceName('node')
->toArray();
}
/**
* Display information about a single node on the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\JsonResponse
*/
public function viewConfig(Request $request, $id)
{
$this->authorize('node-view-config', $request->apiKey());
$node = Node::findOrFail($id);
return response()->json(json_decode($node->getConfigurationAsJson()));
}
/**
* Create a new node on the system.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse|array
*/
public function store(Request $request)
{
$this->authorize('node-create', $request->apiKey());
$repo = new NodeRepository;
try {
$node = $repo->create(array_merge(
$request->only([
'public', 'disk_overallocate', 'memory_overallocate',
]),
$request->intersect([
'name', 'location_id', 'fqdn',
'scheme', 'memory', 'disk',
'daemonBase', 'daemonSFTP', 'daemonListen',
])
));
$fractal = Fractal::create()->item($node)->transformWith(new NodeTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('node')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to create this node. Please try again.',
], 500);
}
}
/**
* Delete a node from the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function delete(Request $request, $id)
{
$this->authorize('node-delete', $request->apiKey());
$repo = new NodeRepository;
try {
$repo->delete($id);
return response('', 204);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to delete this node. Please try again.',
], 500);
}
}
}

View file

@ -1,414 +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\Http\Controllers\API\Admin;
use Log;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\TransferException;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\ServerRepository;
use Pterodactyl\Transformers\Admin\ServerTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
class ServerController extends Controller
{
/**
* Controller to handle returning all servers on the system.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('server-list', $request->apiKey());
$servers = Server::paginate(config('pterodactyl.paginate.api.servers'));
$fractal = Fractal::create()->collection($servers)
->transformWith(new ServerTransformer($request))
->withResourceName('user')
->paginateWith(new IlluminatePaginatorAdapter($servers));
if (config('pterodactyl.api.include_on_list') && $request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->toArray();
}
/**
* Controller to handle returning information on a single server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return array
*/
public function view(Request $request, $id)
{
$this->authorize('server-view', $request->apiKey());
$server = Server::findOrFail($id);
$fractal = Fractal::create()->item($server);
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->transformWith(new ServerTransformer($request))
->withResourceName('server')
->toArray();
}
/**
* Create a new server on the system.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse|array
*/
public function store(Request $request)
{
$this->authorize('server-create', $request->apiKey());
$repo = new ServerRepository;
try {
$server = $repo->create($request->all());
$fractal = Fractal::create()->item($server)->transformWith(new ServerTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('server')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
], 500);
}
}
/**
* Delete a server from the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function delete(Request $request, $id)
{
$this->authorize('server-delete', $request->apiKey());
$repo = new ServerRepository;
try {
$repo->delete($id, $request->has('force_delete'));
return response('', 204);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
], 500);
}
}
/**
* Update the details for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\JsonResponse|array
*/
public function details(Request $request, $id)
{
$this->authorize('server-edit-details', $request->apiKey());
$repo = new ServerRepository;
try {
$server = $repo->updateDetails($id, $request->intersect([
'owner_id', 'name', 'description', 'reset_token',
]));
$fractal = Fractal::create()->item($server)->transformWith(new ServerTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('server')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify this server. Please try again.',
], 500);
}
}
/**
* Set the new docker container for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\RedirectResponse|array
*/
public function container(Request $request, $id)
{
$this->authorize('server-edit-container', $request->apiKey());
$repo = new ServerRepository;
try {
$server = $repo->updateContainer($id, $request->intersect('docker_image'));
$fractal = Fractal::create()->item($server)->transformWith(new ServerTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('server')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify this server container. Please try again.',
], 500);
}
}
/**
* Toggles the install status for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function install(Request $request, $id)
{
$this->authorize('server-install', $request->apiKey());
$repo = new ServerRepository;
try {
$repo->toggleInstall($id);
return response('', 204);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to toggle the install status for this server. Please try again.',
], 500);
}
}
/**
* Setup a server to have a container rebuild.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function rebuild(Request $request, $id)
{
$this->authorize('server-rebuild', $request->apiKey());
$server = Server::with('node')->findOrFail($id);
try {
$server->node->guzzleClient([
'X-Access-Server' => $server->uuid,
'X-Access-Token' => $server->node->daemonSecret,
])->request('POST', '/server/rebuild');
return response('', 204);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
}
}
/**
* Manage the suspension status for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function suspend(Request $request, $id)
{
$this->authorize('server-suspend', $request->apiKey());
$repo = new ServerRepository;
$action = $request->input('action');
if (! in_array($action, ['suspend', 'unsuspend'])) {
return response()->json([
'error' => 'The action provided was invalid. Action should be one of: suspend, unsuspend.',
], 400);
}
try {
$repo->toggleAccess($id, ($action === 'unsuspend'));
return response('', 204);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to ' . $action . ' this server. Please try again.',
], 500);
}
}
/**
* Update the build configuration for a server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\JsonResponse|array
*/
public function build(Request $request, $id)
{
$this->authorize('server-edit-build', $request->apiKey());
$repo = new ServerRepository;
try {
$server = $repo->changeBuild($id, $request->intersect([
'allocation_id', 'add_allocations', 'remove_allocations',
'memory', 'swap', 'io', 'cpu',
]));
$fractal = Fractal::create()->item($server)->transformWith(new ServerTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('server')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify the build settings for this server. Please try again.',
], 500);
}
}
/**
* Update the startup command as well as variables.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function startup(Request $request, $id)
{
$this->authorize('server-edit-startup', $request->apiKey());
$repo = new ServerRepository;
try {
$repo->updateStartup($id, $request->all(), true);
return response('', 204);
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify the startup settings for this server. Please try again.',
], 500);
}
}
}

View file

@ -1,59 +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\Http\Controllers\API\Admin;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Nest;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Transformers\Admin\ServiceTransformer;
class ServiceController extends Controller
{
/**
* Controller to handle returning all locations on the system.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('service-list', $request->apiKey());
return Fractal::create()
->collection(Nest::all())
->transformWith(new ServiceTransformer($request))
->withResourceName('service')
->toArray();
}
/**
* Controller to handle returning information on a single server.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return array
*/
public function view(Request $request, $id)
{
$this->authorize('service-view', $request->apiKey());
$service = Nest::findOrFail($id);
$fractal = Fractal::create()->item($service);
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->transformWith(new ServiceTransformer($request))
->withResourceName('service')
->toArray();
}
}

View file

@ -1,170 +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\Http\Controllers\API\Admin;
use Log;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\oldUserRepository;
use Pterodactyl\Transformers\Admin\UserTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
class UserController extends Controller
{
/**
* Controller to handle returning all users on the system.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('user-list', $request->apiKey());
$users = User::paginate(config('pterodactyl.paginate.api.users'));
$fractal = Fractal::create()->collection($users)
->transformWith(new UserTransformer($request))
->withResourceName('user')
->paginateWith(new IlluminatePaginatorAdapter($users));
if (config('pterodactyl.api.include_on_list') && $request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->toArray();
}
/**
* Display information about a single user on the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return array
*/
public function view(Request $request, $id)
{
$this->authorize('user-view', $request->apiKey());
$fractal = Fractal::create()->item(User::findOrFail($id));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->transformWith(new UserTransformer($request))
->withResourceName('user')
->toArray();
}
/**
* Create a new user on the system.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse|array
*/
public function store(Request $request)
{
$this->authorize('user-create', $request->apiKey());
$repo = new oldUserRepository;
try {
$user = $repo->create($request->only([
'custom_id', 'email', 'password', 'name_first',
'name_last', 'username', 'root_admin',
]));
$fractal = Fractal::create()->item($user)->transformWith(new UserTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('user')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to create this user. Please try again.',
], 500);
}
}
/**
* Update a user.
*
* @param \Illuminate\Http\Request $request
* @param int $user
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $user)
{
$this->authorize('user-edit', $request->apiKey());
$repo = new oldUserRepository;
try {
$user = $repo->update($user, $request->intersect([
'email', 'password', 'name_first',
'name_last', 'username', 'root_admin',
]));
$fractal = Fractal::create()->item($user)->transformWith(new UserTransformer($request));
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->withResourceName('user')->toArray();
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => json_decode($ex->getMessage()),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to update this user. Please try again.',
], 500);
}
}
/**
* Delete a user from the system.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function delete(Request $request, $id)
{
$this->authorize('user-delete', $request->apiKey());
$repo = new oldUserRepository;
try {
$repo->delete($id);
return response('', 204);
} catch (DisplayException $ex) {
return response()->json([
'error' => $ex->getMessage(),
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to delete this user. Please try again.',
], 500);
}
}
}

View file

@ -11,13 +11,13 @@ namespace Pterodactyl\Http\Controllers\API\Remote;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Eggs\EggConfigurationService;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface; use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Services\Services\Options\EggConfigurationService;
class OptionRetrievalController extends Controller class EggRetrievalController extends Controller
{ {
/** /**
* @var \Pterodactyl\Services\Services\Options\EggConfigurationService * @var \Pterodactyl\Services\Eggs\EggConfigurationService
*/ */
protected $configurationFileService; protected $configurationFileService;
@ -29,8 +29,8 @@ class OptionRetrievalController extends Controller
/** /**
* OptionUpdateController constructor. * OptionUpdateController constructor.
* *
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository * @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Services\Options\EggConfigurationService $configurationFileService * @param \Pterodactyl\Services\Eggs\EggConfigurationService $configurationFileService
*/ */
public function __construct( public function __construct(
EggRepositoryInterface $repository, EggRepositoryInterface $repository,
@ -41,7 +41,7 @@ class OptionRetrievalController extends Controller
} }
/** /**
* Return a JSON array of service options and the SHA1 hash of thier configuration file. * Return a JSON array of Eggs and the SHA1 hash of thier configuration file.
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
@ -58,7 +58,7 @@ class OptionRetrievalController extends Controller
} }
/** /**
* Return the configuration file for a single service option for the Daemon. * Return the configuration file for a single Egg for the Daemon.
* *
* @param string $uuid * @param string $uuid
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse

View file

@ -1,36 +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\Http\Controllers\API\User;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Transformers\User\OverviewTransformer;
class CoreController extends Controller
{
/**
* Controller to handle base user request for all of their servers.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function index(Request $request)
{
$this->authorize('user.server-list', $request->apiKey());
$servers = $request->user()->access('service', 'node', 'allocation', 'option')->get();
return Fractal::collection($servers)
->transformWith(new OverviewTransformer)
->withResourceName('server')
->toArray();
}
}

View file

@ -1,84 +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\Http\Controllers\API\User;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Transformers\User\ServerTransformer;
use Pterodactyl\Repositories\old_Daemon\PowerRepository;
use Pterodactyl\Repositories\old_Daemon\CommandRepository;
class ServerController extends Controller
{
/**
* Controller to handle base request for individual server information.
*
* @param \Illuminate\Http\Request $request
* @param string $uuid
* @return array
*/
public function index(Request $request, $uuid)
{
$this->authorize('user.server-view', $request->apiKey());
$server = Server::byUuid($uuid);
$fractal = Fractal::create()->item($server);
if ($request->input('include')) {
$fractal->parseIncludes(explode(',', $request->input('include')));
}
return $fractal->transformWith(new ServerTransformer)
->withResourceName('server')
->toArray();
}
/**
* Controller to handle request for server power toggle.
*
* @param \Illuminate\Http\Request $request
* @param string $uuid
* @return \Illuminate\Http\Response
*/
public function power(Request $request, $uuid)
{
$this->authorize('user.server-power', $request->apiKey());
$server = Server::byUuid($uuid);
$request->user()->can('power-' . $request->input('action'), $server);
$repo = new PowerRepository($server, $request->user());
$repo->do($request->input('action'));
return response('', 204)->header('Content-Type', 'application/json');
}
/**
* Controller to handle base request for individual server information.
*
* @param \Illuminate\Http\Request $request
* @param string $uuid
* @return \Illuminate\Http\Response
*/
public function command(Request $request, $uuid)
{
$this->authorize('user.server-command', $request->apiKey());
$server = Server::byUuid($uuid);
$request->user()->can('send-command', $server);
$repo = new CommandRepository($server, $request->user());
$repo->send($request->input('command'));
return response('', 204)->header('Content-Type', 'application/json');
}
}

View file

@ -91,6 +91,11 @@ class ServersController extends Controller
*/ */
protected $locationRepository; protected $locationRepository;
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $nestRepository;
/** /**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface * @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
*/ */
@ -111,11 +116,6 @@ class ServersController extends Controller
*/ */
protected $service; protected $service;
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $serviceRepository;
/** /**
* @var \Pterodactyl\Services\Servers\StartupModificationService * @var \Pterodactyl\Services\Servers\StartupModificationService
*/ */
@ -144,7 +144,7 @@ class ServersController extends Controller
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService * @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository * @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository * @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService * @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService * @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/ */
@ -164,7 +164,7 @@ class ServersController extends Controller
NodeRepositoryInterface $nodeRepository, NodeRepositoryInterface $nodeRepository,
ReinstallServerService $reinstallService, ReinstallServerService $reinstallService,
ServerRepositoryInterface $repository, ServerRepositoryInterface $repository,
NestRepositoryInterface $serviceRepository, NestRepositoryInterface $nestRepository,
StartupModificationService $startupModificationService, StartupModificationService $startupModificationService,
SuspensionService $suspensionService SuspensionService $suspensionService
) { ) {
@ -179,11 +179,11 @@ class ServersController extends Controller
$this->detailsModificationService = $detailsModificationService; $this->detailsModificationService = $detailsModificationService;
$this->deletionService = $deletionService; $this->deletionService = $deletionService;
$this->locationRepository = $locationRepository; $this->locationRepository = $locationRepository;
$this->nestRepository = $nestRepository;
$this->nodeRepository = $nodeRepository; $this->nodeRepository = $nodeRepository;
$this->reinstallService = $reinstallService; $this->reinstallService = $reinstallService;
$this->repository = $repository; $this->repository = $repository;
$this->service = $service; $this->service = $service;
$this->serviceRepository = $serviceRepository;
$this->startupModificationService = $startupModificationService; $this->startupModificationService = $startupModificationService;
$this->suspensionService = $suspensionService; $this->suspensionService = $suspensionService;
} }
@ -218,19 +218,19 @@ class ServersController extends Controller
return redirect()->route('admin.nodes'); return redirect()->route('admin.nodes');
} }
$services = $this->serviceRepository->getWithOptions(); $nests = $this->nestRepository->getWithEggs();
Javascript::put([ Javascript::put([
'services' => $services->map(function ($item) { 'nests' => $nests->map(function ($item) {
return array_merge($item->toArray(), [ return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(), 'eggs' => $item->eggs->keyBy('id')->toArray(),
]); ]);
})->keyBy('id'), })->keyBy('id'),
]); ]);
return view('admin.servers.new', [ return view('admin.servers.new', [
'locations' => $this->locationRepository->all(), 'locations' => $this->locationRepository->all(),
'services' => $services, 'nests' => $nests,
]); ]);
} }
@ -331,12 +331,12 @@ class ServersController extends Controller
abort(404); abort(404);
} }
$services = $this->serviceRepository->getWithOptions(); $nests = $this->nestRepository->getWithEggs();
Javascript::put([ Javascript::put([
'services' => $services->map(function ($item) { 'nests' => $nests->map(function ($item) {
return array_merge($item->toArray(), [ return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(), 'eggs' => $item->eggs->keyBy('id')->toArray(),
]); ]);
})->keyBy('id'), })->keyBy('id'),
'server_variables' => $parameters->data, 'server_variables' => $parameters->data,
@ -344,7 +344,7 @@ class ServersController extends Controller
return view('admin.servers.view.startup', [ return view('admin.servers.view.startup', [
'server' => $parameters->server, 'server' => $parameters->server,
'services' => $services, 'nests' => $nests,
]); ]);
} }
@ -402,7 +402,7 @@ class ServersController extends Controller
public function setDetails(Request $request, Server $server) public function setDetails(Request $request, Server $server)
{ {
$this->detailsModificationService->edit($server, $request->only([ $this->detailsModificationService->edit($server, $request->only([
'owner_id', 'name', 'description', 'reset_token', 'owner_id', 'name', 'description',
])); ]));
$this->alert->success(trans('admin/server.alerts.details_updated'))->flash(); $this->alert->success(trans('admin/server.alerts.details_updated'))->flash();

View file

@ -159,6 +159,7 @@ class UserController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* *
* @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function update(UserFormRequest $request, User $user) public function update(UserFormRequest $request, User $user)
{ {

View file

@ -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\Http\Controllers\Daemon;
use Pterodactyl\Models\Egg;
use Illuminate\Http\Request;
use Pterodactyl\Models\Nest;
use Pterodactyl\Http\Controllers\Controller;
class ServiceController extends Controller
{
/**
* Returns a listing of all services currently on the system,
* as well as the associated files and the file hashes for
* caching purposes.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function listServices(Request $request)
{
$response = [];
foreach (Nest::all() as $service) {
$response[$service->folder] = [
'main.json' => sha1($this->getConfiguration($service->id)->toJson()),
'index.js' => sha1($service->index_file),
];
}
return response()->json($response);
}
/**
* Returns the contents of the requested file for the given service.
*
* @param \Illuminate\Http\Request $request
* @param string $folder
* @param string $file
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\FileResponse
*/
public function pull(Request $request, $folder, $file)
{
$service = Nest::where('folder', $folder)->firstOrFail();
if ($file === 'index.js') {
return response($service->index_file)->header('Content-Type', 'text/plain');
} elseif ($file === 'main.json') {
return response()->json($this->getConfiguration($service->id));
}
return abort(404);
}
/**
* Returns a `main.json` file based on the configuration
* of each service option.
*
* @param int $id
* @return \Illuminate\Support\Collection
*/
protected function getConfiguration($id)
{
$options = Egg::where('service_id', $id)->get();
return $options->mapWithKeys(function ($item) use ($options) {
return [
$item->tag => array_filter([
'symlink' => $options->where('id', $item->config_from)->pluck('tag')->pop(),
'startup' => json_decode($item->config_startup),
'stop' => $item->config_stop,
'configs' => json_decode($item->config_files),
'log' => json_decode($item->config_logs),
'query' => 'none',
]),
];
});
}
}

View file

@ -54,7 +54,7 @@ class Egg extends Model implements CleansAttributes, ValidableContract
* @var array * @var array
*/ */
protected $casts = [ protected $casts = [
'service_id' => 'integer', 'nest_id' => 'integer',
'config_from' => 'integer', 'config_from' => 'integer',
'script_is_privileged' => 'boolean', 'script_is_privileged' => 'boolean',
'copy_script_from' => 'integer', 'copy_script_from' => 'integer',

View file

@ -140,8 +140,9 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
*/ */
public function getDaemonServiceData($id) public function getDaemonServiceData($id)
{ {
$instance = $this->getBuilder()->with('egg.nest', 'pack')->find($id, $this->getColumns()); Assert::integerish($id, 'First argument passed to getDaemonServiceData must be integer, received %s.');
$instance = $this->getBuilder()->with('egg.nest', 'pack')->find($id, $this->getColumns());
if (! $instance) { if (! $instance) {
throw new RecordNotFoundException(); throw new RecordNotFoundException();
} }

View file

@ -47,7 +47,7 @@ class InstallScriptService
} }
if (! is_null(array_get($data, 'copy_script_from'))) { if (! is_null(array_get($data, 'copy_script_from'))) {
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $egg->service_id)) { if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) {
throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id')); throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id'));
} }
} }

View file

@ -145,8 +145,8 @@ class ServerCreationService
'cpu' => $data['cpu'], 'cpu' => $data['cpu'],
'oom_disabled' => isset($data['oom_disabled']), 'oom_disabled' => isset($data['oom_disabled']),
'allocation_id' => $data['allocation_id'], 'allocation_id' => $data['allocation_id'],
'service_id' => $data['service_id'], 'nest_id' => $data['nest_id'],
'option_id' => $data['option_id'], 'egg_id' => $data['egg_id'],
'pack_id' => (! isset($data['pack_id']) || $data['pack_id'] == 0) ? null : $data['pack_id'], 'pack_id' => (! isset($data['pack_id']) || $data['pack_id'] == 0) ? null : $data['pack_id'],
'startup' => $data['startup'], 'startup' => $data['startup'],
'daemonSecret' => str_random(NodeCreationService::DAEMON_SECRET_LENGTH), 'daemonSecret' => str_random(NodeCreationService::DAEMON_SECRET_LENGTH),

View file

@ -110,8 +110,8 @@ class StartupModificationService
} }
if ( if (
$server->service_id != array_get($data, 'service_id', $server->service_id) || $server->nest_id != array_get($data, 'nest_id', $server->nest_id) ||
$server->option_id != array_get($data, 'option_id', $server->option_id) || $server->egg_id != array_get($data, 'egg_id', $server->egg_id) ||
$server->pack_id != array_get($data, 'pack_id', $server->pack_id) $server->pack_id != array_get($data, 'pack_id', $server->pack_id)
) { ) {
$hasServiceChanges = true; $hasServiceChanges = true;
@ -121,7 +121,7 @@ class StartupModificationService
if (isset($data['environment'])) { if (isset($data['environment'])) {
$validator = $this->validatorService->isAdmin($this->admin) $validator = $this->validatorService->isAdmin($this->admin)
->setFields($data['environment']) ->setFields($data['environment'])
->validate(array_get($data, 'option_id', $server->option_id)); ->validate(array_get($data, 'egg_id', $server->egg_id));
foreach ($validator->getResults() as $result) { foreach ($validator->getResults() as $result) {
$this->serverVariableRepository->withoutFresh()->updateOrCreate([ $this->serverVariableRepository->withoutFresh()->updateOrCreate([
@ -143,15 +143,15 @@ class StartupModificationService
$server = $this->repository->update($server->id, [ $server = $this->repository->update($server->id, [
'installed' => 0, 'installed' => 0,
'startup' => array_get($data, 'startup', $server->startup), 'startup' => array_get($data, 'startup', $server->startup),
'service_id' => array_get($data, 'service_id', $server->service_id), 'nest_id' => array_get($data, 'nest_id', $server->nest_id),
'option_id' => array_get($data, 'option_id', $server->service_id), 'egg_id' => array_get($data, 'egg_id', $server->egg_id),
'pack_id' => array_get($data, 'pack_id', $server->pack_id), 'pack_id' => array_get($data, 'pack_id', $server->pack_id) > 0 ? array_get($data, 'pack_id', $server->pack_id) : null,
'skip_scripts' => isset($data['skip_scripts']), 'skip_scripts' => isset($data['skip_scripts']),
]); ]);
if (isset($hasServiceChanges)) { if (isset($hasServiceChanges)) {
$daemonData['service'] = array_merge( $daemonData['service'] = array_merge(
$this->repository->withColumns(['id', 'option_id', 'pack_id'])->getDaemonServiceData($server), $this->repository->withColumns(['id', 'egg_id', 'pack_id'])->getDaemonServiceData($server->id),
['skip_scripts' => isset($data['skip_scripts'])] ['skip_scripts' => isset($data['skip_scripts'])]
); );
} }

View file

@ -106,7 +106,7 @@ class VariableValidatorService
*/ */
public function validate($option) public function validate($option)
{ {
$variables = $this->optionVariableRepository->findWhere([['option_id', '=', $option]]); $variables = $this->optionVariableRepository->findWhere([['egg_id', '=', $option]]);
if (count($variables) === 0) { if (count($variables) === 0) {
$this->results = []; $this->results = [];

View file

@ -102,7 +102,7 @@ $factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker
return [ return [
'id' => $faker->unique()->randomNumber(), 'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid, 'uuid' => $faker->unique()->uuid,
'service_id' => $faker->unique()->randomNumber(), 'nest_id' => $faker->unique()->randomNumber(),
'name' => $faker->name, 'name' => $faker->name,
'description' => implode(' ', $faker->sentences(3)), 'description' => implode(' ', $faker->sentences(3)),
'startup' => 'java -jar test.jar', 'startup' => 'java -jar test.jar',

View file

@ -12,12 +12,6 @@ class DatabaseSeeder extends Seeder
{ {
Model::unguard(); Model::unguard();
$this->call(MinecraftServiceTableSeeder::class);
$this->call(SourceServiceTableSeeder::class);
$this->call(RustServiceTableSeeder::class);
$this->call(TerrariaServiceTableSeeder::class);
$this->call(VoiceServiceTableSeeder::class);
Model::reguard(); Model::reguard();
} }
} }

View file

@ -1,411 +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
*/
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\EggVariable;
class MinecraftServiceTableSeeder extends Seeder
{
/**
* The core service ID.
*
* @var \Pterodactyl\Models\Nest
*/
protected $service;
/**
* Stores all of the option objects.
*
* @var array
*/
protected $option = [];
private $default_mc = <<<'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 {
onConsole(data) {
// Hide the output spam from Bungeecord getting pinged.
if (_.endsWith(data, '<-> InitialHandler has connected')) return;
return super.onConsole(data);
}
}
module.exports = Service;
EOF;
/**
* Run the database seeds.
*/
public function run()
{
$this->addCoreService();
$this->addCoreOptions();
$this->addVariables();
}
private function addCoreService()
{
$this->service = Nest::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'minecraft',
], [
'name' => 'Minecraft',
'description' => 'Minecraft - the classic game from Mojang. With support for Vanilla MC, Spigot, and many others!',
'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
'index_file' => $this->default_mc,
]);
}
private function addCoreOptions()
{
$script = <<<'EOF'
#!/bin/ash
# Vanilla MC Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl
cd /mnt/server
LATEST_VERSION=`curl -s https://s3.amazonaws.com/Minecraft.Download/versions/versions.json | grep -o "[[:digit:]]\.[0-9]*\.[0-9]" | head -n 1`
if [ -z "$VANILLA_VERSION" ] || [ "$VANILLA_VERSION" == "latest" ]; then
DL_VERSION=$LATEST_VERSION
else
DL_VERSION=$VANILLA_VERSION
fi
curl -o ${SERVER_JARFILE} https://s3.amazonaws.com/Minecraft.Download/versions/${DL_VERSION}/minecraft_server.${DL_VERSION}.jar
EOF;
$this->option['vanilla'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'vanilla',
], [
'name' => 'Vanilla Minecraft',
'description' => 'Minecraft is a game about placing blocks and going on adventures. Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in Creative Mode with unlimited resources or mine deep in Survival Mode, crafting weapons and armor to fend off dangerous mobs. Do all this alone or with friends.',
'docker_image' => 'quay.io/pterodactyl/core:java',
'config_startup' => '{"done": ")! For help, type ", "userInteraction": [ "Go to eula.txt for more info."]}',
'config_logs' => '{"custom": false, "location": "logs/latest.log"}',
'config_files' => '{"server.properties":{"parser": "properties", "find":{"server-ip": "0.0.0.0", "server-port": "{{server.build.default.port}}"}}}',
'config_stop' => 'stop',
'config_from' => null,
'startup' => null,
'script_install' => $script,
]);
$script = <<<'EOF'
#!/bin/ash
# Spigot Installation Script
#
# Server Files: /mnt/server
## Only download if a path is provided, otherwise continue.
if [ ! -z "${DL_PATH}" ]; then
apk update
apk add curl
cd /mnt/server
MODIFIED_DOWNLOAD=`eval echo $(echo ${DL_PATH} | sed -e 's/{{/${/g' -e 's/}}/}/g')`
curl -sSL -o ${SERVER_JARFILE} ${MODIFIED_DOWNLOAD}
fi
EOF;
$this->option['spigot'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'spigot',
], [
'name' => 'Spigot',
'description' => 'Spigot is the most widely-used modded Minecraft server software in the world. It powers many of the top Minecraft server networks around to ensure they can cope with their huge player base and ensure the satisfaction of their players. Spigot works by reducing and eliminating many causes of lag, as well as adding in handy features and settings that help make your job of server administration easier.',
'docker_image' => 'quay.io/pterodactyl/core:java-glibc',
'config_startup' => null,
'config_files' => '{"spigot.yml":{"parser": "yaml", "find":{"settings.restart-on-crash": false}}}',
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['vanilla']->id,
'startup' => null,
'script_install' => $script,
]);
$script = <<<'EOF'
#!/bin/ash
# Sponge Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl
cd /mnt/server
curl -sSL "https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/${SPONGE_VERSION}/spongevanilla-${SPONGE_VERSION}.jar" -o ${SERVER_JARFILE}
EOF;
$this->option['sponge'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'sponge',
], [
'name' => 'Sponge (SpongeVanilla)',
'description' => 'SpongeVanilla is the SpongeAPI implementation for Vanilla Minecraft.',
'docker_image' => 'quay.io/pterodactyl/core:java-glibc',
'config_startup' => '{"userInteraction": [ "You need to agree to the EULA"]}',
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['vanilla']->id,
'startup' => null,
'script_install' => $script,
]);
$script = <<<'EOF'
#!/bin/ash
# Bungeecord Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl
cd /mnt/server
if [ -z "${BUNGEE_VERSION}" ] || [ "${BUNGEE_VERSION}" == "latest" ]; then
BUNGEE_VERSION="lastStableBuild"
fi
curl -o ${SERVER_JARFILE} https://ci.md-5.net/job/BungeeCord/${BUNGEE_VERSION}/artifact/bootstrap/target/BungeeCord.jar
EOF;
$this->option['bungeecord'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'bungeecord',
], [
'name' => 'Bungeecord',
'description' => 'For a long time, Minecraft server owners have had a dream that encompasses a free, easy, and reliable way to connect multiple Minecraft servers together. BungeeCord is the answer to said dream. Whether you are a small server wishing to string multiple game-modes together, or the owner of the ShotBow Network, BungeeCord is the ideal solution for you. With the help of BungeeCord, you will be able to unlock your community\'s full potential.',
'docker_image' => 'quay.io/pterodactyl/core:java',
'config_startup' => '{"done": "Listening on ", "userInteraction": [ "Listening on /0.0.0.0:25577"]}',
'config_files' => '{"config.yml":{"parser": "yaml", "find":{"listeners[0].host": "0.0.0.0:{{server.build.default.port}}", "servers.*.address":{"127.0.0.1": "{{config.docker.interface}}", "localhost": "{{config.docker.interface}}"}}}}',
'config_logs' => '{"custom": false, "location": "proxy.log.0"}',
'config_stop' => 'end',
'config_from' => null,
'startup' => null,
'script_install' => $script,
]);
$script = <<<'EOF'
#!/bin/ash
# Forge Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl
GET_VERSIONS=$(curl -sl http://files.minecraftforge.net/maven/net/minecraftforge/forge/ | grep -A1 Latest | grep -o -e '[1]\.[0-9][0-9] - [0-9][0-9]\.[0-9][0-9]\.[0-9]\.[0-9][0-9][0-9][0-9]')
LATEST_VERSION=$(echo $GET_VERSIONS | sed 's/ //g')
cd /mnt/server
curl -sS http://files.minecraftforge.net/maven/net/minecraftforge/forge/$LATEST_VERSION/forge-$LATEST_VERSION-installer.jar -o installer.jar
curl -sS http://files.minecraftforge.net/maven/net/minecraftforge/forge/$LATEST_VERSION/forge-$LATEST_VERSION-universal.jar -o server.jar
java -jar installer.jar --installServer
rm -rf installer.jar
EOF;
$this->option['forge'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'forge',
], [
'name' => 'Forge Minecraft',
'description' => 'Minecraft Forge Server. Minecraft Forge is a modding API (Application Programming Interface), which makes it easier to create mods, and also make sure mods are compatible with each other.',
'docker_image' => 'quay.io/pterodactyl/core:java',
'config_startup' => '{"done": ")! For help, type ", "userInteraction": [ "Go to eula.txt for more info."]}',
'config_logs' => '{"custom": false, "location": "logs/latest.log"}',
'config_files' => '{"server.properties":{"parser": "properties", "find":{"server-ip": "0.0.0.0", "server-port": "{{server.build.default.port}}"}}}',
'config_stop' => 'stop',
'config_from' => null,
'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
'script_install' => $script,
'script_container' => 'frolvlad/alpine-oraclejdk8:cleaned',
]);
}
private function addVariables()
{
$this->addVanillaVariables();
$this->addSpigotVariables();
$this->addSpongeVariables();
$this->addBungeecordVariables();
$this->addForgeVariables();
}
private function addVanillaVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['vanilla']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the server jarfile to run the server with.',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['vanilla']->id,
'env_variable' => 'VANILLA_VERSION',
], [
'name' => 'Server Version',
'description' => 'The version of Minecraft Vanilla to install. Use "latest" to install the latest version.',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|between:3,7',
]);
}
private function addSpigotVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the server jarfile to run the server with.',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'DL_VERSION',
], [
'name' => 'Spigot Version',
'description' => 'The version of Spigot to download (using the --rev tag). Use "latest" for latest.',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|between:3,7',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['spigot']->id,
'env_variable' => 'DL_PATH',
], [
'name' => 'Download Path',
'description' => 'A URL to use to download Spigot rather than building it on the server. This is not user viewable. Use <code>{{DL_VERSION}}</code> in the URL to automatically insert the assigned version into the URL. If you do not enter a URL Spigot will build directly in the container (this will fail on low memory containers).',
'default_value' => '',
'user_viewable' => 0,
'user_editable' => 0,
'rules' => 'string',
]);
}
private function addSpongeVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['sponge']->id,
'env_variable' => 'SPONGE_VERSION',
], [
'name' => 'Sponge Version',
'description' => 'The version of SpongeVanilla to download and use.',
'default_value' => '1.10.2-5.2.0-BETA-381',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|regex:/^([a-zA-Z0-9.\-_]+)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['sponge']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the Jarfile to use when running SpongeVanilla.',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
}
private function addBungeecordVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['bungeecord']->id,
'env_variable' => 'BUNGEE_VERSION',
], [
'name' => 'Bungeecord Version',
'description' => 'The version of Bungeecord to download and use.',
'default_value' => 'latest',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|alpha_num|between:1,6',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['bungeecord']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Bungeecord Jar File',
'description' => 'The name of the Jarfile to use when running Bungeecord.',
'default_value' => 'bungeecord.jar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
}
private function addForgeVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['forge']->id,
'env_variable' => 'SERVER_JARFILE',
], [
'name' => 'Server Jar File',
'description' => 'The name of the Jarfile to use when running Forge Mod.',
'default_value' => 'server.jar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
]);
}
}

View file

@ -1,416 +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
*/
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Traits\Services\CreatesServiceIndex;
class RustServiceTableSeeder extends Seeder
{
use CreatesServiceIndex;
/**
* The core service ID.
*
* @var Models\Service
*/
protected $service;
/**
* Stores all of the option objects.
*
* @var array
*/
protected $option = [];
/**
* Run the database seeds.
*/
public function run()
{
$this->addCoreService();
$this->addCoreOptions();
$this->addVariables();
}
private function addCoreService()
{
$this->service = Nest::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'rust',
], [
'name' => 'Rust',
'description' => 'The only aim in Rust is to survive. To do this you will need to overcome struggles such as hunger, thirst and cold. Build a fire. Build a shelter. Kill animals for meat. Protect yourself from other players, and kill them for meat. Create alliances with other players and form a town. Do whatever it takes to survive.',
'startup' => './RustDedicated -batchmode +server.port {{SERVER_PORT}} +server.identity "rust" +rcon.port {{RCON_PORT}} +rcon.web true +server.hostname \"{{HOSTNAME}}\" +server.level \"{{LEVEL}}\" +server.description \"{{DESCRIPTION}}\" +server.url \"{{URL}}\" +server.headerimage \"{{SERVER_IMG}}\" +server.worldsize \"{{WORLD_SIZE}}\" +server.seed \"{{SEED}}\" +server.maxplayers {{MAX_PLAYERS}} +rcon.password \"{{RCON_PASS}}\" {{ADDITIONAL_ARGS}}',
'index_file' => $this->getIndexScript(),
]);
}
private function addCoreOptions()
{
$script = <<<'EOF'
apt update
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steam
tar -xzvf steamcmd.tar.gz -C /mnt/server/steam
cd /mnt/server/steam
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 258550 +quit
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
EOF;
$this->option['rustvanilla'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'rustvanilla',
], [
'name' => 'Vanilla',
'description' => 'Vanilla Rust server.',
'docker_image' => 'quay.io/pterodactyl/core:rust',
'config_startup' => '{"done": "Server startup complete", "userInteraction": []}',
'config_files' => '{}',
'config_logs' => '{"custom": false, "location": "latest.log"}',
'config_stop' => 'quit',
'config_from' => null,
'startup' => null,
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
$script = <<<'EOF'
apt update
apt -y --no-install-recommends install curl unzip lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steam
tar -xzvf steamcmd.tar.gz -C /mnt/server/steam
cd /mnt/server/steam
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 258550 +quit
curl "https://dl.bintray.com/oxidemod/builds/Oxide-Rust.zip" > /mnt/server/oxide.zip
unzip -o /mnt/server/oxide.zip -d /mnt/server
rm /mnt/server/oxide.zip
echo "This file is used to determine whether the server is an OxideMod server or not.
Do not delete this file or you may loose OxideMod auto updating from the server." > /mnt/server/OXIDE_FLAG
mkdir -p /mnt/server/.steam/sdk32
cp -v /mnt/server/steam/linux32/steamclient.so /mnt/server/.steam/sdk32/steamclient.so
EOF;
$this->option['rustoxide'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'rustoxide',
], [
'name' => 'OxideMod',
'description' => 'OxideMod Rust server.',
'docker_image' => 'quay.io/pterodactyl/core:rust',
'config_startup' => '{"done": "Server startup complete", "userInteraction": []}',
'config_files' => '{}',
'config_logs' => '{"custom": false, "location": "latest.log"}',
'config_stop' => 'quit',
'config_from' => null,
'startup' => null,
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
}
private function addVariables()
{
$this->addVanillaVariables();
$this->addOxideVariables();
}
private function addVanillaVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'HOSTNAME',
], [
'name' => 'Server Name',
'description' => 'The name of your server in the public server list.',
'default_value' => 'A Rust Server',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'LEVEL',
], [
'name' => 'Level',
'description' => 'The world file for Rust to use.',
'default_value' => 'Procedural Map',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'DESCRIPTION',
], [
'name' => 'Description',
'description' => 'The description under your server title. Commonly used for rules & info.',
'default_value' => 'Powered by Pterodactyl',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'URL',
], [
'name' => 'URL',
'description' => 'The URL for your server. This is what comes up when clicking the "Visit Website" button.',
'default_value' => 'http://pterodactyl.io',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'url',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'WORLD_SIZE',
], [
'name' => 'World Size',
'description' => 'The world size for a procedural map.',
'default_value' => '3000',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'SEED',
], [
'name' => 'World Seed',
'description' => 'The seed for a procedural map.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'present',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'MAX_PLAYERS',
], [
'name' => 'Max Players',
'description' => 'The maximum amount of players allowed in the server at once.',
'default_value' => '40',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'SERVER_IMG',
], [
'name' => 'Server Header Image',
'description' => 'The header image for the top of your server listing.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'url',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'RCON_PORT',
], [
'name' => 'RCON Port',
'description' => 'Port for RCON connections.',
'default_value' => '8401',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'RCON_PASS',
], [
'name' => 'RCON Password',
'description' => 'Remote console access password.',
'default_value' => 'CHANGEME',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustvanilla']->id,
'env_variable' => 'ADDITIONAL_ARGS',
], [
'name' => 'Additional Arguments',
'description' => 'Add additional startup parameters to the server.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'present',
]);
}
private function addOxideVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'HOSTNAME',
], [
'name' => 'Server Name',
'description' => 'The name of your server in the public server list.',
'default_value' => 'A Rust Server',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'LEVEL',
], [
'name' => 'Level',
'description' => 'The world file for Rust to use.',
'default_value' => 'Procedural Map',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'DESCRIPTION',
], [
'name' => 'Description',
'description' => 'The description under your server title. Commonly used for rules & info.',
'default_value' => 'Powered by Pterodactyl',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'URL',
], [
'name' => 'URL',
'description' => 'The URL for your server. This is what comes up when clicking the "Visit Website" button.',
'default_value' => 'http://pterodactyl.io',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'url',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'WORLD_SIZE',
], [
'name' => 'World Size',
'description' => 'The world size for a procedural map.',
'default_value' => '3000',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'SEED',
], [
'name' => 'World Seed',
'description' => 'The seed for a procedural map.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'present',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'MAX_PLAYERS',
], [
'name' => 'Max Players',
'description' => 'The maximum amount of players allowed in the server at once.',
'default_value' => '40',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'SERVER_IMG',
], [
'name' => 'Server Header Image',
'description' => 'The header image for the top of your server listing.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'url',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'RCON_PORT',
], [
'name' => 'RCON Port',
'description' => 'Port for RCON connections.',
'default_value' => '8401',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|integer',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'RCON_PASS',
], [
'name' => 'RCON Password',
'description' => 'Remote console access password.',
'default_value' => 'CHANGEME',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['rustoxide']->id,
'env_variable' => 'ADDITIONAL_ARGS',
], [
'name' => 'Additional Arguments',
'description' => 'Add additional startup parameters to the server.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'present',
]);
}
}

View file

@ -1,478 +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
*/
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Traits\Services\CreatesServiceIndex;
class SourceServiceTableSeeder extends Seeder
{
use CreatesServiceIndex;
/**
* The core service ID.
*
* @var Models\Service
*/
protected $service;
/**
* Stores all of the option objects.
*
* @var array
*/
protected $option = [];
/**
* Run the database seeds.
*/
public function run()
{
$this->addCoreService();
$this->addCoreOptions();
$this->addVariables();
}
private function addCoreService()
{
$this->service = Nest::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'srcds',
], [
'name' => 'Source Engine',
'description' => 'Includes support for most Source Dedicated Server games.',
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +ip 0.0.0.0 -strictportbind -norestart',
'index_file' => $this->getIndexScript(),
]);
}
private function addCoreOptions()
{
$script = <<<'EOF'
#!/bin/bash
# SRCDS Base Installation Script
#
# Server Files: /mnt/server
apt -y update
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steamcmd
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
cd /mnt/server/steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update ${SRCDS_APPID} +quit
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
EOF;
$this->option['source'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'source',
], [
'name' => 'Custom Source Engine Game',
'description' => 'This option allows modifying the startup arguments and other details to run a custo SRCDS based game on the panel.',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => '{"done": "gameserver Steam ID", "userInteraction": []}',
'config_files' => '{}',
'config_logs' => '{"custom": true, "location": "logs/latest.log"}',
'config_stop' => 'quit',
'config_from' => null,
'startup' => null,
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
$this->option['insurgency'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'insurgency',
], [
'name' => 'Insurgency',
'description' => 'Take to the streets for intense close quarters combat, where a team\'s survival depends upon securing crucial strongholds and destroying enemy supply in this multiplayer and cooperative Source Engine based experience.',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => null,
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} +ip 0.0.0.0 -strictportbind -norestart',
'copy_script_from' => $this->option['source']->id,
]);
$this->option['tf2'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'tf2',
], [
'name' => 'Team Fortress 2',
'description' => 'Team Fortress 2 is a team-based first-person shooter multiplayer video game developed and published by Valve Corporation. It is the sequel to the 1996 mod Team Fortress for Quake and its 1999 remake.',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => null,
'config_files' => null,
'config_logs' => null,
'config_stop' => null,
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game {{SRCDS_GAME}} -console -port {{SERVER_PORT}} +map {{SRCDS_MAP}} +ip 0.0.0.0 -strictportbind -norestart',
'copy_script_from' => $this->option['source']->id,
]);
$script = <<<'EOF'
#!/bin/bash
# ARK: Installation Script
#
# Server Files: /mnt/server
apt -y update
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steamcmd
mkdir -p /mnt/server/Engine/Binaries/ThirdParty/SteamCMD/Linux
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
tar -xzvf steamcmd.tar.gz -C /mnt/server/Engine/Binaries/ThirdParty/SteamCMD/Linux
cd /mnt/server/steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 376030 +quit
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
EOF;
$this->option['ark'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'ark',
], [
'name' => 'Ark: Survival Evolved',
'description' => 'As a man or woman stranded, naked, freezing, and starving on the unforgiving shores of a mysterious island called ARK, use your skill and cunning to kill or tame and ride the plethora of leviathan dinosaurs and other primeval creatures roaming the land. Hunt, harvest resources, craft items, grow crops, research technologies, and build shelters to withstand the elements and store valuables, all while teaming up with (or preying upon) hundreds of other players to survive, dominate... and escape! — Gamepedia: ARK',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => '{"done": "Setting breakpad minidump AppID"}',
'config_files' => null,
'config_logs' => null,
'config_stop' => '^C',
'config_from' => $this->option['source']->id,
'startup' => './ShooterGame/Binaries/Linux/ShooterGameServer TheIsland?listen?ServerPassword={{ARK_PASSWORD}}?ServerAdminPassword={{ARK_ADMIN_PASSWORD}}?Port={{SERVER_PORT}}?MaxPlayers={{SERVER_MAX_PLAYERS}}',
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
$script = <<<'EOF'
#!/bin/bash
# CSGO Installation Script
#
# Server Files: /mnt/server
apt -y update
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steamcmd
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
cd /mnt/server/steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 740 +quit
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
EOF;
$this->option['csgo'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'csgo',
], [
'name' => 'Counter-Strike: Global Offensive',
'description' => 'Counter-Strike: Global Offensive is a multiplayer first-person shooter video game developed by Hidden Path Entertainment and Valve Corporation.',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => '{"done": "VAC secure mode is activated.", "userInteraction": []}',
'config_files' => null,
'config_logs' => '{"custom": true, "location": "logs/latest.log"}',
'config_stop' => 'quit',
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game csgo -console -port {{SERVER_PORT}} +ip 0.0.0.0 +map {{SRCDS_MAP}} -strictportbind -norestart +sv_setsteamaccount {{STEAM_ACC}}',
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
$script = <<<'EOF'
#!/bin/bash
# Garry's Mod Installation Script
#
# Server Files: /mnt/server
apt -y update
apt -y --no-install-recommends install curl lib32gcc1 ca-certificates
cd /tmp
curl -sSL -o steamcmd.tar.gz http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p /mnt/server/steamcmd
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
cd /mnt/server/steamcmd
# SteamCMD fails otherwise for some reason, even running as root.
# This is changed at the end of the install process anyways.
chown -R root:root /mnt
export HOME=/mnt/server
./steamcmd.sh +login anonymous +force_install_dir /mnt/server +app_update 4020 +quit
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
EOF;
$this->option['gmod'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'gmod',
], [
'name' => 'Garrys Mod',
'description' => 'Garrys Mod, is a sandbox physics game created by Garry Newman, and developed by his company, Facepunch Studios.',
'docker_image' => 'quay.io/pterodactyl/core:source',
'config_startup' => '{"done": "VAC secure mode is activated.", "userInteraction": []}',
'config_files' => null,
'config_logs' => '{"custom": true, "location": "logs/latest.log"}',
'config_stop' => 'quit',
'config_from' => $this->option['source']->id,
'startup' => './srcds_run -game garrysmod -console -port {{SERVER_PORT}} +ip 0.0.0.0 +map {{SRCDS_MAP}} -strictportbind -norestart +sv_setsteamaccount {{STEAM_ACC}}',
'script_install' => $script,
'script_entry' => 'bash',
'script_container' => 'ubuntu:16.04',
]);
}
private function addVariables()
{
$this->addInsurgencyVariables();
$this->addTF2Variables();
$this->addArkVariables();
$this->addCSGOVariables();
$this->addGMODVariables();
$this->addCustomVariables();
}
private function addInsurgencyVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'default_value' => '17705',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|regex:/^(17705)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'default_value' => 'insurgency',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|regex:/^(insurgency)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['insurgency']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Default Map',
'description' => 'The default map to use when starting the server.',
'default_value' => 'sinjar',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^(\w{1,20})$/',
]);
}
private function addTF2Variables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'default_value' => '232250',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|regex:/^(232250)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'default_value' => 'tf',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|regex:/^(tf)$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['tf2']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Default Map',
'description' => 'The default map to use when starting the server.',
'default_value' => 'cp_dustbowl',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^(\w{1,20})$/',
]);
}
private function addArkVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'ARK_PASSWORD',
], [
'name' => 'Server Password',
'description' => 'If specified, players must provide this password to join the server.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'alpha_dash|between:1,100',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'ARK_ADMIN_PASSWORD',
], [
'name' => 'Admin Password',
'description' => 'If specified, players must provide this password (via the in-game console) to gain access to administrator commands on the server.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'alpha_dash|between:1,100',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['ark']->id,
'env_variable' => 'SERVER_MAX_PLAYERS',
], [
'name' => 'Maximum Players',
'description' => 'Specifies the maximum number of players that can play on the server simultaneously.',
'default_value' => 20,
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|numeric|digits_between:1,4',
]);
}
private function addCSGOVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['csgo']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Map',
'description' => 'The default map for the server.',
'default_value' => 'de_dust2',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|alpha_dash',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['csgo']->id,
'env_variable' => 'STEAM_ACC',
], [
'name' => 'Steam Account Token',
'description' => 'The Steam Account Token required for the server to be displayed publicly.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|alpha_num|size:32',
]);
}
private function addGMODVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['gmod']->id,
'env_variable' => 'SRCDS_MAP',
], [
'name' => 'Map',
'description' => 'The default map for the server.',
'default_value' => 'gm_flatgrass',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|alpha_dash',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['gmod']->id,
'env_variable' => 'STEAM_ACC',
], [
'name' => 'Steam Account Token',
'description' => 'The Steam Account Token required for the server to be displayed publicly.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|string|alpha_num|size:32',
]);
}
private function addCustomVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['source']->id,
'env_variable' => 'SRCDS_APPID',
], [
'name' => 'Game ID',
'description' => 'The ID corresponding to the game to download and run using SRCDS.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|numeric|digits_between:1,6',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['source']->id,
'env_variable' => 'SRCDS_GAME',
], [
'name' => 'Game Name',
'description' => 'The name corresponding to the game to download and run using SRCDS.',
'default_value' => '',
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|alpha_dash|between:1,100',
]);
}
}

View file

@ -1,116 +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
*/
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Traits\Services\CreatesServiceIndex;
class TerrariaServiceTableSeeder extends Seeder
{
use CreatesServiceIndex;
/**
* The core service ID.
*
* @var Models\Service
*/
protected $service;
/**
* Stores all of the option objects.
*
* @var array
*/
protected $option = [];
/**
* Run the database seeds.
*/
public function run()
{
$this->addCoreService();
$this->addCoreOptions();
$this->addVariables();
}
private function addCoreService()
{
$this->service = Nest::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'terraria',
], [
'name' => 'Terraria',
'description' => 'Terraria is a land of adventure! A land of mystery! A land that\'s yours to shape, defend, and enjoy. Your options in Terraria are limitless. Are you an action gamer with an itchy trigger finger? A master builder? A collector? An explorer? There\'s something for everyone.',
'startup' => 'mono TerrariaServer.exe -port {{SERVER_PORT}} -autocreate 2 -worldname World',
'index_file' => $this->getIndexScript(),
]);
}
private function addCoreOptions()
{
$script = <<<'EOF'
#!/bin/ash
# TShock Installation Script
#
# Server Files: /mnt/server
apk update
apk add curl unzip
cd /tmp
curl -sSLO https://github.com/NyxStudios/TShock/releases/download/v${T_VERSION}/tshock_${T_VERSION}.zip
unzip -o tshock_${T_VERSION}.zip -d /mnt/server
EOF;
$this->option['tshock'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'tshock',
], [
'name' => 'Terraria Server (TShock)',
'description' => 'TShock is a server modification for Terraria, written in C#, and based upon the Terraria Server API. It uses JSON for configuration management, and offers several features not present in the Terraria Server normally.',
'docker_image' => 'quay.io/pterodactyl/core:mono',
'config_startup' => '{"userInteraction": [ "You need to agree to the EULA"]}',
'config_startup' => '{"done": "Type \'help\' for a list of commands", "userInteraction": []}',
'config_files' => '{"tshock/config.json":{"parser": "json", "find":{"ServerPort": "{{server.build.default.port}}", "MaxSlots": "{{server.build.env.MAX_SLOTS}}"}}}',
'config_logs' => '{"custom": false, "location": "ServerLog.txt"}',
'config_stop' => 'exit',
'startup' => null,
'script_install' => $script,
]);
}
private function addVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['tshock']->id,
'env_variable' => 'T_VERSION',
], [
'name' => 'TShock Version',
'description' => 'Which version of TShock to install and use.',
'default_value' => '4.3.22',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['tshock']->id,
'env_variable' => 'MAX_SLOTS',
], [
'name' => 'Maximum Slots',
'description' => 'Total number of slots to allow on the server.',
'default_value' => 20,
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|numeric|digits_between:1,3',
]);
}
}

View file

@ -1,182 +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
*/
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Traits\Services\CreatesServiceIndex;
class VoiceServiceTableSeeder extends Seeder
{
use CreatesServiceIndex;
/**
* The core service ID.
*
* @var Nest
*/
protected $service;
/**
* Stores all of the option objects.
*
* @var array
*/
protected $option = [];
/**
* Run the database seeds.
*/
public function run()
{
$this->addCoreService();
$this->addCoreOptions();
$this->addVariables();
}
private function addCoreService()
{
$this->service = Nest::updateOrCreate([
'author' => config('pterodactyl.service.core'),
'folder' => 'voice',
], [
'name' => 'Voice Servers',
'description' => 'Voice servers such as Mumble and Teamspeak 3.',
'startup' => '',
'index_file' => $this->getIndexScript(),
]);
}
private function addCoreOptions()
{
$script = <<<'EOF'
#!/bin/ash
# Mumble Installation Script
#
# Server Files: /mnt/server
apk update
apk add tar curl
cd /tmp
curl -sSLO https://github.com/mumble-voip/mumble/releases/download/${MUMBLE_VERSION}/murmur-static_x86-${MUMBLE_VERSION}.tar.bz2
tar -xjvf murmur-static_x86-${MUMBLE_VERSION}.tar.bz2
cp -r murmur-static_x86-${MUMBLE_VERSION}/* /mnt/server
EOF;
$this->option['mumble'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'mumble',
], [
'name' => 'Mumble Server',
'description' => 'Mumble is an open source, low-latency, high quality voice chat software primarily intended for use while gaming.',
'docker_image' => 'quay.io/pterodactyl/core:glibc',
'config_startup' => '{"done": "Server listening on", "userInteraction": [ "Generating new server certificate"]}',
'config_files' => '{"murmur.ini":{"parser": "ini", "find":{"logfile": "murmur.log", "port": "{{server.build.default.port}}", "host": "0.0.0.0", "users": "{{server.build.env.MAX_USERS}}"}}}',
'config_logs' => '{"custom": true, "location": "logs/murmur.log"}',
'config_stop' => '^C',
'config_from' => null,
'startup' => './murmur.x86 -fg',
'script_install' => $script,
]);
$script = <<<'EOF'
#!/bin/ash
# TS3 Installation Script
#
# Server Files: /mnt/server
apk update
apk add tar curl
cd /tmp
curl -sSLO http://dl.4players.de/ts/releases/${TS_VERSION}/teamspeak3-server_linux_amd64-${TS_VERSION}.tar.bz2
tar -xjvf teamspeak3-server_linux_amd64-${TS_VERSION}.tar.bz2
cp -r teamspeak3-server_linux_amd64/* /mnt/server
echo "machine_id=
default_voice_port=${SERVER_PORT}
voice_ip=0.0.0.0
licensepath=
filetransfer_port=30033
filetransfer_ip=
query_port=${SERVER_PORT}
query_ip=0.0.0.0
query_ip_whitelist=query_ip_whitelist.txt
query_ip_blacklist=query_ip_blacklist.txt
dbplugin=ts3db_sqlite3
dbpluginparameter=
dbsqlpath=sql/
dbsqlcreatepath=create_sqlite/
dbconnections=10
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0
query_skipbruteforcecheck=0" > /mnt/server/ts3server.ini
EOF;
$this->option['ts3'] = Egg::updateOrCreate([
'service_id' => $this->service->id,
'tag' => 'ts3',
], [
'name' => 'Teamspeak3 Server',
'description' => 'VoIP software designed with security in mind, featuring crystal clear voice quality, endless customization options, and scalabilty up to thousands of simultaneous users.',
'docker_image' => 'quay.io/pterodactyl/core:glibc',
'config_startup' => '{"done": "listening on 0.0.0.0:", "userInteraction": []}',
'config_files' => '{"ts3server.ini":{"parser": "ini", "find":{"default_voice_port": "{{server.build.default.port}}", "voice_ip": "0.0.0.0", "query_port": "{{server.build.default.port}}", "query_ip": "0.0.0.0"}}}',
'config_logs' => '{"custom": true, "location": "logs/ts3.log"}',
'config_stop' => '^C',
'config_from' => null,
'startup' => './ts3server_minimal_runscript.sh default_voice_port={{SERVER_PORT}} query_port={{SERVER_PORT}}',
'script_install' => $script,
]);
}
private function addVariables()
{
EggVariable::updateOrCreate([
'option_id' => $this->option['mumble']->id,
'env_variable' => 'MAX_USERS',
], [
'name' => 'Maximum Users',
'description' => 'Maximum concurrent users on the mumble server.',
'default_value' => 100,
'user_viewable' => 1,
'user_editable' => 0,
'rules' => 'required|numeric|digits_between:1,5',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['mumble']->id,
'env_variable' => 'MUMBLE_VERSION',
], [
'name' => 'Server Version',
'description' => 'Version of Mumble Server to download and use.',
'default_value' => '1.2.19',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([0-9_\.-]{5,8})$/',
]);
EggVariable::updateOrCreate([
'option_id' => $this->option['ts3']->id,
'env_variable' => 'TS_VERSION',
], [
'name' => 'Server Version',
'description' => 'The version of Teamspeak 3 to use when running the server.',
'default_value' => '3.0.13.7',
'user_viewable' => 1,
'user_editable' => 1,
'rules' => 'required|regex:/^([0-9_\.-]{5,10})$/',
]);
}
}

View file

@ -18,11 +18,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
$(document).ready(function() { $(document).ready(function() {
$('#pServiceId').select2({ $('#pNestId').select2({
placeholder: 'Select a Service', placeholder: 'Select a Nest',
}).change(); }).change();
$('#pOptionId').select2({ $('#pEggId').select2({
placeholder: 'Select a Service Option', placeholder: 'Select a Nest Egg',
}); });
$('#pPackId').select2({ $('#pPackId').select2({
placeholder: 'Select a Service Pack', placeholder: 'Select a Service Pack',
@ -116,9 +116,9 @@ $('#pNodeId').on('change', function (event) {
}); });
}); });
$('#pServiceId').on('change', function (event) { $('#pNestId').on('change', function (event) {
$('#pOptionId').html('').select2({ $('#pEggId').html('').select2({
data: $.map(_.get(Pterodactyl.services, $(this).val() + '.options', []), function (item) { data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) {
return { return {
id: item.id, id: item.id,
text: item.name, text: item.name,
@ -127,9 +127,9 @@ $('#pServiceId').on('change', function (event) {
}).change(); }).change();
}); });
$('#pOptionId').on('change', function (event) { $('#pEggId').on('change', function (event) {
var parentChain = _.get(Pterodactyl.services, $('#pServiceId').val(), null); var parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null);
var objectChain = _.get(parentChain, 'options.' + $(this).val(), null); var objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null);
$('#pDefaultContainer').val(_.get(objectChain, 'docker_image', 'not defined!')); $('#pDefaultContainer').val(_.get(objectChain, 'docker_image', 'not defined!'));

View file

@ -132,9 +132,7 @@
</div> </div>
</div> </div>
<div class="box-footer no-border no-pad-top no-pad-bottom"> <div class="box-footer no-border no-pad-top no-pad-bottom">
<div class="alert alert-info"> <p class="text-muted small">If you do not want to assign swap space to a server simply put <code>0</code> for the value, or <code>-1</code> to allow unlimited swap space. If you want to disable memory limiting on a server simply enter <code>0</code> into the memory field. We suggest leaving OOM Killer enabled unless you know what you are doing, disabling it could cause your server to hang unexpectedly.<p>
<p class="small no-margin">If you do not want to assign swap space to a server simply put <code>0</code> for the value, or <code>-1</code> to allow unlimited swap space. If you want to disable memory limiting on a server simply enter <code>0</code> into the memory field. We suggest leaving OOM Killer enabled unless you know what you are doing, disabling it could cause your server to hang unexpectedly.<p>
</div>
</div> </div>
<div class="box-body row"> <div class="box-body row">
<div class="form-group col-sm-4"> <div class="form-group col-sm-4">
@ -160,9 +158,7 @@
</div> </div>
</div> </div>
<div class="box-footer no-border no-pad-top no-pad-bottom"> <div class="box-footer no-border no-pad-top no-pad-bottom">
<div class="alert alert-info"> <p class="text-muted small">If you do not want to limit CPU usage set the value to <code>0</code>. To determine a value, take the number <em>physical</em> cores and multiply it by 100. For example, on a quad core system <code>(4 * 100 = 400)</code> there is <code>400%</code> available. To limit a server to using half of a single core, you would set the value to <code>50</code>. To allow a server to use up to two physical cores, set the value to <code>200</code>. BlockIO should be a value between <code>10</code> and <code>1000</code>. Please see <a href="https://docs.docker.com/engine/reference/run/#/block-io-bandwidth-blkio-constraint" target="_blank">this documentation</a> for more information about it.<p>
<p class="small no-margin">If you do not want to limit CPU usage set the value to <code>0</code>. To determine a value, take the number <em>physical</em> cores and multiply it by 100. For example, on a quad core system <code>(4 * 100 = 400)</code> there is <code>400%</code> available. To limit a server to using half of a single core, you would set the value to <code>50</code>. To allow a server to use up to two physical cores, set the value to <code>200</code>. BlockIO should be a value between <code>10</code> and <code>1000</code>. Please see <a href="https://docs.docker.com/engine/reference/run/#/block-io-bandwidth-blkio-constraint" target="_blank">this documentation</a> for more information about it.<p>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -171,38 +167,38 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Service Configuration</h3> <h3 class="box-title">Nest Configuration</h3>
</div> </div>
<div class="box-body row"> <div class="box-body row">
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pServiceId">Service</label> <label for="pNestId">Nest</label>
<select name="service_id" id="pServiceId" class="form-control"> <select name="nest_id" id="pNestId" class="form-control">
@foreach($services as $service) @foreach($nests as $nest)
<option value="{{ $service->id }}" <option value="{{ $nest->id }}"
@if($service->id === old('service_id')) @if($nest->id === old('nest_id'))
selected="selected" selected="selected"
@endif @endif
>{{ $service->name }}</option> >{{ $nest->name }}</option>
@endforeach @endforeach
</select> </select>
<p class="small text-muted no-margin">Select the type of service that this server will be running.</p> <p class="small text-muted no-margin">Select the Nest that this server will be grouped under.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pOptionId">Option</label> <label for="pEggId">Egg</label>
<select name="option_id" id="pOptionId" class="form-control"></select> <select name="egg_id" id="pEggId" class="form-control"></select>
<p class="small text-muted no-margin">Select the type of sub-service that this server will be running.</p> <p class="small text-muted no-margin">Select the Egg that will define how this server should operate.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pPackId">Service Pack</label> <label for="pPackId">Data Pack</label>
<select name="pack_id" id="pPackId" class="form-control"></select> <select name="pack_id" id="pPackId" class="form-control"></select>
<p class="small text-muted no-margin">Select a service pack to be automatically installed on this server when first created.</p> <p class="small text-muted no-margin">Select a data pack to be automatically installed on this server when first created.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<div class="checkbox checkbox-primary no-margin-bottom"> <div class="checkbox checkbox-primary no-margin-bottom">
<input id="pSkipScripting" name="skip_scripting" type="checkbox" value="1" /> <input id="pSkipScripting" name="skip_scripting" type="checkbox" value="1" />
<label for="pSkipScripting" class="strong">Skip Service Option Install Script</label> <label for="pSkipScripting" class="strong">Skip Egg Install Script</label>
</div> </div>
<p class="small text-muted no-margin">If the selected <code>Option</code> has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.</p> <p class="small text-muted no-margin">If the selected Egg has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.</p>
</div> </div>
</div> </div>
</div> </div>
@ -214,9 +210,9 @@
</div> </div>
<div class="box-body row"> <div class="box-body row">
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pDefaultContainer">Process Container</label> <label for="pDefaultContainer">Docker Image</label>
<input id="pDefaultContainer" name="docker_image" value="{{ old('docker_image') }}" class="form-control" /> <input id="pDefaultContainer" name="docker_image" value="{{ old('docker_image') }}" class="form-control" />
<p class="small text-muted no-margin">This is the default Docker container that will be used to run this server.</p> <p class="small text-muted no-margin">This is the default Docker image that will be used to run this server.</p>
</div> </div>
</div> </div>
</div> </div>

View file

@ -91,7 +91,7 @@
<div class="form-group"> <div class="form-group">
<label for="name" class="control-label">Docker Image</label> <label for="name" class="control-label">Docker Image</label>
<input type="text" name="docker_image" value="{{ $server->image }}" class="form-control" /> <input type="text" name="docker_image" value="{{ $server->image }}" class="form-control" />
<p class="text-muted small">The docker image to use for this server. The default image for this service and option combination is <code>{{ $server->option->docker_image }}</code>.</p> <p class="text-muted small">The docker image to use for this server. The default image for this service and option combination is <code>{{ $server->egg->docker_image }}</code>.</p>
</div> </div>
</div> </div>
<div class="box-footer"> <div class="box-footer">

View file

@ -66,8 +66,8 @@
<tr> <tr>
<td>Service</td> <td>Service</td>
<td> <td>
<a href="{{ route('admin.services.view', $server->option->service->id) }}">{{ $server->option->service->name }}</a> :: <a href="{{ route('admin.nests.view', $server->nest_id) }}">{{ $server->nest->name }}</a> ::
<a href="{{ route('admin.services.option.view', $server->option->id) }}">{{ $server->option->name }}</a> <a href="{{ route('admin.nests.egg.view', $server->egg_id) }}">{{ $server->egg->name }}</a>
</td> </td>
</tr> </tr>
<tr> <tr>

View file

@ -78,34 +78,34 @@
</p> </p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pServiceId">Service</label> <label for="pNestId">Nest</label>
<select name="service_id" id="pServiceId" class="form-control"> <select name="nest_id" id="pNestId" class="form-control">
@foreach($services as $service) @foreach($nests as $nest)
<option value="{{ $service->id }}" <option value="{{ $nest->id }}"
@if($service->id === $server->service_id) @if($nest->id === $server->nest_id)
selected selected
@endif @endif
>{{ $service->name }}</option> >{{ $nest->name }}</option>
@endforeach @endforeach
</select> </select>
<p class="small text-muted no-margin">Select the type of service that this server will be running.</p> <p class="small text-muted no-margin">Select the Nest that this server will be grouped into.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pOptionId">Option</label> <label for="pEggId">Egg</label>
<select name="option_id" id="pOptionId" class="form-control"></select> <select name="egg_id" id="pEggId" class="form-control"></select>
<p class="small text-muted no-margin">Select the type of sub-service that this server will be running.</p> <p class="small text-muted no-margin">Select the Egg that will provide processing data for this server.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="pPackId">Service Pack</label> <label for="pPackId">Data Pack</label>
<select name="pack_id" id="pPackId" class="form-control"></select> <select name="pack_id" id="pPackId" class="form-control"></select>
<p class="small text-muted no-margin">Select a service pack to be automatically installed on this server when first created.</p> <p class="small text-muted no-margin">Select a data pack to be automatically installed on this server when first created.</p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<div class="checkbox checkbox-primary no-margin-bottom"> <div class="checkbox checkbox-primary no-margin-bottom">
<input id="pSkipScripting" name="skip_scripting" type="checkbox" value="1" @if($server->skip_scripts) checked @endif /> <input id="pSkipScripting" name="skip_scripting" type="checkbox" value="1" @if($server->skip_scripts) checked @endif />
<label for="pSkipScripting" class="strong">Skip Service Option Install Script</label> <label for="pSkipScripting" class="strong">Skip Egg Install Script</label>
</div> </div>
<p class="small text-muted no-margin">If the selected <code>Option</code> has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.</p> <p class="small text-muted no-margin">If the selected Egg has an install script attached to it, the script will run during install after the pack is installed. If you would like to skip this step, check this box.</p>
</div> </div>
</div> </div>
</div> </div>
@ -122,11 +122,11 @@
{!! Theme::js('vendor/lodash/lodash.js') !!} {!! Theme::js('vendor/lodash/lodash.js') !!}
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$('#pServiceId').select2({ $('#pNestId').select2({
placeholder: 'Select a Service', placeholder: 'Select a Nest',
}).change(); }).change();
$('#pOptionId').select2({ $('#pEggId').select2({
placeholder: 'Select a Service Option', placeholder: 'Select a Nest Egg',
}); });
$('#pPackId').select2({ $('#pPackId').select2({
placeholder: 'Select a Service Pack', placeholder: 'Select a Service Pack',
@ -143,20 +143,20 @@
}); });
</script> </script>
<script> <script>
$('#pServiceId').on('change', function (event) { $('#pNestId').on('change', function (event) {
$('#pOptionId').html('').select2({ $('#pEggId').html('').select2({
data: $.map(_.get(Pterodactyl.services, $(this).val() + '.options', []), function (item) { data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) {
return { return {
id: item.id, id: item.id,
text: item.name, text: item.name,
}; };
}), }),
}).val('{{ $server->option_id }}').change(); }).change();
}); });
$('#pOptionId').on('change', function (event) { $('#pEggId').on('change', function (event) {
var parentChain = _.get(Pterodactyl.services, $('#pServiceId').val(), null); var parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null);
var objectChain = _.get(parentChain, 'options.' + $(this).val(), null); var objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null);
$('#pDefaultContainer').val(_.get(objectChain, 'docker_image', 'not defined!')); $('#pDefaultContainer').val(_.get(objectChain, 'docker_image', 'not defined!'));
@ -167,7 +167,7 @@
} }
$('#pPackId').html('').select2({ $('#pPackId').html('').select2({
data: [{ id: '', text: 'No Service Pack' }].concat( data: [{ id: '0', text: 'No Service Pack' }].concat(
$.map(_.get(objectChain, 'packs', []), function (item, i) { $.map(_.get(objectChain, 'packs', []), function (item, i) {
return { return {
id: item.id, id: item.id,

View file

@ -6,92 +6,92 @@
* This software is licensed under the terms of the MIT license. * This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
Route::get('/', 'CoreController@index'); //Route::get('/', 'CoreController@index');
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| Server Controller Routes //| Server Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/admin/servers //| Endpoint: /api/admin/servers
| //|
*/ //*/
Route::group(['prefix' => '/servers'], function () { //Route::group(['prefix' => '/servers'], function () {
Route::get('/', 'ServerController@index'); // Route::get('/', 'ServerController@index');
Route::get('/{id}', 'ServerController@view'); // Route::get('/{id}', 'ServerController@view');
//
Route::post('/', 'ServerController@store'); // Route::post('/', 'ServerController@store');
//
Route::put('/{id}/details', 'ServerController@details'); // Route::put('/{id}/details', 'ServerController@details');
Route::put('/{id}/container', 'ServerController@container'); // Route::put('/{id}/container', 'ServerController@container');
Route::put('/{id}/build', 'ServerController@build'); // Route::put('/{id}/build', 'ServerController@build');
Route::put('/{id}/startup', 'ServerController@startup'); // Route::put('/{id}/startup', 'ServerController@startup');
//
Route::patch('/{id}/install', 'ServerController@install'); // Route::patch('/{id}/install', 'ServerController@install');
Route::patch('/{id}/rebuild', 'ServerController@rebuild'); // Route::patch('/{id}/rebuild', 'ServerController@rebuild');
Route::patch('/{id}/suspend', 'ServerController@suspend'); // Route::patch('/{id}/suspend', 'ServerController@suspend');
//
Route::delete('/{id}', 'ServerController@delete'); // Route::delete('/{id}', 'ServerController@delete');
}); //});
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| Location Controller Routes //| Location Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/admin/locations //| Endpoint: /api/admin/locations
| //|
*/ //*/
Route::group(['prefix' => '/locations'], function () { //Route::group(['prefix' => '/locations'], function () {
Route::get('/', 'LocationController@index'); // Route::get('/', 'LocationController@index');
}); //});
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| Node Controller Routes //| Node Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/admin/nodes //| Endpoint: /api/admin/nodes
| //|
*/ //*/
Route::group(['prefix' => '/nodes'], function () { //Route::group(['prefix' => '/nodes'], function () {
Route::get('/', 'NodeController@index'); // Route::get('/', 'NodeController@index');
Route::get('/{id}', 'NodeController@view'); // Route::get('/{id}', 'NodeController@view');
Route::get('/{id}/config', 'NodeController@viewConfig'); // Route::get('/{id}/config', 'NodeController@viewConfig');
//
Route::post('/', 'NodeController@store'); // Route::post('/', 'NodeController@store');
//
Route::delete('/{id}', 'NodeController@delete'); // Route::delete('/{id}', 'NodeController@delete');
}); //});
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| User Controller Routes //| User Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/admin/users //| Endpoint: /api/admin/users
| //|
*/ //*/
Route::group(['prefix' => '/users'], function () { //Route::group(['prefix' => '/users'], function () {
Route::get('/', 'UserController@index'); // Route::get('/', 'UserController@index');
Route::get('/{id}', 'UserController@view'); // Route::get('/{id}', 'UserController@view');
//
Route::post('/', 'UserController@store'); // Route::post('/', 'UserController@store');
//
Route::put('/{id}', 'UserController@update'); // Route::put('/{id}', 'UserController@update');
//
Route::delete('/{id}', 'UserController@delete'); // Route::delete('/{id}', 'UserController@delete');
}); //});
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| Service Controller Routes //| Service Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/admin/services //| Endpoint: /api/admin/services
| //|
*/ //*/
Route::group(['prefix' => '/services'], function () { //Route::group(['prefix' => '/services'], function () {
Route::get('/', 'ServiceController@index'); // Route::get('/', 'ServiceController@index');
Route::get('/{id}', 'ServiceController@view'); // Route::get('/{id}', 'ServiceController@view');
}); //});

View file

@ -8,7 +8,7 @@
*/ */
Route::get('/authenticate/{token}', 'ValidateKeyController@index')->name('api.remote.authenticate'); Route::get('/authenticate/{token}', 'ValidateKeyController@index')->name('api.remote.authenticate');
Route::group(['prefix' => '/options'], function () { Route::group(['prefix' => '/eggs'], function () {
Route::get('/', 'OptionRetrievalController@index')->name('api.remote.services'); Route::get('/', 'EggRetrievalController@download@index')->name('api.remote.eggs');
Route::get('/{uuid}', 'OptionRetrievalController@download')->name('api.remote.services.download'); Route::get('/{uuid}', 'EggRetrievalController@download')->name('api.remote.eggs.download');
}); });

View file

@ -6,22 +6,22 @@
* This software is licensed under the terms of the MIT license. * This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
Route::get('/', 'CoreController@index')->name('api.user'); //Route::get('/', 'CoreController@index')->name('api.user');
//
/* ///*
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| Server Controller Routes //| Server Controller Routes
|-------------------------------------------------------------------------- //|--------------------------------------------------------------------------
| //|
| Endpoint: /api/user/server/{server} //| Endpoint: /api/user/server/{server}
| //|
*/ //*/
Route::group([ //Route::group([
'prefix' => '/server/{server}', // 'prefix' => '/server/{server}',
'middleware' => 'server', // 'middleware' => 'server',
], function () { //], function () {
Route::get('/', 'ServerController@index')->name('api.user.server'); // Route::get('/', 'ServerController@index')->name('api.user.server');
//
Route::post('/power', 'ServerController@power')->name('api.user.server.power'); // Route::post('/power', 'ServerController@power')->name('api.user.server.power');
Route::post('/command', 'ServerController@command')->name('api.user.server.command'); // Route::post('/command', 'ServerController@command')->name('api.user.server.command');
}); //});