Extract Nextcloud major upgrade logic to script and add UI button

Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/8cd11b09-5073-4e27-8e59-9afffaf96c1f

Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-23 19:21:21 +00:00
committed by Simon L.
parent cbea0730d3
commit cc8f1e4f57
6 changed files with 124 additions and 33 deletions

View File

@@ -1027,6 +1027,66 @@ readonly class DockerActionManager {
}
}
public function RunNextcloudUpgradeToLatestMajor(\Closure $addToStreamingResponseBody): void {
$containerName = 'nextcloud-aio-nextcloud';
// Create exec instance
$url = $this->BuildApiUrl(sprintf('containers/%s/exec', urlencode($containerName)));
$response = json_decode(
$this->guzzleClient->request(
'POST',
$url,
[
'json' => [
'AttachStdout' => true,
'AttachStderr' => true,
'Tty' => true,
'Cmd' => ['bash', '/upgrade-latest-major.sh'],
],
]
)->getBody()->getContents(),
true,
512,
JSON_THROW_ON_ERROR,
);
$execId = $response['Id'];
// Start exec and stream output
$url = $this->BuildApiUrl(sprintf('exec/%s/start', $execId));
$streamResponse = $this->guzzleClient->request(
'POST',
$url,
[
'stream' => true,
'json' => [
'Detach' => false,
'Tty' => true,
],
]
);
$body = $streamResponse->getBody();
$buffer = '';
while (!$body->eof()) {
$chunk = $body->read(1024);
$buffer .= $chunk;
// Flush complete lines
while (($pos = strpos($buffer, "\n")) !== false) {
$line = substr($buffer, 0, $pos);
$buffer = substr($buffer, $pos + 1);
$line = rtrim($line, "\r");
if ($line !== '') {
$addToStreamingResponseBody($line);
}
}
}
// Flush any remaining output
if (trim($buffer) !== '') {
$addToStreamingResponseBody(trim($buffer));
}
}
public function SystemPrune(?\Closure $addToStreamingResponseBody = null): void {
$endpoints = [
// Remove stopped containers