Skip to content

Commit 78d6e59

Browse files
authored
Merge branch 'develop' into cputhreads
2 parents 71292a7 + 7d45379 commit 78d6e59

31 files changed

+1877
-1317
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ return PhpCsFixer\Config::create()
3333
'new_with_braces' => false,
3434
'no_alias_functions' => true,
3535
'no_multiline_whitespace_before_semicolons' => true,
36+
'no_superfluous_phpdoc_tags' => false,
3637
'no_unreachable_default_argument_value' => true,
3738
'no_useless_return' => true,
3839
'not_operator_with_successor_space' => true,

app/Http/Requests/Api/Client/Servers/SendPowerRequest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public function permission(): string
1818
case 'start':
1919
return Permission::ACTION_CONTROL_START;
2020
case 'stop':
21+
case 'kill':
2122
return Permission::ACTION_CONTROL_STOP;
2223
case 'restart':
2324
return Permission::ACTION_CONTROL_RESTART;
24-
case 'kill':
25-
return Permission::ACTION_CONTROL_KILL;
2625
}
2726

2827
return '__invalid';

app/Models/Permission.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class Permission extends Validable
2020
const ACTION_CONTROL_START = 'control.start';
2121
const ACTION_CONTROL_STOP = 'control.stop';
2222
const ACTION_CONTROL_RESTART = 'control.restart';
23-
const ACTION_CONTROL_KILL = 'control.kill';
2423

2524
const ACTION_DATABASE_READ = 'database.read';
2625
const ACTION_DATABASE_CREATE = 'database.create';
@@ -111,7 +110,6 @@ class Permission extends Validable
111110
'start' => 'Allows a user to start the server if it is stopped.',
112111
'stop' => 'Allows a user to stop a server if it is running.',
113112
'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.',
114-
'kill' => 'Allows a user to terminate a server process.',
115113
],
116114
],
117115

app/Models/Server.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class Server extends Validable
6161
*/
6262
const RESOURCE_NAME = 'server';
6363

64+
const STATUS_INSTALLING = 0;
65+
const STATUS_INSTALLED = 1;
66+
const STATUS_INSTALL_FAILED = 2;
67+
6468
/**
6569
* The table associated with the model.
6670
*

app/Repositories/Wings/DaemonServerRepository.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Pterodactyl\Repositories\Wings;
44

5-
use BadMethodCallException;
65
use Webmozart\Assert\Assert;
76
use Pterodactyl\Models\Server;
87
use GuzzleHttp\Exception\TransferException;
@@ -13,7 +12,6 @@ class DaemonServerRepository extends DaemonRepository
1312
/**
1413
* Returns details about a server from the Daemon instance.
1514
*
16-
* @return array
1715
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
1816
*/
1917
public function getDetails(): array
@@ -89,10 +87,20 @@ public function delete(): void
8987

9088
/**
9189
* Reinstall a server on the daemon.
90+
*
91+
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
9292
*/
9393
public function reinstall(): void
9494
{
95-
throw new BadMethodCallException('Method is not implemented.');
95+
Assert::isInstanceOf($this->server, Server::class);
96+
97+
try {
98+
$this->getHttpClient()->post(sprintf(
99+
'/api/servers/%s/reinstall', $this->server->uuid
100+
));
101+
} catch (TransferException $exception) {
102+
throw new DaemonConnectionException($exception);
103+
}
96104
}
97105

98106
/**

app/Services/Servers/ReinstallServerService.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
namespace Pterodactyl\Services\Servers;
44

55
use Pterodactyl\Models\Server;
6-
use GuzzleHttp\Exception\RequestException;
76
use Illuminate\Database\ConnectionInterface;
87
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
98
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
10-
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
119

1210
class ReinstallServerService
1311
{
@@ -44,28 +42,23 @@ public function __construct(
4442
}
4543

4644
/**
47-
* @param int|\Pterodactyl\Models\Server $server
45+
* Reinstall a server on the remote daemon.
4846
*
49-
* @throws \Pterodactyl\Exceptions\DisplayException
50-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
51-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
47+
* @param \Pterodactyl\Models\Server $server
48+
* @return \Pterodactyl\Models\Server
49+
*
50+
* @throws \Throwable
5251
*/
53-
public function reinstall($server)
52+
public function reinstall(Server $server)
5453
{
55-
if (! $server instanceof Server) {
56-
$server = $this->repository->find($server);
57-
}
58-
59-
$this->database->beginTransaction();
60-
$this->repository->withoutFreshModel()->update($server->id, [
61-
'installed' => 0,
62-
], true, true);
54+
$this->database->transaction(function () use ($server) {
55+
$this->repository->withoutFreshModel()->update($server->id, [
56+
'installed' => Server::STATUS_INSTALLING,
57+
]);
6358

64-
try {
6559
$this->daemonServerRepository->setServer($server)->reinstall();
66-
$this->database->commit();
67-
} catch (RequestException $exception) {
68-
throw new DaemonConnectionException($exception);
69-
}
60+
});
61+
62+
return $server->refresh();
7063
}
7164
}

composer.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@
1515
"ext-mbstring": "*",
1616
"ext-pdo_mysql": "*",
1717
"ext-zip": "*",
18-
"appstract/laravel-blade-directives": "^1.6",
19-
"aws/aws-sdk-php": "^3.110",
20-
"cakephp/chronos": "^1.2",
21-
"doctrine/dbal": "^2.9",
18+
"appstract/laravel-blade-directives": "^1.8",
19+
"aws/aws-sdk-php": "^3.134",
20+
"cakephp/chronos": "^1.3",
21+
"doctrine/dbal": "^2.10",
2222
"fideloper/proxy": "^4.2",
23-
"guzzlehttp/guzzle": "^6.3",
23+
"guzzlehttp/guzzle": "^6.5",
2424
"hashids/hashids": "^4.0",
25-
"laracasts/utilities": "^3.0",
26-
"laravel/framework": "^6.0.0",
27-
"laravel/helpers": "^1.1",
25+
"laracasts/utilities": "^3.1",
26+
"laravel/framework": "^6.18",
27+
"laravel/helpers": "^1.2",
2828
"laravel/tinker": "^1.0",
2929
"lcobucci/jwt": "^3.3",
3030
"matriphe/iso-639": "^1.2",
3131
"pragmarx/google2fa": "^5.0",
3232
"predis/predis": "^1.1",
3333
"prologue/alerts": "^0.4",
3434
"s1lentium/iptools": "^1.1",
35-
"spatie/laravel-fractal": "^5.6",
36-
"staudenmeir/belongs-to-through": "^2.6",
37-
"symfony/yaml": "^4.0",
38-
"webmozart/assert": "^1.5"
35+
"spatie/laravel-fractal": "^5.7",
36+
"staudenmeir/belongs-to-through": "^2.9",
37+
"symfony/yaml": "^4.4",
38+
"webmozart/assert": "^1.7"
3939
},
4040
"require-dev": {
4141
"barryvdh/laravel-debugbar": "^3.2",
4242
"barryvdh/laravel-ide-helper": "^2.6",
4343
"codedungeon/phpunit-result-printer": "0.25.1",
44-
"friendsofphp/php-cs-fixer": "^2.15.1",
45-
"laravel/dusk": "^5.5",
46-
"php-mock/php-mock-phpunit": "^2.4",
44+
"friendsofphp/php-cs-fixer": "^2.16.1",
45+
"laravel/dusk": "^5.11",
46+
"php-mock/php-mock-phpunit": "^2.6",
4747
"phpunit/phpunit": "^7"
4848
},
4949
"autoload": {

0 commit comments

Comments
 (0)