Custom config.php content in fpm chroot gets removed by nc

Hello there,
as described in the title, if 've a problem with my setup. Background:
Running NC via nginx & php-fpm using the php-fpm chroot option. Everythings works fine so far (eg. Webcron) except using operating system cron.
Because of the fpm chroot settings, php-fpm needs other path settings in config.php eg.

'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/chroot-data/public/apps',
      'url' => '/apps',
      'writable' => true,
  'datadirectory' =>'/chroot-data/nextcloud_data',

Works fine. But running (as nextcoud user)

php -f /srv/users/nextcloud/chroot/chroot-data/public/cron.php

will fail, because of the different filesystem structure seen by php-cli.
One solution often found on the web is to prepend the data & apps directory option with something like this:

((php_sapi_name() != 'cli') ? '' : '/srv/users/nextcloud/chroot')

(or setting something like $CUSTOM_ROOT = … at the top of the config file for more readability)

Sadly this seems to be cleaned out by nc sanitize operations and the only way I see to stop that, is to set

'config_is_read_only' => true,

but this also stops the Updater from working (need to change config.php manually).

So, long story short, is there any other way (like ‘overwrite.cli.url’ => )to respect the nc paths in a chrooted environment ?

Thanks in advance :slight_smile:


Nextcloud version (eg, 12.0.2): 13.0.5
Operating system and version (eg, Ubuntu 17.04): Gentoo
Apache or nginx version (eg, Apache 2.4.25): nginx 1.14.0-r2
PHP version (eg, 7.1): 7.1.18

i think this you shoukld post this in devel git hub

Thank you for your suggestion !

The solution provided by blizzz works:

place the condition in config/custom.config.php (create it), this should not be overwritten iirc.