Nextcloud 16/17 on OpenBSD 6.7: Update via command line

Table of contents

Summary Summary

NextCloud (opens in a new tab), “the flexible open source file synchronization and sharing solution”, provides build-in updater (opens in a new tab). Thankfully, we can update/upgrade the software with its own updater.

Updated on 2020-02-10 Updated on 2020-02-10

Updating 18.0.14 -> 19.0.8 and 19.0.8 -> 20.0.7 were successful with the web updater instead of command line interface on OpenBSD (opens in a new tab) 6.8 with PHP (opens in a new tab) 7.4. It’s more convenient : )

Overview Overview

This is how to carry it out via command line after installing NextCloud on OpenBSD (opens in a new tab):

console
# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php

$ cd <nextcloud-dir>

$ # apply for env without `chroot` to "datadirectory"
# nvim config/config.php

$ # `occ upgrade` in updater.phar requires `php` executable
$ doas -u <nextcloud-user> php updater/updater.phar
$ # Continue update? -> y
$ # Should the "occ upgrade" command be executed? -> y
$ # Keep maintenance mode active? -> y
$ # or:
$ #doas -u <nextcloud-user> php-7.3 occ maintenance:mode --off

$ # apply for env with `chroot` to "datadirectory"
$ doas nvim config/config.php

# rm /usr/local/bin/php

Tutorial (Step-by-step description) Tutorial (Step-by-step description)

Move to the NextCloud directory:

console
$ cd <nextcloud-dir>

First, change config.php (opens in a new tab) temporarily:

console
# nvim config/config.php

Here, set “datadirectory” as it is without chroot (opens in a new tab):

diff
- 'datadirectory' => '/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/var/www/<web-dir>/nextcloud/data',

Next, prepare php (opens in a new tab) executable for updater.phar:

console
# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php

OK. Ready. Let’s run updater:

console
$ doas -u <nextcloud-user> php updater/updater.phar

The updating process will start like this:

console
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 16.0.6.

Update to Nextcloud 17.0.1 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip
Open changelog ↗

Steps that will be executed:
[ ] Check for expected files
[ ] Check for write permissions
[ ] Create backup
[ ] Downloading
[ ] Verify integrity
[ ] Extracting
[ ] Enable maintenance mode
[ ] Replace entry points
[ ] Delete old files
[ ] Move new files in place
[ ] Done

Start update? [y/N] y

Then

console
Info: Gracefully stopping the updater via Ctrl-C is not possible - PCNTL extension is not loaded.

[✔] Check for expected files
[✔] Check for write permissions
[✔] Create backup
[✔] Downloading
[✔] Verify integrity
[✔] Extracting
[✔] Enable maintenance modeconfig/
[✔] Replace entry points
[✔] Delete old files
[✔] Move new files in place
[✔] Done

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n] y

And

console
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2019-11-20T12:55:00+00:00 Set log level to debug
2019-11-20T12:55:00+00:00 Repair step: Repair MySQL collation
...
2019-11-20T12:56:37+00:00 Update successful
2019-11-20T12:56:37+00:00 Maintenance mode is kept active
2019-11-20T12:56:37+00:00 Reset log level

Keep maintenance mode active? [y/N] y

Maintenance mode is still necessary because we have an invalid config.php where chroot is deactivated.

console
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
...

The update is successful. Let’s clean up and restart the service.

Remove the temporary executable:

console
# rm /usr/local/bin/php

Stop maintenance mode:

console
$ doas -u <nextcloud-user> php-7.3 occ maintenance:mode --off

Finally, restore “datadirectory” in config.php to be under chroot:

console
# nvim config/config.php
diff
- 'datadirectory' => '/etc/www/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/<web-dir>/nextcloud/data',

Finished.

More on: Run web, mail and federated services

OBSD Solutions

OBSD Solutions: OpenBSD consulting and support by Scqr, Reflerd Inc. (opens in a new tab)

Comments and feedback are welcome.