Warn on mismatching auto-config files

Co-authored-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Florian Latifi <mail@florian-latifi.at>
This commit is contained in:
Florian Latifi 2023-12-14 00:06:24 +01:00
parent 6151f60208
commit 089413edc2
2 changed files with 47 additions and 0 deletions

View File

@ -217,6 +217,18 @@ To customize Apache max file upload limit you can change the following variable:
- `APACHE_BODY_LIMIT` (default `1073741824` [1GiB]) This restricts the total
size of the HTTP request body sent from the client. It specifies the number of _bytes_ that are allowed in a request body. A value of **0** means **unlimited**. Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html#apache) for more information.
### Auto configuration and Nextcloud updates
The image comes with special config files for Nextcloud that set parameters specific to containerized usage (e.g. `upgrade-disable-web.config.php`) or enable auto configuration via environment variables (e.g. `reverse-proxy.config.php`). Within the image, the latest version of these config files are located in `/usr/src/nextcloud/config`.
During a fresh Nextcloud installation, the latest version (from the image) of these files are copied into `/var/www/html/config` so that they are stored within your container's persistent volume and picked up by Nextcloud alongside your local configuration.
The copied files, however, are **not** automatically overwritten whenever you update your environment with a newer Nextcloud image. This is to prevent local changes in `/var/www/html/config` from being unexpectedly overwritten. This may lead to your image-specific configuration files becoming outdated and image functionality not matching that which is documented.
A warning will be generated in the container log output when outdated image-specific configuration files are detected at startup in a running container. When you see this warning, you should manually compare (or copy) the files from `/usr/src/nextcloud/config` to `/var/www/html/config`.
As long as you have not modified any of the provided config files in `/var/www/html/config` (other than `config.php`) or only added new ones with names that do not conflict with the image specific ones, copying the new ones into place should be safe (but check the source path `/usr/src/nextcloud/config` for any newly named config files to avoid new overlaps just in case).
Not keeping these files up-to-date when this warning appears may cause certain auto configuration environment variables to be ignored or the image to not work as documented or expected.
## Auto configuration via hook folders

View File

@ -273,6 +273,41 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi
) 9> /var/www/html/nextcloud-init-sync.lock
# check if at least one config file on persistent storage differs from running image
outOfDateCfgFiles=0
for cfgPath in /usr/src/nextcloud/config/*.php; do
cfgFile=$(basename "$cfgPath")
if [ "$cfgFile" != "config.sample.php" ]; then
if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then
outOfDateCfgFiles=1
break # we stop at detecting just one out of date file here so that we can generate the full list later (because arrays are a PITA w/o bash)
fi
fi
done
if [ $outOfDateCfgFiles -eq 1 ]; then # i.e. if some out of date or missing config files were noted let's try to inform the operator
echo "*** WARNING ***"
echo "*** The image-specific config files on your persistent volume differ from those that ship with the running image."
echo "*** This could lead to behavior that differs from that documented for the image (such as auto configuration variables not working as expected)."
echo "*** Don't panic! This can happen if you've ever upgraded your running container since we do not overwrite configuration files stored on persistent volumes after initial installation for your safety."
echo "*** The following config files differ from that expected by the running image:"
for cfgPath in /usr/src/nextcloud/config/*.php; do
cfgFile=$(basename "$cfgPath")
if [ "$cfgFile" != "config.sample.php" ]; then
if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then
echo "**** /var/www/html/config/$cfgFile (versus the latest version for this image found at /usr/src/nextcloud/config/$cfgFile)"
fi
fi
done
echo "*** Details and instructions for resolving can be found at https://github.com/nextcloud/docker#auto-configuration-and-nextcloud-updates"
echo "*** In short, compare the contents of /usr/src/nextcloud/config/ with /var/www/html/config/."
fi
run_path before-starting
fi