Merge branch 'develop' into cputhreads
This commit is contained in:
commit
78d6e59fc5
31 changed files with 1883 additions and 1323 deletions
|
@ -18,11 +18,10 @@ class SendPowerRequest extends ClientApiRequest
|
|||
case 'start':
|
||||
return Permission::ACTION_CONTROL_START;
|
||||
case 'stop':
|
||||
case 'kill':
|
||||
return Permission::ACTION_CONTROL_STOP;
|
||||
case 'restart':
|
||||
return Permission::ACTION_CONTROL_RESTART;
|
||||
case 'kill':
|
||||
return Permission::ACTION_CONTROL_KILL;
|
||||
}
|
||||
|
||||
return '__invalid';
|
||||
|
|
|
@ -20,7 +20,6 @@ class Permission extends Validable
|
|||
const ACTION_CONTROL_START = 'control.start';
|
||||
const ACTION_CONTROL_STOP = 'control.stop';
|
||||
const ACTION_CONTROL_RESTART = 'control.restart';
|
||||
const ACTION_CONTROL_KILL = 'control.kill';
|
||||
|
||||
const ACTION_DATABASE_READ = 'database.read';
|
||||
const ACTION_DATABASE_CREATE = 'database.create';
|
||||
|
@ -111,7 +110,6 @@ class Permission extends Validable
|
|||
'start' => 'Allows a user to start the server if it is stopped.',
|
||||
'stop' => 'Allows a user to stop a server if it is running.',
|
||||
'restart' => 'Allows a user to perform a server restart. This allows them to start the server if it is offline, but not put the server in a completely stopped state.',
|
||||
'kill' => 'Allows a user to terminate a server process.',
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ class Server extends Validable
|
|||
*/
|
||||
const RESOURCE_NAME = 'server';
|
||||
|
||||
const STATUS_INSTALLING = 0;
|
||||
const STATUS_INSTALLED = 1;
|
||||
const STATUS_INSTALL_FAILED = 2;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Repositories\Wings;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
|
@ -13,7 +12,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
/**
|
||||
* Returns details about a server from the Daemon instance.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function getDetails(): array
|
||||
|
@ -89,10 +87,20 @@ class DaemonServerRepository extends DaemonRepository
|
|||
|
||||
/**
|
||||
* Reinstall a server on the daemon.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function reinstall(): void
|
||||
{
|
||||
throw new BadMethodCallException('Method is not implemented.');
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
try {
|
||||
$this->getHttpClient()->post(sprintf(
|
||||
'/api/servers/%s/reinstall', $this->server->uuid
|
||||
));
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
namespace Pterodactyl\Services\Servers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
|
||||
class ReinstallServerService
|
||||
{
|
||||
|
@ -44,28 +42,23 @@ class ReinstallServerService
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int|\Pterodactyl\Models\Server $server
|
||||
* Reinstall a server on the remote daemon.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \Pterodactyl\Models\Server
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function reinstall($server)
|
||||
public function reinstall(Server $server)
|
||||
{
|
||||
if (! $server instanceof Server) {
|
||||
$server = $this->repository->find($server);
|
||||
}
|
||||
$this->database->transaction(function () use ($server) {
|
||||
$this->repository->withoutFreshModel()->update($server->id, [
|
||||
'installed' => Server::STATUS_INSTALLING,
|
||||
]);
|
||||
|
||||
$this->database->beginTransaction();
|
||||
$this->repository->withoutFreshModel()->update($server->id, [
|
||||
'installed' => 0,
|
||||
], true, true);
|
||||
|
||||
try {
|
||||
$this->daemonServerRepository->setServer($server)->reinstall();
|
||||
$this->database->commit();
|
||||
} catch (RequestException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
});
|
||||
|
||||
return $server->refresh();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue