brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: occ config:system:set trusted_domains 2 changes one entry of the list

CLI
~/tips/tip-nextcloud-occ-config-system-set-trusted-domains

sudo -E -u www-data php occ config:system:get trusted_domains

Array settings in config.php are set with an index. Without it you overwrite the wrong thing.

The trusted_domains key in config.php is a list, and occ can change it one entry at a time if you give it an index.

First look at what is there:

sudo -E -u www-data php occ config:system:get trusted_domains

The docs show three lines of output, one per entry. To replace the third one you give its position, starting at 0, as a second name:

sudo -E -u www-data php occ config:system:set trusted_domains 2 --value=example.com

That replaces entry 2 and leaves the others alone. If you rather set the whole list at once, use the json type:

sudo -E -u www-data php occ config:system:set trusted_domains \
  --type json --value '["nextcloud.local","example.com"]'

The same index trick works for other array and nested settings, such as the redis block in config.php, where the docs use config:system:set redis host --value=....

The caveat: the json form replaces the entire list. In the docs example, a list of three domains becomes two. Run the get first and make sure the new list still has every address you use before you run it.

The docs list two more options for config:system:set. --update-only changes a value only if one is already stored, and otherwise prints Value not updated, as it has not been set before. Without it, the command creates the value when it doesn’t exist. The --type option comes with the docs warning “Use carefully; can break your instance”.

To remove an entry again, config:system:delete takes the same name and index. It doesn’t complain when the value wasn’t set, unless you add --error-if-not-exists. This was not run against a live Nextcloud; it follows the admin manual.

Further reading: Nextcloud admin manual: apps, background jobs and config commands

Going deeper: Guide: put Nextcloud behind Nginx Proxy Manager with HTTPS and the right headers

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link