Occ config commands have no effect

[/details]

Nextcloud version (eg, 20.0.5): nextcloud:21.0.0
Operating system and version (eg, Ubuntu 20.04): nextcloud:21.0.0 docker image
Apache or nginx version (eg, Apache 2.4.25): apache 2.4.38
PHP version (eg, 7.4): PHP 7.4.16

The issue you are facing:

When running occ config commands the output shows that it is a success however there is no effect. I have tested:
sudo -u www-data PHP_MEMORY_LIMIT=512M php occ COMMAND

  • config:import
  • config:system:set
  • maintenance:mode

and none of the commands have an effect despite giving a positive output.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Using nextcloud:21.0.0 docker image and docker-compose, spin up stack
  2. docker exec -it CONTAINER_ID bash
  3. Run above commands
  4. Command outputs success message
  5. No change is made to config / system

The output of your Nextcloud log in Admin > Logging:

NONE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

NOTE MAINTENANCE MODE IS SET TO TRUE BUT IS NOT ACTIVE ON SYSTEM

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'knowledgebaseenabled' => false,
  'defaultapp' => 'files,dashboard',
  'simpleSignUpLink.shown' => false,
  'filelocking.enabled' => false,
  'trashbin_retention_obligation' => 'auto',
  'versions_retention_obligation' => 'auto',
  'skeletondirectory' => '/var/www/html/core/skeleton',
  'templatedirectory' => '/var/www/html/core/skeleton/Templates',
  'part_file_in_storage' => false,
  'logfile' => '/var/log/nextcloud.log',
  'loglevel' => 0,
  'objectstore' => 
  array (
    'class' => '\\OC\\Files\\ObjectStore\\S3',
    'arguments' => 
    array (
      'bucket' => '',
      'key' => '',
      'secret' => '',
      'region' => 'us-east-1',
      'hostname' => '',
      'port' => '',
      'objectPrefix' => 'data/',
      'autocreate' => false,
      'use_ssl' => false,
      'use_path_style' => false,
    ),
  ),
  'auth.webauthn.enabled' => true,
  'hide_login_form' => false,
  'lost_password_link' => 'https://google.com',
  'config_is_read_only' => false,
  'instanceid' => '*****',
  'passwordsalt' => '*****',
  'secret' => ''*****',',
  'trusted_domains' => 
  array (
    0 => 'localhost:8080',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '21.0.0.18',
  'overwrite.cli.url' => 'http://localhost:8080',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-db:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_asdf',
  'dbpassword' => ''*****',',
  'installed' => true,
  'maintenance' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

N/A

Here is a screenshot showing how I will set a variable and it will not be honored.

When I create a new server that starts in maintenance mode, the occ command does not show the server as in maintenance mode, but the site does.

I seem to have found the issue. I was building a new image from the official nextcloud image to allow importing more environment variables similar to how they do in the image (docker/Dockerfile at master · nextcloud/docker · GitHub)

This was causing issues.

Instead I have moved to generating a config.json file using JQ on container start that then imports the config settings.

jq --argjson MAINTENANCE_MODE "$MAINTENANCE_MODE" \
--argjson LOG_LEVEL "$LOG_LEVEL" \
--argjson FILELOCKING_ENABLED "$FILELOCKING_ENABLED" \
--arg TRASHBIN_RETENTION_OBLIGATION "$TRASHBIN_RETENTION_OBLIGATION" \
--arg VERSIONS_RETENTION_OBLIGATION "$VERSIONS_RETENTION_OBLIGATION" \
--argjson PART_FILE_IN_STORAGE "$PART_FILE_IN_STORAGE" \
--argjson SHOW_SIMPLE_SIGN_UP_LINK "$SHOW_SIMPLE_SIGN_UP_LINK" \
--arg SKELETON_DIRECTORY "$SKELETON_DIRECTORY" \
--arg DEFAULT_TEMPLATES_DIRECTORY "$DEFAULT_TEMPLATES_DIRECTORY" \
--argjson WEBAUTHN_ENABLED "$WEBAUTHN_ENABLED" \
--argjson HIDE_LOGIN_FORM "$HIDE_LOGIN_FORM" \
--arg LOST_PASSWORD_LINK "$LOST_PASSWORD_LINK" \
--argjson KNOWLEDGE_BASE_ENABLED "$KNOWLEDGE_BASE_ENABLED" \
--arg DEFAULT_APP "$DEFAULT_APP" \
--arg REWRITE_BASE_PATH "$REWRITE_BASE_PATH" \
'. .system.knowledgebaseenabled=$KNOWLEDGE_BASE_ENABLED | .system.hide_login_form=$HIDE_LOGIN_FORM | .system."auth.webauthn.enabled"=$WEBAUTHN_ENABLED | .system.skeletondirectory=$SKELETON_DIRECTORY | .system.templatedirectory=$DEFAULT_TEMPLATES_DIRECTORY | .system."simpleSignUpLink.shown"=$SHOW_SIMPLE_SIGN_UP_LINK | .system.part_file_in_storage=$PART_FILE_IN_STORAGE | .system.versions_retention_obligation=$VERSIONS_RETENTION_OBLIGATION | .system.trashbin_retention_obligation=$TRASHBIN_RETENTION_OBLIGATION | .system."filelocking.enabled"=$FILELOCKING_ENABLED | .system.loglevel=$LOG_LEVEL | .system.defaultapp=$DEFAULT_APP | .system.maintenance=$MAINTENANCE_MODE | .system."htaccess.RewriteBase" = $REWRITE_BASE_PATH | .system.lost_password_link = $LOST_PASSWORD_LINK' config.json > config.tmp.json
mv config.tmp.json /var/www/html/config/config.json
# # IMPORT CONFIG IF AVAILABLE
sudo -u www-data PHP_MEMORY_LIMIT=512M php /var/www/html/occ config:import /var/www/html/config/config.json

This seems to work very well for my use case.