mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-30 15:30:08 +00:00
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:
committed by
Simon L.
parent
cbea0730d3
commit
cc8f1e4f57
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user