Merge pull request #155 from Pterodactyl/feature/database-improvements
Foreign Keys & Deletion Improvements
This commit is contained in:
commit
bcaaefbc64
28 changed files with 931 additions and 80 deletions
11
.env.example
11
.env.example
|
@ -4,6 +4,7 @@ APP_KEY=SomeRandomString3232RandomString
|
||||||
APP_THEME=default
|
APP_THEME=default
|
||||||
APP_TIMEZONE=UTC
|
APP_TIMEZONE=UTC
|
||||||
APP_CLEAR_TASKLOG=720
|
APP_CLEAR_TASKLOG=720
|
||||||
|
APP_DELETE_MINUTES=10
|
||||||
CONSOLE_PUSH_FREQ=250
|
CONSOLE_PUSH_FREQ=250
|
||||||
CONSOLE_PUSH_COUNT=10
|
CONSOLE_PUSH_COUNT=10
|
||||||
|
|
||||||
|
@ -15,7 +16,6 @@ DB_PASSWORD=secret
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=database
|
SESSION_DRIVER=database
|
||||||
QUEUE_DRIVER=database
|
|
||||||
|
|
||||||
MAIL_DRIVER=smtp
|
MAIL_DRIVER=smtp
|
||||||
MAIL_HOST=mailtrap.io
|
MAIL_HOST=mailtrap.io
|
||||||
|
@ -28,3 +28,12 @@ MAIL_FROM=you@example.com
|
||||||
API_PREFIX=api
|
API_PREFIX=api
|
||||||
API_VERSION=v1
|
API_VERSION=v1
|
||||||
API_DEBUG=false
|
API_DEBUG=false
|
||||||
|
|
||||||
|
QUEUE_DRIVER=database
|
||||||
|
QUEUE_HIGH=high
|
||||||
|
QUEUE_STANDARD=standard
|
||||||
|
QUEUE_LOW=low
|
||||||
|
|
||||||
|
SQS_KEY=aws-public
|
||||||
|
SQS_SECRET=aws-secret
|
||||||
|
SQS_QUEUE_PREFIX=aws-queue-prefix
|
||||||
|
|
|
@ -74,7 +74,7 @@ class RunTasks extends Command
|
||||||
|
|
||||||
foreach ($tasks as &$task) {
|
foreach ($tasks as &$task) {
|
||||||
$bar->advance();
|
$bar->advance();
|
||||||
$this->dispatch(new SendScheduledTask(Models\Server::findOrFail($task->server), $task));
|
$this->dispatch((new SendScheduledTask(Models\Server::findOrFail($task->server), $task))->onQueue(env('QUEUE_LOW', 'low')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$bar->finish();
|
$bar->finish();
|
||||||
|
|
44
app/Events/ServerDeleted.php
Normal file
44
app/Events/ServerDeleted.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2016 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.
|
||||||
|
*/
|
||||||
|
namespace Pterodactyl\Events;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ServerDeleted
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($id)
|
||||||
|
{
|
||||||
|
$this->server = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ class ServersController extends Controller
|
||||||
|
|
||||||
public function getIndex(Request $request)
|
public function getIndex(Request $request)
|
||||||
{
|
{
|
||||||
$query = Models\Server::select(
|
$query = Models\Server::withTrashed()->select(
|
||||||
'servers.*',
|
'servers.*',
|
||||||
'nodes.name as a_nodeName',
|
'nodes.name as a_nodeName',
|
||||||
'users.email as a_ownerEmail',
|
'users.email as a_ownerEmail',
|
||||||
|
@ -84,7 +84,7 @@ class ServersController extends Controller
|
||||||
$servers = $query->paginate(20);
|
$servers = $query->paginate(20);
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
Alert::warning('There was an error with the search parameters provided.');
|
Alert::warning('There was an error with the search parameters provided.');
|
||||||
$servers = Models\Server::select(
|
$servers = Models\Server::withTrashed()->select(
|
||||||
'servers.*',
|
'servers.*',
|
||||||
'nodes.name as a_nodeName',
|
'nodes.name as a_nodeName',
|
||||||
'users.email as a_ownerEmail',
|
'users.email as a_ownerEmail',
|
||||||
|
@ -112,7 +112,7 @@ class ServersController extends Controller
|
||||||
|
|
||||||
public function getView(Request $request, $id)
|
public function getView(Request $request, $id)
|
||||||
{
|
{
|
||||||
$server = Models\Server::select(
|
$server = Models\Server::withTrashed()->select(
|
||||||
'servers.*',
|
'servers.*',
|
||||||
'nodes.name as a_nodeName',
|
'nodes.name as a_nodeName',
|
||||||
'users.email as a_ownerEmail',
|
'users.email as a_ownerEmail',
|
||||||
|
@ -394,7 +394,7 @@ class ServersController extends Controller
|
||||||
try {
|
try {
|
||||||
$server = new ServerRepository;
|
$server = new ServerRepository;
|
||||||
$server->deleteServer($id, $force);
|
$server->deleteServer($id, $force);
|
||||||
Alert::success('Server was successfully deleted from the panel and the daemon.')->flash();
|
Alert::success('Server has been marked for deletion on the system.')->flash();
|
||||||
return redirect()->route('admin.servers');
|
return redirect()->route('admin.servers');
|
||||||
} catch (DisplayException $ex) {
|
} catch (DisplayException $ex) {
|
||||||
Alert::danger($ex->getMessage())->flash();
|
Alert::danger($ex->getMessage())->flash();
|
||||||
|
@ -510,4 +510,31 @@ class ServersController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function postQueuedDeletionHandler(Request $request, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$repo = new ServerRepository;
|
||||||
|
if (!is_null($request->input('cancel'))) {
|
||||||
|
$repo->cancelDeletion($id);
|
||||||
|
Alert::success('Server deletion has been cancelled. This server will remain suspended until you unsuspend it.')->flash();
|
||||||
|
return redirect()->route('admin.servers.view', $id);
|
||||||
|
} else if(!is_null($request->input('delete'))) {
|
||||||
|
$repo->deleteNow($id);
|
||||||
|
Alert::success('Server was successfully deleted from the system.')->flash();
|
||||||
|
return redirect()->route('admin.servers');
|
||||||
|
} else if(!is_null($request->input('force_delete'))) {
|
||||||
|
$repo->deleteNow($id, true);
|
||||||
|
Alert::success('Server was successfully force deleted from the system.')->flash();
|
||||||
|
return redirect()->route('admin.servers');
|
||||||
|
}
|
||||||
|
} catch (DisplayException $ex) {
|
||||||
|
Alert::danger($ex->getMessage())->flash();
|
||||||
|
return redirect()->route('admin.servers.view', $id);
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
Log::error($ex);
|
||||||
|
Alert::danger('An unhandled error occured while attempting to perform this action.')->flash();
|
||||||
|
return redirect()->route('admin.servers.view', $id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,11 @@ class AdminRoutes {
|
||||||
'uses' => 'Admin\ServersController@deleteServer'
|
'uses' => 'Admin\ServersController@deleteServer'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$router->post('/view/{id}/queuedDeletion', [
|
||||||
|
'uses' => 'Admin\ServersController@postQueuedDeletionHandler',
|
||||||
|
'as' => 'admin.servers.post.queuedDeletion'
|
||||||
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Node Routes
|
// Node Routes
|
||||||
|
|
67
app/Jobs/DeleteServer.php
Normal file
67
app/Jobs/DeleteServer.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2016 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.
|
||||||
|
*/
|
||||||
|
namespace Pterodactyl\Jobs;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
use Pterodactyl\Models;
|
||||||
|
use Pterodactyl\Repositories\ServerRepository;
|
||||||
|
|
||||||
|
class DeleteServer extends Job implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Id of server to be deleted.
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @param integer $server
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$repo = new ServerRepository;
|
||||||
|
$repo->deleteNow($this->id);
|
||||||
|
}
|
||||||
|
}
|
65
app/Jobs/SuspendServer.php
Normal file
65
app/Jobs/SuspendServer.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2016 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.
|
||||||
|
*/
|
||||||
|
namespace Pterodactyl\Jobs;
|
||||||
|
|
||||||
|
use Debugbar;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
use Pterodactyl\Repositories\ServerRepository;
|
||||||
|
|
||||||
|
class SuspendServer extends Job implements ShouldQueue
|
||||||
|
{
|
||||||
|
use InteractsWithQueue, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of associated server model.
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$repo = new ServerRepository;
|
||||||
|
$repo->suspend($this->id, true);
|
||||||
|
}
|
||||||
|
}
|
64
app/Listeners/DeleteServerListener.php
Normal file
64
app/Listeners/DeleteServerListener.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Pterodactyl - Panel
|
||||||
|
* Copyright (c) 2015 - 2016 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.
|
||||||
|
*/
|
||||||
|
namespace Pterodactyl\Listeners;
|
||||||
|
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
use Pterodactyl\Events\ServerDeleted;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
|
||||||
|
use Pterodactyl\Jobs\SuspendServer;
|
||||||
|
use Pterodactyl\Jobs\DeleteServer;
|
||||||
|
|
||||||
|
class DeleteServerListener
|
||||||
|
{
|
||||||
|
|
||||||
|
use DispatchesJobs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param DeleteServerEvent $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(ServerDeleted $event)
|
||||||
|
{
|
||||||
|
$this->dispatch((new SuspendServer($event->server))->onQueue(env('QUEUE_HIGH', 'high')));
|
||||||
|
$this->dispatch(
|
||||||
|
(new DeleteServer($event->server))
|
||||||
|
->delay(Carbon::now()->addMinutes(env('APP_DELETE_MINUTES', 10)))
|
||||||
|
->onQueue(env('QUEUE_STANDARD', 'standard'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,12 +26,15 @@ namespace Pterodactyl\Models;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Pterodactyl\Models\Subuser;
|
use Pterodactyl\Models\Subuser;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
use Pterodactyl\Exceptions\DisplayException;
|
use Pterodactyl\Exceptions\DisplayException;
|
||||||
|
|
||||||
class Server extends Model
|
class Server extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table associated with the model.
|
* The table associated with the model.
|
||||||
*
|
*
|
||||||
|
@ -44,17 +47,21 @@ class Server extends Model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $hidden = [
|
protected $hidden = ['daemonSecret', 'sftp_password'];
|
||||||
'daemonSecret',
|
|
||||||
'sftp_password'
|
/**
|
||||||
];
|
* The attributes that should be mutated to dates.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields that are not mass assignable.
|
* Fields that are not mass assignable.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $guarded = ['id', 'installed', 'created_at', 'updated_at'];
|
protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast values to correct type.
|
* Cast values to correct type.
|
||||||
|
@ -92,6 +99,7 @@ class Server extends Model
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
self::$user = Auth::user();
|
self::$user = Auth::user();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,10 +189,6 @@ class Server extends Model
|
||||||
|
|
||||||
$result = $query->first();
|
$result = $query->first();
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
throw new DisplayException('No server was found belonging to this user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($result)) {
|
if(!is_null($result)) {
|
||||||
$result->daemonSecret = self::getUserDaemonSecret($result);
|
$result->daemonSecret = self::getUserDaemonSecret($result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
'Pterodactyl\Events\SomeEvent' => [
|
'Pterodactyl\Events\ServerDeleted' => [
|
||||||
'Pterodactyl\Listeners\EventListener',
|
'Pterodactyl\Listeners\DeleteServerListener',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ use Pterodactyl\Models;
|
||||||
use Pterodactyl\Services\UuidService;
|
use Pterodactyl\Services\UuidService;
|
||||||
use Pterodactyl\Services\DeploymentService;
|
use Pterodactyl\Services\DeploymentService;
|
||||||
use Pterodactyl\Notifications\ServerCreated;
|
use Pterodactyl\Notifications\ServerCreated;
|
||||||
|
use Pterodactyl\Events\ServerDeleted;
|
||||||
|
|
||||||
use Pterodactyl\Exceptions\DisplayException;
|
use Pterodactyl\Exceptions\DisplayException;
|
||||||
use Pterodactyl\Exceptions\AccountNotFoundException;
|
use Pterodactyl\Exceptions\AccountNotFoundException;
|
||||||
|
@ -767,11 +768,37 @@ class ServerRepository
|
||||||
public function deleteServer($id, $force)
|
public function deleteServer($id, $force)
|
||||||
{
|
{
|
||||||
$server = Models\Server::findOrFail($id);
|
$server = Models\Server::findOrFail($id);
|
||||||
$node = Models\Node::findOrFail($server->node);
|
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Delete Allocations
|
if ($force === 'force' || $force === true) {
|
||||||
|
$server->installed = 3;
|
||||||
|
$server->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$server->delete();
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
event(new ServerDeleted($server->id));
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
DB::rollBack();
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteNow($id, $force = false) {
|
||||||
|
$server = Models\Server::withTrashed()->findOrFail($id);
|
||||||
|
$node = Models\Node::findOrFail($server->node);
|
||||||
|
|
||||||
|
// Handle server being restored previously or
|
||||||
|
// an accidental queue.
|
||||||
|
if (!$server->trashed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
// Unassign Allocations
|
||||||
Models\Allocation::where('assigned_to', $server->id)->update([
|
Models\Allocation::where('assigned_to', $server->id)->update([
|
||||||
'assigned_to' => null
|
'assigned_to' => null
|
||||||
]);
|
]);
|
||||||
|
@ -779,20 +806,23 @@ class ServerRepository
|
||||||
// Remove Variables
|
// Remove Variables
|
||||||
Models\ServerVariables::where('server_id', $server->id)->delete();
|
Models\ServerVariables::where('server_id', $server->id)->delete();
|
||||||
|
|
||||||
|
// Remove Permissions (Foreign Key requires before Subusers)
|
||||||
|
Models\Permission::where('server_id', $server->id)->delete();
|
||||||
|
|
||||||
// Remove SubUsers
|
// Remove SubUsers
|
||||||
Models\Subuser::where('server_id', $server->id)->delete();
|
Models\Subuser::where('server_id', $server->id)->delete();
|
||||||
|
|
||||||
// Remove Permissions
|
|
||||||
Models\Permission::where('server_id', $server->id)->delete();
|
|
||||||
|
|
||||||
// Remove Downloads
|
// Remove Downloads
|
||||||
Models\Download::where('server', $server->uuid)->delete();
|
Models\Download::where('server', $server->uuid)->delete();
|
||||||
|
|
||||||
|
// Clear Tasks
|
||||||
|
Models\Task::where('server', $server->id)->delete();
|
||||||
|
|
||||||
// Delete Databases
|
// Delete Databases
|
||||||
$databases = Models\Database::select('id')->where('server_id', $server->id)->get();
|
// This is the one un-recoverable point where
|
||||||
|
// transactions will not save us.
|
||||||
$repository = new DatabaseRepository;
|
$repository = new DatabaseRepository;
|
||||||
foreach($databases as &$database) {
|
foreach(Models\Database::select('id')->where('server_id', $server->id)->get() as &$database) {
|
||||||
// Use the repository to drop the database, we don't need to delete here because it is now gone.
|
|
||||||
$repository->drop($database->id);
|
$repository->drop($database->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,17 +834,16 @@ class ServerRepository
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->delete();
|
$server->forceDelete();
|
||||||
DB::commit();
|
DB::commit();
|
||||||
return true;
|
|
||||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||||
if ($force === 'force') {
|
// Set installed is set to 3 when force deleting.
|
||||||
$server->delete();
|
if ($server->installed === 3 || $force) {
|
||||||
|
$server->forceDelete();
|
||||||
DB::commit();
|
DB::commit();
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
throw new DisplayException('An error occured while attempting to delete the server on the daemon.', $ex);
|
throw $ex;
|
||||||
}
|
}
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
@ -822,6 +851,15 @@ class ServerRepository
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancelDeletion($id)
|
||||||
|
{
|
||||||
|
$server = Models\Server::withTrashed()->findOrFail($id);
|
||||||
|
$server->restore();
|
||||||
|
|
||||||
|
$server->installed = 1;
|
||||||
|
$server->save();
|
||||||
|
}
|
||||||
|
|
||||||
public function toggleInstall($id)
|
public function toggleInstall($id)
|
||||||
{
|
{
|
||||||
$server = Models\Server::findOrFail($id);
|
$server = Models\Server::findOrFail($id);
|
||||||
|
@ -837,9 +875,9 @@ class ServerRepository
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function suspend($id)
|
public function suspend($id, $deleted = false)
|
||||||
{
|
{
|
||||||
$server = Models\Server::findOrFail($id);
|
$server = ($deleted) ? Models\Server::withTrashed()->findOrFail($id) : Models\Server::findOrFail($id);
|
||||||
$node = Models\Node::findOrFail($server->node);
|
$node = Models\Node::findOrFail($server->node);
|
||||||
|
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
|
@ -8,28 +8,25 @@
|
||||||
"email": "dane@daneeveritt.com",
|
"email": "dane@daneeveritt.com",
|
||||||
"homepage": "https://github.com/DaneEveritt",
|
"homepage": "https://github.com/DaneEveritt",
|
||||||
"role": "Lead Developer"
|
"role": "Lead Developer"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Dylan Seidt",
|
|
||||||
"email": "dylan.seidt@gmail.com",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6.4",
|
"php": ">=5.6.4",
|
||||||
"laravel/framework": "5.3.6",
|
"laravel/framework": "5.3.21",
|
||||||
"barryvdh/laravel-debugbar": "^2.2.3",
|
"barryvdh/laravel-debugbar": "2.2.3",
|
||||||
"doctrine/dbal": "^2.5.4",
|
"doctrine/dbal": "2.5.5",
|
||||||
"guzzlehttp/guzzle": "^6.2.1",
|
"guzzlehttp/guzzle": "6.2.2",
|
||||||
"pragmarx/google2fa": "^1.0.1",
|
"pragmarx/google2fa": "1.0.1",
|
||||||
"webpatser/laravel-uuid": "^2.0",
|
"webpatser/laravel-uuid": "2.0.1",
|
||||||
"prologue/alerts": "^0.4.0",
|
"prologue/alerts": "0.4.0",
|
||||||
"s1lentium/iptools": "^1.1.0",
|
"s1lentium/iptools": "1.1.0",
|
||||||
"edvinaskrucas/settings": "^2.0",
|
"edvinaskrucas/settings": "2.0.0",
|
||||||
"igaster/laravel-theme": "^1.1.3",
|
"igaster/laravel-theme": "1.1.3",
|
||||||
"nesbot/carbon": "^1.21",
|
"nesbot/carbon": "1.21.0",
|
||||||
"mtdowling/cron-expression": "^1.1",
|
"mtdowling/cron-expression": "1.1.0",
|
||||||
"dingo/api": "1.0.0-beta6"
|
"dingo/api": "1.0.0-beta6",
|
||||||
|
"aws/aws-sdk-php": "3.19.20",
|
||||||
|
"predis/predis": "1.1.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
|
|
|
@ -38,38 +38,23 @@ return [
|
||||||
'database' => [
|
'database' => [
|
||||||
'driver' => 'database',
|
'driver' => 'database',
|
||||||
'table' => 'jobs',
|
'table' => 'jobs',
|
||||||
'queue' => 'default',
|
'queue' => env('QUEUE_STANDARD'),
|
||||||
'retry_after' => 60,
|
'retry_after' => 60,
|
||||||
],
|
],
|
||||||
|
|
||||||
'beanstalkd' => [
|
|
||||||
'driver' => 'beanstalkd',
|
|
||||||
'host' => 'localhost',
|
|
||||||
'queue' => 'default',
|
|
||||||
'retry_after' => 60,
|
|
||||||
],
|
|
||||||
|
|
||||||
'sqs' => [
|
'sqs' => [
|
||||||
'driver' => 'sqs',
|
'driver' => 'sqs',
|
||||||
'key' => 'your-public-key',
|
'key' => env('SQS_KEY'),
|
||||||
'secret' => 'your-secret-key',
|
'secret' => env('SQS_SECRET'),
|
||||||
'queue' => 'your-queue-url',
|
'prefix' => env('SQS_QUEUE_PREFIX'),
|
||||||
'region' => 'us-east-1',
|
'queue' => env('QUEUE_STANDARD'),
|
||||||
],
|
'region' => env('SQS_REGION', 'us-east-1'),
|
||||||
|
|
||||||
'iron' => [
|
|
||||||
'driver' => 'iron',
|
|
||||||
'host' => 'mq-aws-us-east-1.iron.io',
|
|
||||||
'token' => 'your-token',
|
|
||||||
'project' => 'your-project-id',
|
|
||||||
'queue' => 'your-queue-name',
|
|
||||||
'encrypt' => true,
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'redis' => [
|
'redis' => [
|
||||||
'driver' => 'redis',
|
'driver' => 'redis',
|
||||||
'connection' => 'default',
|
'connection' => 'default',
|
||||||
'queue' => 'default',
|
'queue' => env('QUEUE_STANDARD'),
|
||||||
'retry_after' => 60,
|
'retry_after' => 60,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignKeysServers extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE servers
|
||||||
|
MODIFY COLUMN node INT(10) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN owner INT(10) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN allocation INT(10) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN service INT(10) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN servers.option INT(10) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->foreign('node')->references('id')->on('nodes');
|
||||||
|
$table->foreign('owner')->references('id')->on('users');
|
||||||
|
$table->foreign('allocation')->references('id')->on('allocations');
|
||||||
|
$table->foreign('service')->references('id')->on('services');
|
||||||
|
$table->foreign('option')->references('id')->on('service_options');
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('servers', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('servers_node_foreign');
|
||||||
|
$table->dropForeign('servers_owner_foreign');
|
||||||
|
$table->dropForeign('servers_allocation_foreign');
|
||||||
|
$table->dropForeign('servers_service_foreign');
|
||||||
|
$table->dropForeign('servers_option_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('servers_node_foreign');
|
||||||
|
$table->dropIndex('servers_owner_foreign');
|
||||||
|
$table->dropIndex('servers_allocation_foreign');
|
||||||
|
$table->dropIndex('servers_service_foreign');
|
||||||
|
$table->dropIndex('servers_option_foreign');
|
||||||
|
|
||||||
|
$table->dropColumn('deleted_at');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE servers
|
||||||
|
MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN owner MEDIUMINT(8) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN allocation MEDIUMINT(8) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN service MEDIUMINT(8) UNSIGNED NOT NULL,
|
||||||
|
MODIFY COLUMN servers.option MEDIUMINT(8) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignAllocations extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE allocations
|
||||||
|
MODIFY COLUMN assigned_to INT(10) UNSIGNED NULL,
|
||||||
|
MODIFY COLUMN node INT(10) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
|
||||||
|
Schema::table('allocations', function (Blueprint $table) {
|
||||||
|
$table->foreign('assigned_to')->references('id')->on('servers');
|
||||||
|
$table->foreign('node')->references('id')->on('nodes');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('allocations', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('allocations_assigned_to_foreign');
|
||||||
|
$table->dropForeign('allocations_node_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('allocations_assigned_to_foreign');
|
||||||
|
$table->dropIndex('allocations_node_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE allocations
|
||||||
|
MODIFY COLUMN assigned_to MEDIUMINT(8) UNSIGNED NULL,
|
||||||
|
MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignApiKeys extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('api_keys', function (Blueprint $table) {
|
||||||
|
$table->foreign('user')->references('id')->on('users');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('api_keys', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('api_keys_user_foreign');
|
||||||
|
$table->dropIndex('api_keys_user_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignApiPermissions extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE api_permissions MODIFY key_id INT(10) UNSIGNED NOT NULL');
|
||||||
|
|
||||||
|
Schema::table('api_permissions', function (Blueprint $table) {
|
||||||
|
$table->foreign('key_id')->references('id')->on('api_keys');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('api_permissions', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('api_permissions_key_id_foreign');
|
||||||
|
$table->dropIndex('api_permissions_key_id_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE api_permissions MODIFY key_id MEDIUMINT(8) UNSIGNED NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignDatabaseServers extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('database_servers', function (Blueprint $table) {
|
||||||
|
$table->foreign('linked_node')->references('id')->on('nodes');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('database_servers', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('database_servers_linked_node_foreign');
|
||||||
|
$table->dropIndex('database_servers_linked_node_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignDatabases extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('databases', function (Blueprint $table) {
|
||||||
|
$table->foreign('server_id')->references('id')->on('servers');
|
||||||
|
$table->foreign('db_server')->references('id')->on('database_servers');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('databases', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('databases_server_id_foreign');
|
||||||
|
$table->dropForeign('databases_db_server_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('databases_server_id_foreign');
|
||||||
|
$table->dropIndex('databases_db_server_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
37
database/migrations/2016_10_23_203335_add_foreign_nodes.php
Normal file
37
database/migrations/2016_10_23_203335_add_foreign_nodes.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignNodes extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE nodes MODIFY location INT(10) UNSIGNED NOT NULL');
|
||||||
|
|
||||||
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
|
$table->foreign('location')->references('id')->on('locations');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('nodes_location_foreign');
|
||||||
|
$table->dropIndex('nodes_location_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE nodes MODIFY location MEDIUMINT(10) UNSIGNED NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignPermissions extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('permissions', function (Blueprint $table) {
|
||||||
|
$table->foreign('user_id')->references('id')->on('users');
|
||||||
|
$table->foreign('server_id')->references('id')->on('servers');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('permissions', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('permissions_user_id_foreign');
|
||||||
|
$table->dropForeign('permissions_server_id_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('permissions_user_id_foreign');
|
||||||
|
$table->dropIndex('permissions_server_id_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignServerVariables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE server_variables
|
||||||
|
MODIFY COLUMN server_id INT(10) UNSIGNED NULL,
|
||||||
|
MODIFY COLUMN variable_id INT(10) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
|
||||||
|
Schema::table('server_variables', function (Blueprint $table) {
|
||||||
|
$table->foreign('server_id')->references('id')->on('servers');
|
||||||
|
$table->foreign('variable_id')->references('id')->on('service_variables');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('server_variables', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('server_variables_server_id_foreign');
|
||||||
|
$table->dropForeign('server_variables_variable_id_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('server_variables_server_id_foreign');
|
||||||
|
$table->dropIndex('server_variables_variable_id_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE allocations
|
||||||
|
MODIFY COLUMN server_id MEDIUMINT(8) UNSIGNED NULL,
|
||||||
|
MODIFY COLUMN variable_id MEDIUMINT(8) UNSIGNED NOT NULL
|
||||||
|
');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignServiceOptions extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE service_options MODIFY parent_service INT(10) UNSIGNED NOT NULL');
|
||||||
|
|
||||||
|
Schema::table('service_options', function (Blueprint $table) {
|
||||||
|
$table->foreign('parent_service')->references('id')->on('services');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('service_options', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('service_options_parent_service_foreign');
|
||||||
|
$table->dropIndex('service_options_parent_service_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE service_options MODIFY parent_service MEDIUMINT(8) UNSIGNED NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignServiceVariables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::statement('ALTER TABLE service_variables MODIFY option_id INT(10) UNSIGNED NOT NULL');
|
||||||
|
|
||||||
|
Schema::table('service_variables', function (Blueprint $table) {
|
||||||
|
$table->foreign('option_id')->references('id')->on('service_options');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('service_variables', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('service_variables_option_id_foreign');
|
||||||
|
$table->dropIndex('service_variables_option_id_foreign');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::statement('ALTER TABLE service_variables MODIFY option_id MEDIUMINT(8) UNSIGNED NOT NULL');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignSubusers extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('subusers', function (Blueprint $table) {
|
||||||
|
$table->foreign('user_id')->references('id')->on('users');
|
||||||
|
$table->foreign('server_id')->references('id')->on('servers');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('subusers', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('subusers_user_id_foreign');
|
||||||
|
$table->dropForeign('subusers_server_id_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('subusers_user_id_foreign');
|
||||||
|
$table->dropIndex('subusers_server_id_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
36
database/migrations/2016_10_23_204610_add_foreign_tasks.php
Normal file
36
database/migrations/2016_10_23_204610_add_foreign_tasks.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddForeignTasks extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('tasks', function (Blueprint $table) {
|
||||||
|
$table->foreign('server')->references('id')->on('servers');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('tasks', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('tasks_server_foreign');
|
||||||
|
$table->dropForeign('tasks_server_foreign');
|
||||||
|
|
||||||
|
$table->dropIndex('tasks_server_foreign');
|
||||||
|
$table->dropIndex('tasks_server_foreign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,8 +49,21 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($servers as $server)
|
@foreach ($servers as $server)
|
||||||
<tr @if($server->suspended === 1)class="warning"@endif data-server="{{ $server->uuidShort }}">
|
<tr
|
||||||
<td><a href="/admin/servers/view/{{ $server->id }}">{{ $server->name }}</a>@if($server->suspended === 1) <span class="label label-warning">Suspended</span>@endif</td>
|
@if($server->suspended === 1 && !$server->trashed())
|
||||||
|
class="warning"
|
||||||
|
@elseif($server->trashed())
|
||||||
|
class="danger"
|
||||||
|
@endif
|
||||||
|
data-server="{{ $server->uuidShort }}">
|
||||||
|
<td>
|
||||||
|
<a href="/admin/servers/view/{{ $server->id }}">{{ $server->name }}</a>
|
||||||
|
@if($server->suspended === 1 && !$server->trashed())
|
||||||
|
<span class="label label-warning">Suspended</span>
|
||||||
|
@elseif($server->trashed())
|
||||||
|
<span class="label label-danger">Pending Deletion</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td><a href="/admin/users/view/{{ $server->owner }}">{{ $server->a_ownerEmail }}</a></td>
|
<td><a href="/admin/users/view/{{ $server->owner }}">{{ $server->a_ownerEmail }}</a></td>
|
||||||
<td><a href="/admin/nodes/view/{{ $server->node }}">{{ $server->a_nodeName }}</a></td>
|
<td><a href="/admin/nodes/view/{{ $server->node }}">{{ $server->a_nodeName }}</a></td>
|
||||||
<td class="hidden-xs"><code>{{ $server->username }}</code></td>
|
<td class="hidden-xs"><code>{{ $server->username }}</code></td>
|
||||||
|
|
|
@ -30,10 +30,21 @@
|
||||||
<li><a href="/admin/servers">Servers</a></li>
|
<li><a href="/admin/servers">Servers</a></li>
|
||||||
<li class="active">{{ $server->name }} ({{ $server->uuidShort}})</li>
|
<li class="active">{{ $server->name }} ({{ $server->uuidShort}})</li>
|
||||||
</ul>
|
</ul>
|
||||||
@if($server->suspended === 1)
|
@if($server->suspended === 1 && !$server->trashed())
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
This server is suspended and has no user access. Processes cannot be started and files cannot be modified. All API access is disabled unless using a master token.
|
This server is suspended and has no user access. Processes cannot be started and files cannot be modified. All API access is disabled unless using a master token.
|
||||||
</div>
|
</div>
|
||||||
|
@elseif($server->trashed())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
This server is marked for deletion <strong>{{ Carbon::parse($server->deleted_at)->addMinutes(env('APP_DELETE_MINUTES', 10))->diffForHumans() }}</strong>. If you want to cancel this action simply click the button below.
|
||||||
|
<br /><br />
|
||||||
|
<form action="{{ route('admin.servers.post.queuedDeletion', $server->id) }}" method="POST">
|
||||||
|
<button class="btn btn-sm btn-default" name="cancel" value="1">Cancel Deletion</button>
|
||||||
|
<button class="btn btn-sm btn-danger pull-right" name="force_delete" value="1"><strong>Force</strong> Delete</button>
|
||||||
|
<button class="btn btn-sm btn-danger pull-right" name="delete" style="margin-right:10px;" value="1">Delete</button>
|
||||||
|
{!! csrf_field() !!}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if($server->installed === 0)
|
@if($server->installed === 0)
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
|
@ -55,7 +66,7 @@
|
||||||
@if($server->installed !== 2)
|
@if($server->installed !== 2)
|
||||||
<li><a href="#tab_manage" data-toggle="tab">Manage</a></li>
|
<li><a href="#tab_manage" data-toggle="tab">Manage</a></li>
|
||||||
@endif
|
@endif
|
||||||
<li><a href="#tab_delete" data-toggle="tab">Delete</a></li>
|
@if(!$server->trashed())<li><a href="#tab_delete" data-toggle="tab">Delete</a></li>@endif
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="tab_about">
|
<div class="tab-pane active" id="tab_about">
|
||||||
|
|
Loading…
Reference in a new issue