From 850f2b9a4ff95b5fee64ffa9da74ca53b3f8eaeb Mon Sep 17 00:00:00 2001
From: SkyMulley
Date: Mon, 10 Aug 2026 16:39:22 +0100
Subject: [PATCH] Disable reinstall action during normal server status if "skip
egg install scripts" setting is enabled (#5696)
### 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
---
app/Exceptions/DisplayException.php | 2 +-
app/Models/Server.php | 13 +++
.../Servers/ReinstallServerService.php | 6 +
.../Api/Application/ServerTransformer.php | 1 +
.../Api/Client/ServerTransformer.php | 1 +
resources/lang/en/admin/server.php | 1 +
resources/scripts/api/server/getServer.ts | 2 +
.../server/settings/ReinstallServerBox.tsx | 12 ++
.../views/admin/servers/view/manage.blade.php | 5 +-
.../Servers/ServerControllerTest.php | 26 +++++
.../ServerManagementControllerTest.php | 103 ++++++++++++++++++
.../Client/Server/SettingsControllerTest.php | 42 +++++++
.../ServersController/ReinstallServerTest.php | 57 ++++++++++
13 files changed, 269 insertions(+), 2 deletions(-)
create mode 100644 tests/Integration/Api/Application/Servers/ServerControllerTest.php
create mode 100644 tests/Integration/Api/Application/Servers/ServerManagementControllerTest.php
create mode 100644 tests/Integration/Http/Controllers/Admin/ServersController/ReinstallServerTest.php
diff --git a/app/Exceptions/DisplayException.php b/app/Exceptions/DisplayException.php
index 884df9a89..26e662cc6 100644
--- a/app/Exceptions/DisplayException.php
+++ b/app/Exceptions/DisplayException.php
@@ -49,7 +49,7 @@ class DisplayException extends PterodactylException implements HttpExceptionInte
*/
public function render(Request $request): JsonResponse|RedirectResponse
{
- if ($request->expectsJson()) {
+ if ($request->expectsJson() || $request->is('api/*')) {
return response()->json(Handler::toArray($this), $this->getStatusCode(), $this->getHeaders());
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 7411a2a9c..0773823d4 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -220,6 +220,19 @@ class Server extends Model implements Identifiable
return $this->status === self::STATUS_SUSPENDED;
}
+ /**
+ * A server that skips its egg's install script gains nothing from a reinstall. The one
+ * exception is a server sitting in a failed state, where that report is the way back out.
+ */
+ public function canBeReinstalled(): bool
+ {
+ return !$this->skip_scripts || in_array($this->status, [
+ self::STATUS_INSTALLING,
+ self::STATUS_INSTALL_FAILED,
+ self::STATUS_REINSTALL_FAILED,
+ ], true);
+ }
+
/**
* Gets the user who owns the server.
*
diff --git a/app/Services/Servers/ReinstallServerService.php b/app/Services/Servers/ReinstallServerService.php
index 182223828..d18a76d41 100644
--- a/app/Services/Servers/ReinstallServerService.php
+++ b/app/Services/Servers/ReinstallServerService.php
@@ -4,6 +4,7 @@ namespace Pterodactyl\Services\Servers;
use Pterodactyl\Models\Server;
use Illuminate\Database\ConnectionInterface;
+use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
class ReinstallServerService
@@ -21,9 +22,14 @@ class ReinstallServerService
* 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();
diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php
index e5db01fb2..e7caee392 100644
--- a/app/Transformers/Api/Application/ServerTransformer.php
+++ b/app/Transformers/Api/Application/ServerTransformer.php
@@ -85,6 +85,7 @@ class ServerTransformer extends BaseTransformer
// This field is deprecated, please use "status".
'installed' => $server->isInstalled() ? 1 : 0,
'environment' => $this->environmentService->handle($server),
+ 'skip_scripts' => $server->skip_scripts,
],
$server->getUpdatedAtColumn() => $this->formatTimestamp($server->updated_at),
$server->getCreatedAtColumn() => $this->formatTimestamp($server->created_at),
diff --git a/app/Transformers/Api/Client/ServerTransformer.php b/app/Transformers/Api/Client/ServerTransformer.php
index 747d2f2d8..6cddc112d 100644
--- a/app/Transformers/Api/Client/ServerTransformer.php
+++ b/app/Transformers/Api/Client/ServerTransformer.php
@@ -79,6 +79,7 @@ class ServerTransformer extends BaseClientTransformer
// This field is deprecated, please use "status".
'is_installing' => !$server->isInstalled(),
'is_transferring' => !is_null($server->transfer),
+ 'skip_scripts' => $server->skip_scripts,
];
}
diff --git a/resources/lang/en/admin/server.php b/resources/lang/en/admin/server.php
index 29cb72d18..ff7747eef 100644
--- a/resources/lang/en/admin/server.php
+++ b/resources/lang/en/admin/server.php
@@ -4,6 +4,7 @@ return [
'exceptions' => [
'no_new_default_allocation' => 'You are attempting to delete the default allocation for this server but there is no fallback allocation to use.',
'marked_as_failed' => 'This server was marked as having failed a previous installation. Current status cannot be toggled in this state.',
+ 'skipping_install_script' => 'This server is configured to skip its egg\'s install script. Reinstalling is not available until that setting is disabled.',
'bad_variable' => 'There was a validation error with the :name variable.',
'daemon_exception' => 'There was an exception while attempting to communicate with the daemon resulting in a HTTP/:code response code. This exception has been logged. (request id: :request_id)',
'default_allocation_not_found' => 'The requested default allocation was not found in this server\'s allocations.',
diff --git a/resources/scripts/api/server/getServer.ts b/resources/scripts/api/server/getServer.ts
index 16743ef87..d24194447 100644
--- a/resources/scripts/api/server/getServer.ts
+++ b/resources/scripts/api/server/getServer.ts
@@ -58,6 +58,7 @@ export interface Server {
backups: number;
};
isTransferring: boolean;
+ skipScripts: boolean;
variables: ServerEggVariable[];
allocations: Allocation[];
}
@@ -83,6 +84,7 @@ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData)
eggFeatures: data.egg_features || [],
featureLimits: { ...data.feature_limits },
isTransferring: data.is_transferring,
+ skipScripts: data.skip_scripts,
variables: ((data.relationships?.variables as FractalResponseList | undefined)?.data || []).map(
rawDataToServerEggVariable
),
diff --git a/resources/scripts/components/server/settings/ReinstallServerBox.tsx b/resources/scripts/components/server/settings/ReinstallServerBox.tsx
index 3a5a8dad5..42f7a4a0e 100644
--- a/resources/scripts/components/server/settings/ReinstallServerBox.tsx
+++ b/resources/scripts/components/server/settings/ReinstallServerBox.tsx
@@ -11,6 +11,7 @@ import { Dialog } from '@/components/elements/dialog';
export default () => {
const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid);
+ const skipScripts = ServerContext.useStoreState((state) => state.server.data!.skipScripts);
const [modalVisible, setModalVisible] = useState(false);
const { addFlash, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes);
@@ -36,6 +37,17 @@ export default () => {
clearFlashes();
}, []);
+ if (skipScripts) {
+ return (
+
+
+ Reinstalling this server has been disabled because it is configured to skip its egg's install
+ script. If you would like to reinstall this server, contact a server administrator.
+
+
+ );
+ }
+
return (
This will reinstall the server with the assigned service scripts. Danger! This could overwrite server data.