loading...

Nextcloud on OpenBSD: Update via command line

nabbisen profile image Heddi Nabbisen Updated on ・3 min read

Summary

NextCloud, "the flexible open source file synchronization and sharing solution", provides build-in updater.
Thankfully, We can update/upgrade the software with it.
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

Description (step-by-step)

Move to the NextCloud directory:

$ cd <nextcloud-dir>

First, change config.php temporarily:

# nvim config/config.php

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

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

Next, prepare php executable for updater.phar:

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

OK. Ready.
Let's run updater:

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

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

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

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

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
...

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

Remove the temporary executable:

# rm /usr/local/bin/php

Stop maintenance mode:

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

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

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

Finished.

Posted on by:

nabbisen profile

Heddi Nabbisen

@nabbisen

An ICT designer/developer and a security monk. "With a cool brain and a warm heart", I am challenging unsolved problems in our society. I use OpenBSD/Rust/etc.

Discussion

pic
Editor guide