DEV Community

nabbisen
nabbisen

Posted on • Updated on • Originally published at obsd.solutions

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

Summary

NextCloud, "the flexible open source file synchronization and sharing solution", provides build-in updater.
Thankfully, we can update/upgrade the software with its own updater.

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 6.8 with PHP 7.4. It's more convenient : )

Overview

This is how to carry it out via command line after installing NextCloud on OpenBSD:

# 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
Enter fullscreen mode Exit fullscreen mode

Tutorial (Step-by-step description)

Move to the NextCloud directory:

$ cd <nextcloud-dir>
Enter fullscreen mode Exit fullscreen mode

First, change config.php temporarily:

# nvim config/config.php
Enter fullscreen mode Exit fullscreen mode

Here, set "datadirectory" as it is without chroot:

- 'datadirectory' => '/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/var/www/<web-dir>/nextcloud/data',
Enter fullscreen mode Exit fullscreen mode

Next, prepare php executable for updater.phar:

# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

OK. Ready.
Let's run updater:

$ doas -u <nextcloud-user> php updater/updater.phar
Enter fullscreen mode Exit fullscreen mode

The updating process will start like this:

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
Enter fullscreen mode Exit fullscreen mode

Then

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
Enter fullscreen mode Exit fullscreen mode

And

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
Enter fullscreen mode Exit fullscreen mode

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

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
...
Enter fullscreen mode Exit fullscreen mode

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

Remove the temporary executable:

# rm /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Stop maintenance mode:

$ doas -u <nextcloud-user> php-7.3 occ maintenance:mode --off
Enter fullscreen mode Exit fullscreen mode

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

# nvim config/config.php
Enter fullscreen mode Exit fullscreen mode
- 'datadirectory' => '/etc/www/<web-dir>/nextcloud/data',
+ 'datadirectory' => '/<web-dir>/nextcloud/data',
Enter fullscreen mode Exit fullscreen mode

Finished.

Top comments (0)