Files
pterodactyl-panel/app/Actions/Servers/ReinstallServer.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

32 lines
932 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Actions\Servers;
use Illuminate\Support\Facades\DB;
use Pterodactyl\Contracts\Servers\ReinstallsServers;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Facades\Daemon;
use Pterodactyl\Models\Server;
use Throwable;
final readonly class ReinstallServer implements ReinstallsServers
{
/**
* @throws DisplayException when the server skips its install script and is installed
* @throws Throwable
*/
public function reinstall(Server $server): Server
{
throw_unless($server->canBeReinstalled(), DisplayException::class, trans('admin/server.exceptions.skipping_install_script'));
return DB::transaction(function () use ($server): Server {
$server->fill(['status' => Server::STATUS_INSTALLING])->save();
Daemon::server($server)->reinstall();
return $server->refresh();
});
}
}