mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-29 10:55:43 -05:00
### Description You're able to enable a "skip egg install scripts" per server, while still being able to reinstall a server. With this setting enabled, reinstalling a server has no functional use, the server is locked and shutdown, then simply unlocked immediately afterwards after a success signal from wings. This PR disables the reinstall button when skip install scripts is enabled for both the user and admin, with a little component telling you why you cannot reinstall. The reinstall button is not disabled if the server is in a status that reinstall could resolve (eg. failed install). ### Resolved issues: 1. [x] resolves pterodactyl/panel#5306
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Services\Servers;
|
|
|
|
use Pterodactyl\Models\Server;
|
|
use Illuminate\Database\ConnectionInterface;
|
|
use Pterodactyl\Exceptions\DisplayException;
|
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
|
|
|
class ReinstallServerService
|
|
{
|
|
/**
|
|
* ReinstallService constructor.
|
|
*/
|
|
public function __construct(
|
|
private ConnectionInterface $connection,
|
|
private DaemonServerRepository $daemonServerRepository,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Reinstall a server on the remote daemon.
|
|
*
|
|
* @throws \Throwable
|
|
* @throws DisplayException
|
|
*/
|
|
public function handle(Server $server): Server
|
|
{
|
|
if (!$server->canBeReinstalled()) {
|
|
throw new DisplayException(trans('admin/server.exceptions.skipping_install_script'));
|
|
}
|
|
|
|
return $this->connection->transaction(function () use ($server) {
|
|
$server->fill(['status' => Server::STATUS_INSTALLING])->save();
|
|
|
|
$this->daemonServerRepository->setServer($server)->reinstall();
|
|
|
|
return $server->refresh();
|
|
});
|
|
}
|
|
}
|