-
Notifications
You must be signed in to change notification settings - Fork 1k
aio-interface: extract Nextcloud latest-major upgrade logic to dedicated script and add UI trigger button #7988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/add-script-and-button-for-logic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97f6653
Extract Nextcloud major upgrade logic to script and add UI button
Copilot daeb325
Rename sendNotification to execCommandInContainer and reuse for upgra…
Copilot 89d1d6d
Add $cmd array validation to execCommandInContainer
Copilot 02e9f9a
Apply suggestion from @szaimen
szaimen 8ab13ce
Apply suggestion from @szaimen
szaimen 3119421
Apply suggestion from @szaimen
szaimen ac0dca2
Apply suggestion from @szaimen
szaimen da06f68
Set installLatestMajor when upgrade-to-latest-major button is clicked
Copilot f29a3d5
Extract getLatestMajorVersion() to avoid duplicating the version string
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/bin/bash | ||
|
|
||
| # shellcheck disable=SC2016 | ||
| image_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" | ||
| IMAGE_MAJOR="${image_version%%.*}" | ||
|
|
||
| php /var/www/html/occ config:system:set updatedirectory --value="/nc-updater" | ||
| INSTALLED_AT="$(php /var/www/html/occ config:app:get core installedat)" | ||
| if [ -n "${INSTALLED_AT}" ]; then | ||
| # Set the installedat to 00 which will allow to skip staging and install the next major directly | ||
| # shellcheck disable=SC2001 | ||
| INSTALLED_AT="$(echo "${INSTALLED_AT}" | sed "s|[0-9][0-9]$|00|")" | ||
| php /var/www/html/occ config:app:set core installedat --value="${INSTALLED_AT}" | ||
| fi | ||
| php /var/www/html/updater/updater.phar --no-interaction --no-backup | ||
| if ! php /var/www/html/occ -V || php /var/www/html/occ status | grep maintenance | grep -q 'true'; then | ||
| echo "Installation of Nextcloud failed!" | ||
| touch "$NEXTCLOUD_DATA_DIR/install.failed" | ||
| exit 1 | ||
| fi | ||
| # shellcheck disable=SC2016 | ||
| installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" | ||
| INSTALLED_MAJOR="${installed_version%%.*}" | ||
| # If a valid upgrade path, trigger the Nextcloud built-in Updater | ||
| if ! [ "$INSTALLED_MAJOR" -gt "$IMAGE_MAJOR" ]; then | ||
| php /var/www/html/updater/updater.phar --no-interaction --no-backup | ||
| if ! php /var/www/html/occ -V || php /var/www/html/occ status | grep maintenance | grep -q 'true'; then | ||
| echo "Installation of Nextcloud failed!" | ||
| # TODO: Add a hint here about what to do / where to look / updater.log? | ||
| touch "$NEXTCLOUD_DATA_DIR/install.failed" | ||
| exit 1 | ||
| fi | ||
| # shellcheck disable=SC2016 | ||
| installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" | ||
| fi | ||
| php /var/www/html/occ config:system:set updatechecker --type=bool --value=true | ||
| php /var/www/html/occ app:enable nextcloud-aio --force | ||
| php /var/www/html/occ db:add-missing-columns | ||
| php /var/www/html/occ db:add-missing-primary-keys | ||
| yes | php /var/www/html/occ db:convert-filecache-bigint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ | |
| readonly class DockerController { | ||
| private const string TOP_CONTAINER = 'nextcloud-aio-apache'; | ||
|
|
||
| private function getLatestMajorVersion(): string { | ||
| return '33'; | ||
| } | ||
|
Comment on lines
+18
to
+20
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can probably be a constant |
||
|
|
||
| public function __construct( | ||
| private DockerActionManager $dockerActionManager, | ||
| private ContainerDefinitionFetcher $containerDefinitionFetcher, | ||
|
|
@@ -221,7 +225,7 @@ public function StartContainer(Request $request, Response $response, array $args | |
| } | ||
|
|
||
| if (isset($request->getParsedBody()['install_latest_major'])) { | ||
| $installLatestMajor = '33'; | ||
| $installLatestMajor = $this->getLatestMajorVersion(); | ||
| } else { | ||
| $installLatestMajor = ''; | ||
| } | ||
|
|
@@ -328,6 +332,23 @@ public function StopContainer(Request $request, Response $response, array $args) | |
| return $nonbufResp; | ||
| } | ||
|
|
||
| public function RunNextcloudUpgradeToLatestMajor(Request $request, Response $response, array $args) : Response { | ||
| $this->configurationManager->installLatestMajor = $this->getLatestMajorVersion(); | ||
|
|
||
| // Get streaming response start and closure | ||
| $nonbufResp = $this->startStreamingResponse($response); | ||
| $body = $nonbufResp->getBody(); | ||
| $addToStreamingResponseBody = function (string $message) use ($body) : void { | ||
| $body->write("<div>" . htmlspecialchars($message, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "</div>"); | ||
| }; | ||
|
|
||
| $this->dockerActionManager->RunNextcloudUpgradeToLatestMajor($addToStreamingResponseBody); | ||
|
|
||
| // End streaming response | ||
| $this->finalizeStreamingResponse($nonbufResp); | ||
| return $nonbufResp; | ||
| } | ||
|
|
||
| public function SystemPrune(Request $request, Response $response, array $args) : Response { | ||
| // Get streaming response start and closure | ||
| $nonbufResp = $this->startStreamingResponse($response); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stay in the parent script