'checkUpdate']; public function mount() { $this->refreshUpgradeState(); } public function checkUpdate() { try { $this->refreshUpgradeState(); } catch (\Throwable $e) { return handleError($e, $this); } } protected function refreshUpgradeState(): void { $this->currentVersion = config('constants.coolify.version'); $this->latestVersion = get_latest_version_of_coolify(); $this->devMode = isDev(); if ($this->devMode) { $this->isUpgradeAvailable = true; return; } $settings = InstanceSettings::find(0); if (data_get($settings, 'update_channel') === 'custom') { $this->latestVersion = (string) $settings->update_custom_tag; $this->isUpgradeAvailable = $this->fullButton && $this->latestVersion !== ''; return; } $hasNewerVersion = version_compare($this->latestVersion, $this->currentVersion, '>'); $newVersionAvailable = (bool) data_get($settings, 'new_version_available', false); if ($settings && $newVersionAvailable && ! $hasNewerVersion) { $settings->update(['new_version_available' => false]); $newVersionAvailable = false; } $this->isUpgradeAvailable = $hasNewerVersion && $newVersionAvailable; } public function upgrade() { try { if (! isInstanceAdmin()) { abort(403); } if ($this->updateInProgress) { return; } $this->updateInProgress = true; dispatch(function () { try { UpdateCoolify::run(manual_update: true); } catch (\Throwable $e) { report($e); } })->afterResponse(); auditLog('ui.instance.upgrade_started', [ 'team_id' => null, 'resource' => 'instance', 'from_version' => config('constants.coolify.version'), 'to_version' => $this->latestVersion, ]); } catch (\Throwable $e) { return handleError($e, $this); } } public function getUpgradeStatus(): array { // Only root team members can view upgrade status if (auth()->user()?->currentTeam()?->id !== 0) { return ['status' => 'none']; } $server = Server::find(0); if (! $server) { return ['status' => 'none']; } $statusFile = CoolifyUpgradeStatus::FILE; try { $content = instant_remote_process( ["cat {$statusFile} 2>/dev/null || echo ''"], $server, false ); $content = trim($content ?? ''); } catch (\Throwable $e) { return ['status' => 'none']; } return CoolifyUpgradeStatus::fromFile( content: $content, // The version of the container that answers, not $currentVersion: after the restart, that is still the old version of the page. runningVersion: (string) config('constants.coolify.version'), targetVersion: $this->latestVersion !== '' ? $this->latestVersion : get_latest_version_of_coolify(), ); } }