From 21291a365f8cbff28d4a8d8c43c403f555a08162 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 14:37:17 -0500 Subject: [PATCH 01/37] Move Nextcloud installation inside container Signed-off-by: Eric Nemchik --- Dockerfile | 63 ++++++---- Dockerfile.aarch64 | 63 ++++++---- README.md | 17 +-- readme-vars.yml | 21 ++-- root/app/upgrade.exclude | 5 + .../nginx/site-confs/default.conf.sample | 4 +- root/etc/crontabs/root | 2 +- .../s6-rc.d/init-crontabs-config/run | 2 +- .../s6-rc.d/init-nextcloud-config/run | 108 +++++++++++++++--- root/migrations/02-default-location | 11 ++ root/usr/bin/occ | 2 +- root/usr/bin/updater.phar | 4 - 12 files changed, 203 insertions(+), 99 deletions(-) create mode 100644 root/app/upgrade.exclude create mode 100644 root/migrations/02-default-location delete mode 100755 root/usr/bin/updater.phar diff --git a/Dockerfile b/Dockerfile index 0fbc589..b3ff846 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,42 +45,55 @@ RUN \ php82-sqlite3 \ php82-sysvsem \ php82-xmlreader \ + rsync \ samba-client \ sudo && \ apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ php82-pecl-mcrypt && \ - echo "**** configure php and nginx for nextcloud ****" && \ - echo 'apc.enable_cli=1' >> /etc/php82/conf.d/apcu.ini && \ - sed -i \ - -e 's/;opcache.enable.*=.*/opcache.enable=1/g' \ - -e 's/;opcache.interned_strings_buffer.*=.*/opcache.interned_strings_buffer=16/g' \ - -e 's/;opcache.max_accelerated_files.*=.*/opcache.max_accelerated_files=10000/g' \ - -e 's/;opcache.memory_consumption.*=.*/opcache.memory_consumption=128/g' \ - -e 's/;opcache.save_comments.*=.*/opcache.save_comments=1/g' \ - -e 's/;opcache.revalidate_freq.*=.*/opcache.revalidate_freq=1/g' \ - -e 's/;always_populate_raw_post_data.*=.*/always_populate_raw_post_data=-1/g' \ - -e 's/memory_limit.*=.*128M/memory_limit=512M/g' \ - -e 's/max_execution_time.*=.*30/max_execution_time=120/g' \ - -e 's/upload_max_filesize.*=.*2M/upload_max_filesize=1024M/g' \ - -e 's/post_max_size.*=.*8M/post_max_size=1024M/g' \ - -e 's/output_buffering.*=.*/output_buffering=0/g' \ - /etc/php82/php.ini && \ - sed -i \ - '/opcache.enable=1/a opcache.enable_cli=1' \ - /etc/php82/php.ini && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php82/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php82/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php82/php-fpm.d/www.conf && \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php82/php-fpm.conf && \ - echo "**** set version tag ****" && \ + echo "**** configure php for nextcloud ****" && \ + { \ + echo 'apc.enable_cli=1' \ + } >> /etc/php82/conf.d/apcu.ini && \ + { \ + echo 'opcache.enable=1' \ + echo 'opcache.interned_strings_buffer=32' \ + echo 'opcache.max_accelerated_files=10000' \ + echo 'opcache.memory_consumption=128' \ + echo 'opcache.save_comments=1' \ + echo 'opcache.revalidate_freq=60' \ + echo 'opcache.jit=1255' \ + echo 'opcache.jit_buffer_size=128M' \ + } >> "/etc/php82/conf.d/00_opcache.ini" && \ + { \ + echo 'memory_limit=512M' \ + echo 'upload_max_filesize=16G' \ + echo 'post_max_size=16G' \ + echo 'max_input_time=3600' \ + echo 'max_execution_time=3600' \ + echo 'output_buffering=0' \ + echo 'always_populate_raw_post_data=-1' \ + } >> "/etc/php82/conf.d/nextcloud.ini" && \ + echo "**** install nextcloud ****" && \ + mkdir -p \ + /app/www/src/ && \ if [ -z ${NEXTCLOUD_RELEASE+x} ]; then \ NEXTCLOUD_RELEASE=$(curl -sX GET https://api.github.com/repos/nextcloud/server/releases \ | jq -r '.[] | select(.prerelease != true) | .tag_name' \ | sed 's|^v||g' | sort -rV | head -1); \ fi && \ - echo "**** download nextcloud ****" && \ - curl -o /app/nextcloud.tar.bz2 -L \ + curl -o \ + /tmp/nextcloud.tar.bz2 -L \ https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_RELEASE}.tar.bz2 && \ - echo "**** test tarball ****" && \ - tar xvf /app/nextcloud.tar.bz2 -C \ - /tmp && \ + tar xf /tmp/nextcloud.tar.bz2 -C \ + /app/www/src --strip-components=1 \ + rm -rf /app/www/src/updater; \ + mkdir -p /app/www/src/data; \ + mkdir -p /app/www/src/custom_apps; \ + chmod +x /app/www/src/occ; \ echo "**** cleanup ****" && \ rm -rf \ /tmp/* diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index db3ecbb..e461c54 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -45,42 +45,55 @@ RUN \ php82-sqlite3 \ php82-sysvsem \ php82-xmlreader \ + rsync \ samba-client \ sudo && \ apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing \ php82-pecl-mcrypt && \ - echo "**** configure php and nginx for nextcloud ****" && \ - echo 'apc.enable_cli=1' >> /etc/php82/conf.d/apcu.ini && \ - sed -i \ - -e 's/;opcache.enable.*=.*/opcache.enable=1/g' \ - -e 's/;opcache.interned_strings_buffer.*=.*/opcache.interned_strings_buffer=16/g' \ - -e 's/;opcache.max_accelerated_files.*=.*/opcache.max_accelerated_files=10000/g' \ - -e 's/;opcache.memory_consumption.*=.*/opcache.memory_consumption=128/g' \ - -e 's/;opcache.save_comments.*=.*/opcache.save_comments=1/g' \ - -e 's/;opcache.revalidate_freq.*=.*/opcache.revalidate_freq=1/g' \ - -e 's/;always_populate_raw_post_data.*=.*/always_populate_raw_post_data=-1/g' \ - -e 's/memory_limit.*=.*128M/memory_limit=512M/g' \ - -e 's/max_execution_time.*=.*30/max_execution_time=120/g' \ - -e 's/upload_max_filesize.*=.*2M/upload_max_filesize=1024M/g' \ - -e 's/post_max_size.*=.*8M/post_max_size=1024M/g' \ - -e 's/output_buffering.*=.*/output_buffering=0/g' \ - /etc/php82/php.ini && \ - sed -i \ - '/opcache.enable=1/a opcache.enable_cli=1' \ - /etc/php82/php.ini && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php82/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php82/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php82/php-fpm.d/www.conf && \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php82/php-fpm.conf && \ - echo "**** set version tag ****" && \ + echo "**** configure php for nextcloud ****" && \ + { \ + echo 'apc.enable_cli=1' \ + } >> /etc/php82/conf.d/apcu.ini && \ + { \ + echo 'opcache.enable=1' \ + echo 'opcache.interned_strings_buffer=32' \ + echo 'opcache.max_accelerated_files=10000' \ + echo 'opcache.memory_consumption=128' \ + echo 'opcache.save_comments=1' \ + echo 'opcache.revalidate_freq=60' \ + echo 'opcache.jit=1255' \ + echo 'opcache.jit_buffer_size=128M' \ + } >> "/etc/php82/conf.d/00_opcache.ini" && \ + { \ + echo 'memory_limit=512M' \ + echo 'upload_max_filesize=16G' \ + echo 'post_max_size=16G' \ + echo 'max_input_time=3600' \ + echo 'max_execution_time=3600' \ + echo 'output_buffering=0' \ + echo 'always_populate_raw_post_data=-1' \ + } >> "/etc/php82/conf.d/nextcloud.ini" && \ + echo "**** install nextcloud ****" && \ + mkdir -p \ + /app/www/src/ && \ if [ -z ${NEXTCLOUD_RELEASE+x} ]; then \ NEXTCLOUD_RELEASE=$(curl -sX GET https://api.github.com/repos/nextcloud/server/releases \ | jq -r '.[] | select(.prerelease != true) | .tag_name' \ | sed 's|^v||g' | sort -rV | head -1); \ fi && \ - echo "**** download nextcloud ****" && \ - curl -o /app/nextcloud.tar.bz2 -L \ + curl -o \ + /tmp/nextcloud.tar.bz2 -L \ https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_RELEASE}.tar.bz2 && \ - echo "**** test tarball ****" && \ - tar xvf /app/nextcloud.tar.bz2 -C \ - /tmp && \ + tar xf /tmp/nextcloud.tar.bz2 -C \ + /app/www/src --strip-components=1 \ + rm -rf /app/www/src/updater; \ + mkdir -p /app/www/src/data; \ + mkdir -p /app/www/src/custom_apps; \ + chmod +x /app/www/src/occ; \ echo "**** cleanup ****" && \ rm -rf \ /tmp/* diff --git a/README.md b/README.md index 4b5e915..d3d3db8 100644 --- a/README.md +++ b/README.md @@ -64,21 +64,13 @@ The architectures supported by this image are: Access the webui at `https://:443`, for more information check out [Nextcloud](https://nextcloud.com/). -Docker image update and recreation of container alone won't update nextcloud version. +### Updating Nextcloud -In order to update nextcloud version, you have two options, firstly make sure you are using the latest docker image,then either +Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one. -1. Perform the in app gui update. -2. Use the CLI version by running `docker exec -it nextcloud updater.phar` - (Both of these are described [here](https://docs.nextcloud.com/server/latest/admin_manual/maintenance/update.html)) +It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16. -Note: Both `occ` and `updater.phar` can be run without prepending with `sudo -u abc php` or `sudo -u www-data php` - -If you are not customizing our default nginx configuration you will need to remove the file: -``` -/config/nginx/site-confs/default.conf -``` -Then restart the container to replace it with the latest one. +Since all data is stored in the `/config` and `/data` volumes, nothing gets lost. The startup script will check for the version in your volume and the installed docker version. If it finds a mismatch, it automatically starts the upgrade process. ### Collaborative Editing @@ -254,6 +246,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **06.06.23:** - Move Nextcloud installation inside container. * **25.05.23:** - Rebase to Alpine 3.18, deprecate armhf. * **13.04.23:** - Move ssl.conf include to default.conf. * **21.03.23:** - Add php81-sysvsem as new dep for v26. Update default X-Robots-Tag to `noindex, nofollow``. diff --git a/readme-vars.yml b/readme-vars.yml index 68d10cb..a454c2a 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -51,22 +51,14 @@ app_setup_block_enabled: true app_setup_block: | Access the webui at `https://:443`, for more information check out [Nextcloud]({{ project_url }}). - Docker image update and recreation of container alone won't update nextcloud version. + ### Updating Nextcloud - In order to update nextcloud version, you have two options, firstly make sure you are using the latest docker image,then either + Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one. + + It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16. + + Since all data is stored in the `/config` and `/data` volumes, nothing gets lost. The startup script will check for the version in your volume and the installed docker version. If it finds a mismatch, it automatically starts the upgrade process. - 1. Perform the in app gui update. - 2. Use the CLI version by running `docker exec -it nextcloud updater.phar` - (Both of these are described [here](https://docs.nextcloud.com/server/latest/admin_manual/maintenance/update.html)) - - Note: Both `occ` and `updater.phar` can be run without prepending with `sudo -u abc php` or `sudo -u www-data php` - - If you are not customizing our default nginx configuration you will need to remove the file: - ``` - /config/nginx/site-confs/default.conf - ``` - Then restart the container to replace it with the latest one. - ### Collaborative Editing Nextcloud's built-in collaborative editing packages (Collabora/CODE and OnlyOffice) only work on x86_64 systems with glibc, and therefore they are not compatible with our images. You should create separate containers for them and set them up in Nextcloud with their respective connector addons. @@ -76,6 +68,7 @@ app_setup_block: | # changelog changelogs: + - { date: "06.06.23:", desc: "Move Nextcloud installation inside container." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." } - { date: "21.03.23:", desc: "Add php81-sysvsem as new dep for v26. Update default X-Robots-Tag to `noindex, nofollow``." } diff --git a/root/app/upgrade.exclude b/root/app/upgrade.exclude new file mode 100644 index 0000000..354864d --- /dev/null +++ b/root/app/upgrade.exclude @@ -0,0 +1,5 @@ +/config/ +/data/ +/custom_apps/ +/themes/ +/version.php diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample index 812b413..fcb937c 100644 --- a/root/defaults/nginx/site-confs/default.conf.sample +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -1,4 +1,4 @@ -## Version 2023/04/13 - Changelog: https://github.com/linuxserver/docker-nextcloud/commits/master/root/defaults/nginx/site-confs/default.conf.sample +## Version 2023/06/06 - Changelog: https://github.com/linuxserver/docker-nextcloud/commits/master/root/defaults/nginx/site-confs/default.conf.sample # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { @@ -17,7 +17,7 @@ server { include /config/nginx/ssl.conf; - root /config/www/nextcloud/; + root /app/www/public; # display real ip in nginx logs when connected through reverse proxy via docker network set_real_ip_from 172.0.0.0/8; diff --git a/root/etc/crontabs/root b/root/etc/crontabs/root index 85227e4..804eb03 100644 --- a/root/etc/crontabs/root +++ b/root/etc/crontabs/root @@ -6,4 +6,4 @@ 0 3 * * 6 run-parts /etc/periodic/weekly 0 5 1 * * run-parts /etc/periodic/monthly # nextcloud cron -*/5 * * * * s6-setuidgid abc php -f /config/www/nextcloud/cron.php +*/5 * * * * s6-setuidgid abc php -f /app/www/public/cron.php diff --git a/root/etc/s6-overlay/s6-rc.d/init-crontabs-config/run b/root/etc/s6-overlay/s6-rc.d/init-crontabs-config/run index da3a7b4..45f3844 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-crontabs-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-crontabs-config/run @@ -17,7 +17,7 @@ if [[ ! -f /config/crontabs/root ]]; then # copy crontab from included defaults (using -n, do not overwrite an existing file) cp -n /etc/crontabs/root /config/crontabs/ fi -sed -i "s|s6-setuidgid abc php[78] -f /config/www/nextcloud/cron.php|s6-setuidgid abc php -f /config/www/nextcloud/cron.php|" /config/crontabs/root +sed -i "s|s6-setuidgid abc php[0-9]* -f /config/www/nextcloud/cron.php|s6-setuidgid abc php -f /app/www/public/cron.php|" /config/crontabs/root # set permissions and import user crontabs lsiown root:root /config/crontabs/root crontab -u root /config/crontabs/root diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 546ea61..e48741f 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -3,26 +3,106 @@ # create folders mkdir -p \ - /config/www/nextcloud \ + /app/www/public \ + /config/www/nextcloud/config \ + /config/www/nextcloud/custom_apps \ + /config/www/nextcloud/themes \ /data +# migrate legacy install (copy inside container) +if [ -f /config/www/nextcloud/version.php ]; then + echo "Migrating legacy install" + rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ + for dir in config custom_apps themes; do + if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then + rsync -rlD --include "/${dir}/" --exclude '/*' /config/www/nextcloud/ /app/www/public/ + fi + done + rsync -rlD --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ + rm -f /config/www/nextcloud/version.php + touch /tmp/full_chown +fi + +# copy defaults +if [[ ! -f /app/www/public/config/config.php ]]; then + cp /defaults/config.php /app/www/public/config/config.php +fi +datadirectory=$(php -r "require '/app/www/public/version.php'; echo \$CONFIG['datadirectory'];") + +# symlink folders +for dir in config data custom_apps themes; do + if [ "${dir}" = "data" ]; then + if [ "$(readlink /app/www/public/${dir})" != "${datadirectory}" ]; then + rm -rf "/app/www/public/${dir}" + ln -s "${datadirectory}" "/app/www/public/${dir}" + fi + continue + fi + if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then + rm -rf "/app/www/public/${dir}" + ln -s "/config/www/nextcloud/${dir}" "/app/www/public/${dir}" + fi +done + # install app -if [ ! -e /config/www/nextcloud/index.php ]; then - tar xf /app/nextcloud.tar.bz2 -C \ - /config/www/nextcloud --strip-components=1 +vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } +vergt() { ! vergte "${2}" "${1}"; } +verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } +verlt() { ! verlte "${2}" "${1}"; } + +installed_version="0.0.0.0" +if [ -f /app/www/public/version.php ]; then + installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);") +fi +image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);") + +if vergt "${installed_version}" "${image_version}"; then + echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" + sleep infinity +fi + +if vergt "${image_version}" "${installed_version}"; then + echo "Initializing nextcloud ${image_version} ..." + if [ "${installed_version}" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from ${installed_version} ..." + occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before + fi + + rsync -rlD --delete --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ + for dir in config data custom_apps themes; do + if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then + rsync -rlD --include "/${dir}/" --exclude '/*' /app/www/src/ /app/www/public/ + fi + done + rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ + + touch /tmp/full_chown + + if [ "${installed_version}" = "0.0.0.0" ]; then + # Install + echo "New nextcloud instance" + echo "Please run the web-based installer on first connect!" + else + # Upgrade + occ upgrade + + occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + fi + + rm -f /tmp/list_before /tmp/list_after + echo "Initializing finished" +fi + +echo "Setting permissions" +if [ -f /tmp/full_chown ]; then lsiown abc:abc -R \ - /config/www/nextcloud - chmod +x /config/www/nextcloud/occ + /app/www/public + rm -f /tmp/full_chown fi - -# copy config -if [[ ! -f /config/www/nextcloud/config/config.php ]]; then - cp /defaults/config.php /config/www/nextcloud/config/config.php -fi - -# permissions lsiown abc:abc \ - /config/www/nextcloud/config/config.php \ + /app/www/public \ /data if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then diff --git a/root/migrations/02-default-location b/root/migrations/02-default-location new file mode 100644 index 0000000..a3727ec --- /dev/null +++ b/root/migrations/02-default-location @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +DEFAULT_CONF="/config/nginx/site-confs/default.conf" +OLD_ROOT="root /config/www/nextcloud/;" +NEW_ROOT="root /app/www/public;" + +if grep -q "${OLD_ROOT}" "${DEFAULT_CONF}"; then + echo "updating root in ${DEFAULT_CONF}" + sed -i "s|${OLD_ROOT}|${NEW_ROOT}|" "${DEFAULT_CONF}" +fi diff --git a/root/usr/bin/occ b/root/usr/bin/occ index d1370d8..a08d55e 100755 --- a/root/usr/bin/occ +++ b/root/usr/bin/occ @@ -1,4 +1,4 @@ #!/usr/bin/with-contenv bash # shellcheck shell=bash -sudo -u abc -s /bin/bash -c "php /config/www/nextcloud/occ $*" +sudo -u abc -s /bin/bash -c "php /app/www/public/occ $*" diff --git a/root/usr/bin/updater.phar b/root/usr/bin/updater.phar deleted file mode 100755 index 5839f5d..0000000 --- a/root/usr/bin/updater.phar +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bash -# shellcheck shell=bash - -sudo -u abc -s /bin/bash -c "php /config/www/nextcloud/updater/updater.phar $*" From 799bf398a525f0ca6406113a414519d2ddd8b0ad Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 14:42:07 -0500 Subject: [PATCH 02/37] Fix Dockerfile syntax Signed-off-by: Eric Nemchik --- Dockerfile | 42 +++++++++++++++++++++--------------------- Dockerfile.aarch64 | 42 +++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index b3ff846..7c16385 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,26 +56,26 @@ RUN \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php82/php-fpm.conf && \ echo "**** configure php for nextcloud ****" && \ { \ - echo 'apc.enable_cli=1' \ + echo 'apc.enable_cli=1'; \ } >> /etc/php82/conf.d/apcu.ini && \ { \ - echo 'opcache.enable=1' \ - echo 'opcache.interned_strings_buffer=32' \ - echo 'opcache.max_accelerated_files=10000' \ - echo 'opcache.memory_consumption=128' \ - echo 'opcache.save_comments=1' \ - echo 'opcache.revalidate_freq=60' \ - echo 'opcache.jit=1255' \ - echo 'opcache.jit_buffer_size=128M' \ + echo 'opcache.enable=1'; \ + echo 'opcache.interned_strings_buffer=32'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.jit=1255'; \ + echo 'opcache.jit_buffer_size=128M'; \ } >> "/etc/php82/conf.d/00_opcache.ini" && \ { \ - echo 'memory_limit=512M' \ - echo 'upload_max_filesize=16G' \ - echo 'post_max_size=16G' \ - echo 'max_input_time=3600' \ - echo 'max_execution_time=3600' \ - echo 'output_buffering=0' \ - echo 'always_populate_raw_post_data=-1' \ + echo 'memory_limit=512M'; \ + echo 'upload_max_filesize=16G'; \ + echo 'post_max_size=16G'; \ + echo 'max_input_time=3600'; \ + echo 'max_execution_time=3600'; \ + echo 'output_buffering=0'; \ + echo 'always_populate_raw_post_data=-1'; \ } >> "/etc/php82/conf.d/nextcloud.ini" && \ echo "**** install nextcloud ****" && \ mkdir -p \ @@ -89,11 +89,11 @@ RUN \ /tmp/nextcloud.tar.bz2 -L \ https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_RELEASE}.tar.bz2 && \ tar xf /tmp/nextcloud.tar.bz2 -C \ - /app/www/src --strip-components=1 \ - rm -rf /app/www/src/updater; \ - mkdir -p /app/www/src/data; \ - mkdir -p /app/www/src/custom_apps; \ - chmod +x /app/www/src/occ; \ + /app/www/src --strip-components=1 && \ + rm -rf /app/www/src/updater && \ + mkdir -p /app/www/src/data && \ + mkdir -p /app/www/src/custom_apps && \ + chmod +x /app/www/src/occ && \ echo "**** cleanup ****" && \ rm -rf \ /tmp/* diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index e461c54..da2e55a 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -56,26 +56,26 @@ RUN \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php82/php-fpm.conf && \ echo "**** configure php for nextcloud ****" && \ { \ - echo 'apc.enable_cli=1' \ + echo 'apc.enable_cli=1'; \ } >> /etc/php82/conf.d/apcu.ini && \ { \ - echo 'opcache.enable=1' \ - echo 'opcache.interned_strings_buffer=32' \ - echo 'opcache.max_accelerated_files=10000' \ - echo 'opcache.memory_consumption=128' \ - echo 'opcache.save_comments=1' \ - echo 'opcache.revalidate_freq=60' \ - echo 'opcache.jit=1255' \ - echo 'opcache.jit_buffer_size=128M' \ + echo 'opcache.enable=1'; \ + echo 'opcache.interned_strings_buffer=32'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.jit=1255'; \ + echo 'opcache.jit_buffer_size=128M'; \ } >> "/etc/php82/conf.d/00_opcache.ini" && \ { \ - echo 'memory_limit=512M' \ - echo 'upload_max_filesize=16G' \ - echo 'post_max_size=16G' \ - echo 'max_input_time=3600' \ - echo 'max_execution_time=3600' \ - echo 'output_buffering=0' \ - echo 'always_populate_raw_post_data=-1' \ + echo 'memory_limit=512M'; \ + echo 'upload_max_filesize=16G'; \ + echo 'post_max_size=16G'; \ + echo 'max_input_time=3600'; \ + echo 'max_execution_time=3600'; \ + echo 'output_buffering=0'; \ + echo 'always_populate_raw_post_data=-1'; \ } >> "/etc/php82/conf.d/nextcloud.ini" && \ echo "**** install nextcloud ****" && \ mkdir -p \ @@ -89,11 +89,11 @@ RUN \ /tmp/nextcloud.tar.bz2 -L \ https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_RELEASE}.tar.bz2 && \ tar xf /tmp/nextcloud.tar.bz2 -C \ - /app/www/src --strip-components=1 \ - rm -rf /app/www/src/updater; \ - mkdir -p /app/www/src/data; \ - mkdir -p /app/www/src/custom_apps; \ - chmod +x /app/www/src/occ; \ + /app/www/src --strip-components=1 && \ + rm -rf /app/www/src/updater && \ + mkdir -p /app/www/src/data && \ + mkdir -p /app/www/src/custom_apps && \ + chmod +x /app/www/src/occ && \ echo "**** cleanup ****" && \ rm -rf \ /tmp/* From 14bc5e1aa5b9736352630e4b6e59d79ba81b60b0 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 15:00:12 -0500 Subject: [PATCH 03/37] Migrate after creating symlinks Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index e48741f..df4ca28 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -3,26 +3,14 @@ # create folders mkdir -p \ - /app/www/public \ + /app/www/public/config \ + /app/www/public/custom_apps \ + /app/www/public/themes \ /config/www/nextcloud/config \ /config/www/nextcloud/custom_apps \ /config/www/nextcloud/themes \ /data -# migrate legacy install (copy inside container) -if [ -f /config/www/nextcloud/version.php ]; then - echo "Migrating legacy install" - rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ - for dir in config custom_apps themes; do - if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then - rsync -rlD --include "/${dir}/" --exclude '/*' /config/www/nextcloud/ /app/www/public/ - fi - done - rsync -rlD --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ - rm -f /config/www/nextcloud/version.php - touch /tmp/full_chown -fi - # copy defaults if [[ ! -f /app/www/public/config/config.php ]]; then cp /defaults/config.php /app/www/public/config/config.php @@ -44,6 +32,20 @@ for dir in config data custom_apps themes; do fi done +# migrate legacy install (copy inside container) +if [ -f /config/www/nextcloud/version.php ]; then + echo "Migrating legacy install" + rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ + for dir in config custom_apps themes; do + if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then + rsync -rlD --include "/${dir}/" --exclude '/*' /config/www/nextcloud/ /app/www/public/ + fi + done + rsync -rlD --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ + rm -f /config/www/nextcloud/version.php + touch /tmp/full_chown +fi + # install app vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } vergt() { ! vergte "${2}" "${1}"; } From 4646cd7d459d46108e9da353853050b993ccf250 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 15:42:21 -0500 Subject: [PATCH 04/37] Reorder init logic again Migrate before symlink Don't copy persistent data into container Fix datadirectory file Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 43 ++++++++----------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index df4ca28..826c06c 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -11,41 +11,32 @@ mkdir -p \ /config/www/nextcloud/themes \ /data +# migrate legacy install (copy inside container) +if [ -f /config/www/nextcloud/version.php ]; then + echo "Migrating legacy install" + rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ + rsync -rlD --delete --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ + touch /tmp/full_chown +fi + # copy defaults if [[ ! -f /app/www/public/config/config.php ]]; then cp /defaults/config.php /app/www/public/config/config.php fi -datadirectory=$(php -r "require '/app/www/public/version.php'; echo \$CONFIG['datadirectory'];") +datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];") # symlink folders -for dir in config data custom_apps themes; do - if [ "${dir}" = "data" ]; then - if [ "$(readlink /app/www/public/${dir})" != "${datadirectory}" ]; then - rm -rf "/app/www/public/${dir}" - ln -s "${datadirectory}" "/app/www/public/${dir}" - fi - continue - fi +if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then + rm -rf /app/www/public/data + ln -s "${datadirectory}" /app/www/public/data +fi +for dir in config custom_apps themes; do if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then rm -rf "/app/www/public/${dir}" ln -s "/config/www/nextcloud/${dir}" "/app/www/public/${dir}" fi done -# migrate legacy install (copy inside container) -if [ -f /config/www/nextcloud/version.php ]; then - echo "Migrating legacy install" - rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ - for dir in config custom_apps themes; do - if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then - rsync -rlD --include "/${dir}/" --exclude '/*' /config/www/nextcloud/ /app/www/public/ - fi - done - rsync -rlD --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ - rm -f /config/www/nextcloud/version.php - touch /tmp/full_chown -fi - # install app vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } vergt() { ! vergte "${2}" "${1}"; } @@ -54,9 +45,9 @@ verlt() { ! verlte "${2}" "${1}"; } installed_version="0.0.0.0" if [ -f /app/www/public/version.php ]; then - installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);") + installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) fi -image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);") +image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) if vergt "${installed_version}" "${image_version}"; then echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" @@ -72,7 +63,7 @@ if vergt "${image_version}" "${installed_version}"; then rsync -rlD --delete --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ for dir in config data custom_apps themes; do - if [ -z "$(ls -A /app/www/public/${dir}/)" ]; then + if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then rsync -rlD --include "/${dir}/" --exclude '/*' /app/www/src/ /app/www/public/ fi done From 2924be908116b0a124df3caa04a5f5e0becab9d2 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 18:22:21 -0500 Subject: [PATCH 05/37] Cleanup migrated files Signed-off-by: Eric Nemchik --- .../s6-overlay/s6-rc.d/init-nextcloud-config/run | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 826c06c..64cac34 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -14,8 +14,17 @@ mkdir -p \ # migrate legacy install (copy inside container) if [ -f /config/www/nextcloud/version.php ]; then echo "Migrating legacy install" - rsync -rlD --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ - rsync -rlD --delete --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ + rsync -rlD --remove-source-files --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ + rsync -rlD --remove-source-files --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ + rm -rf /config/www/nextcloud/updater/ + find \ + /config/www/nextcloud/ \ + -type d -empty \ + ! -path "/config/www/nextcloud/config" \ + ! -path "/config/www/nextcloud/custom_apps" \ + ! -path "/config/www/nextcloud/themes" \ + -delete + touch /tmp/full_chown fi From 7cc124486a47a4ba1eb7f75743cdef111152d020 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 18:45:12 -0500 Subject: [PATCH 06/37] Rearrange init order again Symlink user folders before reading datadirectory Symlink datadirectory separately Signed-off-by: Eric Nemchik --- readme-vars.yml | 2 +- .../s6-rc.d/init-nextcloud-config/run | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index a454c2a..8465926 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -68,7 +68,7 @@ app_setup_block: | # changelog changelogs: - - { date: "06.06.23:", desc: "Move Nextcloud installation inside container." } + - { date: "06.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." } - { date: "21.03.23:", desc: "Add php81-sysvsem as new dep for v26. Update default X-Robots-Tag to `noindex, nofollow``." } diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 64cac34..8c16cd2 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -24,21 +24,10 @@ if [ -f /config/www/nextcloud/version.php ]; then ! -path "/config/www/nextcloud/custom_apps" \ ! -path "/config/www/nextcloud/themes" \ -delete - touch /tmp/full_chown fi -# copy defaults -if [[ ! -f /app/www/public/config/config.php ]]; then - cp /defaults/config.php /app/www/public/config/config.php -fi -datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];") - -# symlink folders -if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then - rm -rf /app/www/public/data - ln -s "${datadirectory}" /app/www/public/data -fi +# symlink config folders for dir in config custom_apps themes; do if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then rm -rf "/app/www/public/${dir}" @@ -46,6 +35,16 @@ for dir in config custom_apps themes; do fi done +# copy defaults +cp -n /defaults/config.php /app/www/public/config/config.php 2> >(grep -v 'cp: not replacing') +datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];" 2>/dev/null) + +# symlink data folder +if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then + rm -rf /app/www/public/data + ln -s "${datadirectory}" /app/www/public/data +fi + # install app vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } vergt() { ! vergte "${2}" "${1}"; } From d1ddb603b04e77458cfc380aff81af54c29608f0 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 19:07:55 -0500 Subject: [PATCH 07/37] Don't delete extra files with rsync Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 8c16cd2..a670a35 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -14,7 +14,7 @@ mkdir -p \ # migrate legacy install (copy inside container) if [ -f /config/www/nextcloud/version.php ]; then echo "Migrating legacy install" - rsync -rlD --remove-source-files --delete --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ + rsync -rlD --remove-source-files --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ rsync -rlD --remove-source-files --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ rm -rf /config/www/nextcloud/updater/ find \ @@ -69,7 +69,7 @@ if vergt "${image_version}" "${installed_version}"; then occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before fi - rsync -rlD --delete --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ + rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ for dir in config data custom_apps themes; do if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then rsync -rlD --include "/${dir}/" --exclude '/*' /app/www/src/ /app/www/public/ From 91f7977effbfd5a0740856c985879b093933c36f Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 23:00:47 -0500 Subject: [PATCH 08/37] setup config Signed-off-by: Eric Nemchik --- root/defaults/config.php | 20 +++++++++++++++---- .../s6-rc.d/init-nextcloud-config/run | 16 +++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/root/defaults/config.php b/root/defaults/config.php index 7a17b70..db32f41 100644 --- a/root/defaults/config.php +++ b/root/defaults/config.php @@ -1,6 +1,18 @@ '\OC\Memcache\APCu', +$CONFIG = [ + 'memcache.local' => '\\OC\\Memcache\\APCu', + 'memcache.distributed' => '\\OC\\Memcache\\Memcached', 'datadirectory' => '/data', - ); - + 'apps_paths' => [ + 0 => [ + 'path' => '/app/www/public/apps', + 'url' => '/apps', + 'writable' => false, + ], + 1 => [ + 'path' => '/app/www/public/custom_apps', + 'url' => '/custom_apps', + 'writable' => true, + ], + ], +]; diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index a670a35..d478afc 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -35,9 +35,21 @@ for dir in config custom_apps themes; do fi done -# copy defaults +# setup config cp -n /defaults/config.php /app/www/public/config/config.php 2> >(grep -v 'cp: not replacing') -datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];" 2>/dev/null) +if ! occ config:system:get memcache.local; then + occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' +fi +if ! occ config:system:get memcache.distributed; then + occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' +fi +if ! occ config:system:get datadirectory; then + occ config:system:set datadirectory --value='/data' +fi +if ! occ config:system:get apps_paths || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then + occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') +fi +datadirectory=$(occ config:system:get datadirectory) # symlink data folder if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then From 57c6197dbedd26035d601efda903f7852f3dc697 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 23:26:11 -0500 Subject: [PATCH 09/37] Run occ after install Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index d478afc..9bdabb9 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -35,21 +35,9 @@ for dir in config custom_apps themes; do fi done -# setup config +# copy defaults cp -n /defaults/config.php /app/www/public/config/config.php 2> >(grep -v 'cp: not replacing') -if ! occ config:system:get memcache.local; then - occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' -fi -if ! occ config:system:get memcache.distributed; then - occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' -fi -if ! occ config:system:get datadirectory; then - occ config:system:set datadirectory --value='/data' -fi -if ! occ config:system:get apps_paths || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then - occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') -fi -datadirectory=$(occ config:system:get datadirectory) +datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];" 2>/dev/null) # symlink data folder if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then @@ -118,6 +106,20 @@ lsiown abc:abc \ /app/www/public \ /data +# setup config +if ! occ config:system:get memcache.local; then + occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' +fi +if ! occ config:system:get memcache.distributed; then + occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' +fi +if ! occ config:system:get datadirectory; then + occ config:system:set datadirectory --value='/data' +fi +if ! occ config:system:get apps_paths || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then + occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') +fi + if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then echo "Removing CODE Server" APP=$(occ app:list --no-interaction | grep richdocumentscode | awk -F ' ' '{print $2}' | tr -d ':') From beac2d82ef73da94abaf0769d1561903bb01c4bc Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Tue, 6 Jun 2023 23:44:28 -0500 Subject: [PATCH 10/37] Redirect output Doesn't need to be in container log Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 9bdabb9..de81a7b 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -96,8 +96,8 @@ if vergt "${image_version}" "${installed_version}"; then echo "Initializing finished" fi -echo "Setting permissions" if [ -f /tmp/full_chown ]; then + echo "Setting permissions" lsiown abc:abc -R \ /app/www/public rm -f /tmp/full_chown @@ -107,16 +107,16 @@ lsiown abc:abc \ /data # setup config -if ! occ config:system:get memcache.local; then +if ! occ config:system:get memcache.local >/dev/null 2>&1; then occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' fi -if ! occ config:system:get memcache.distributed; then +if ! occ config:system:get memcache.distributed >/dev/null 2>&1; then occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' fi -if ! occ config:system:get datadirectory; then +if ! occ config:system:get datadirectory >/dev/null 2>&1; then occ config:system:set datadirectory --value='/data' fi -if ! occ config:system:get apps_paths || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then +if ! occ config:system:get apps_paths >/dev/null 2>&1 || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') fi From bddeebb9538d6dc3c6821807be1b6cfa15496ca9 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 00:18:14 -0500 Subject: [PATCH 11/37] Fix symlink breaking Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index de81a7b..21f9a4c 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -72,7 +72,7 @@ if vergt "${image_version}" "${installed_version}"; then rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ for dir in config data custom_apps themes; do if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then - rsync -rlD --include "/${dir}/" --exclude '/*' /app/www/src/ /app/www/public/ + rsync -rlD --include "/${dir}/*" --exclude '/*' /app/www/src/ /app/www/public/ fi done rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ From e1f23358256f1193ea3d5be6a097dc5b6ef255cb Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 00:26:58 -0500 Subject: [PATCH 12/37] Additional permission fixes Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 21f9a4c..917fc6d 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -99,11 +99,20 @@ fi if [ -f /tmp/full_chown ]; then echo "Setting permissions" lsiown abc:abc -R \ - /app/www/public + /app/www/public \ + /config/www/nextcloud rm -f /tmp/full_chown fi lsiown abc:abc \ /app/www/public \ + /app/www/public/config \ + /app/www/public/custom_apps \ + /app/www/public/data \ + /app/www/public/themes \ + /config/www/nextcloud \ + /config/www/nextcloud/config \ + /config/www/nextcloud/custom_apps \ + /config/www/nextcloud/themes \ /data # setup config From 53f51776870d7a6ff0f2c1a641a39996ca686b94 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 00:39:33 -0500 Subject: [PATCH 13/37] Only run occ config if installed Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 917fc6d..2785d6a 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -116,17 +116,19 @@ lsiown abc:abc \ /data # setup config -if ! occ config:system:get memcache.local >/dev/null 2>&1; then - occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' -fi -if ! occ config:system:get memcache.distributed >/dev/null 2>&1; then - occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' -fi -if ! occ config:system:get datadirectory >/dev/null 2>&1; then - occ config:system:set datadirectory --value='/data' -fi -if ! occ config:system:get apps_paths >/dev/null 2>&1 || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then - occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') +if occ config:system:get installed >/dev/null 2>&1; then + if ! occ config:system:get memcache.local >/dev/null 2>&1; then + occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' + fi + if ! occ config:system:get memcache.distributed >/dev/null 2>&1; then + occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' + fi + if ! occ config:system:get datadirectory >/dev/null 2>&1; then + occ config:system:set datadirectory --value='/data' + fi + if ! occ config:system:get apps_paths >/dev/null 2>&1 || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then + occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') + fi fi if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then From 95a5440b6469cb02ca61c4870204d4fd161f3cf8 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 01:00:34 -0500 Subject: [PATCH 14/37] Fix config format Signed-off-by: Eric Nemchik --- root/defaults/config.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/root/defaults/config.php b/root/defaults/config.php index db32f41..45ed83c 100644 --- a/root/defaults/config.php +++ b/root/defaults/config.php @@ -1,18 +1,21 @@ '\\OC\\Memcache\\APCu', 'memcache.distributed' => '\\OC\\Memcache\\Memcached', 'datadirectory' => '/data', - 'apps_paths' => [ - 0 => [ + 'apps_paths' => + array ( + 0 => + array ( 'path' => '/app/www/public/apps', 'url' => '/apps', 'writable' => false, - ], - 1 => [ + ), + 1 => + array ( 'path' => '/app/www/public/custom_apps', 'url' => '/custom_apps', 'writable' => true, - ], - ], -]; + ), + ), +); From f5ea4e4b4e11e8b8e3599ff0e8cf7b1104875024 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 09:24:28 -0500 Subject: [PATCH 15/37] Account for persistent config version Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 66 ++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 2785d6a..a434c40 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -24,7 +24,7 @@ if [ -f /config/www/nextcloud/version.php ]; then ! -path "/config/www/nextcloud/custom_apps" \ ! -path "/config/www/nextcloud/themes" \ -delete - touch /tmp/full_chown + touch /tmp/migration fi # symlink config folders @@ -45,27 +45,48 @@ if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then ln -s "${datadirectory}" /app/www/public/data fi -# install app +# initialize version variables +installed_version="0.0.0.0" +config_version="0.0.0.0" + +# get versions +image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) +if [ -f /app/www/public/version.php ]; then + installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) +fi +if occ config:system:get installed >/dev/null 2>&1 && + occ config:system:get version >/dev/null 2>&1; then + config_version=$(occ config:system:get version 2>/dev/null) +fi + +# compare versions vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } vergt() { ! vergte "${2}" "${1}"; } verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } verlt() { ! verlte "${2}" "${1}"; } -installed_version="0.0.0.0" -if [ -f /app/www/public/version.php ]; then - installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) -fi -image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) - -if vergt "${installed_version}" "${image_version}"; then - echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" +if vergt "${installed_version}" "${image_version}" || + vergt "${config_version}" "${image_version}"; then + echo "Can't start Nextcloud because the version of the data (install: ${installed_version} or config: ${config_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" sleep infinity fi +if [ "${installed_version}" != "0.0.0.0" ] && + [ "${config_version}" != "0.0.0.0" ] && + [ "${installed_version}" != "${config_version}" ]; then + echo "Version mismatch between config and install. Forcing upgrade to ${image_version} ..." + touch /tmp/version_mismatch -if vergt "${image_version}" "${installed_version}"; then +fi + +# initialize nextcloud +if vergt "${image_version}" "${installed_version}" || + vergt "${image_version}" "${config_version}" || + [ -f /tmp/migration ] || + [ -f /tmp/version_mismatch ]; then echo "Initializing nextcloud ${image_version} ..." - if [ "${installed_version}" != "0.0.0.0" ]; then - echo "Upgrading nextcloud from ${installed_version} ..." + if [ "${installed_version}" != "0.0.0.0" ] || + [ "${config_version}" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from install: ${installed_version} or config: ${config_version} ..." occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before fi @@ -77,9 +98,13 @@ if vergt "${image_version}" "${installed_version}"; then done rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ - touch /tmp/full_chown + echo "Setting permissions" + lsiown abc:abc -R \ + /app/www/public \ + /config/www/nextcloud - if [ "${installed_version}" = "0.0.0.0" ]; then + if [ "${installed_version}" = "0.0.0.0" ] && + [ "${config_version}" = "0.0.0.0" ]; then # Install echo "New nextcloud instance" echo "Please run the web-based installer on first connect!" @@ -96,13 +121,10 @@ if vergt "${image_version}" "${installed_version}"; then echo "Initializing finished" fi -if [ -f /tmp/full_chown ]; then - echo "Setting permissions" - lsiown abc:abc -R \ - /app/www/public \ - /config/www/nextcloud - rm -f /tmp/full_chown -fi +rm -f \ + /tmp/migration \ + /tmp/version_mismatch + lsiown abc:abc \ /app/www/public \ /app/www/public/config \ From b914cfdf0b4eb1c67f493eb82115dde85657acd6 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 09:53:52 -0500 Subject: [PATCH 16/37] Don't copy defaults The install and symlink handles this Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index a434c40..7c5bbeb 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -35,14 +35,10 @@ for dir in config custom_apps themes; do fi done -# copy defaults -cp -n /defaults/config.php /app/www/public/config/config.php 2> >(grep -v 'cp: not replacing') -datadirectory=$(php -r "require '/app/www/public/config/config.php'; echo \$CONFIG['datadirectory'];" 2>/dev/null) - # symlink data folder -if [ "$(readlink /app/www/public/data)" != "${datadirectory}" ]; then +if [ "$(readlink /app/www/public/data)" != "/data" ]; then rm -rf /app/www/public/data - ln -s "${datadirectory}" /app/www/public/data + ln -s /data /app/www/public/data fi # initialize version variables From 50300ca0855485194d2dd52c030a44512d5881c2 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 10:41:36 -0500 Subject: [PATCH 17/37] Don't consider version installed inside Only consider version on persistent config Signed-off-by: Eric Nemchik --- .../s6-rc.d/init-nextcloud-config/run | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 7c5bbeb..372e36c 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -43,16 +43,11 @@ fi # initialize version variables installed_version="0.0.0.0" -config_version="0.0.0.0" # get versions image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) -if [ -f /app/www/public/version.php ]; then - installed_version=$(php -r "require '/app/www/public/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) -fi -if occ config:system:get installed >/dev/null 2>&1 && - occ config:system:get version >/dev/null 2>&1; then - config_version=$(occ config:system:get version 2>/dev/null) +if occ config:system:get installed >/dev/null 2>&1 && occ config:system:get version >/dev/null 2>&1; then + installed_version=$(occ config:system:get version 2>/dev/null) fi # compare versions @@ -61,28 +56,16 @@ vergt() { ! vergte "${2}" "${1}"; } verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } verlt() { ! verlte "${2}" "${1}"; } -if vergt "${installed_version}" "${image_version}" || - vergt "${config_version}" "${image_version}"; then - echo "Can't start Nextcloud because the version of the data (install: ${installed_version} or config: ${config_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" +if vergt "${installed_version}" "${image_version}"; then + echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" sleep infinity fi -if [ "${installed_version}" != "0.0.0.0" ] && - [ "${config_version}" != "0.0.0.0" ] && - [ "${installed_version}" != "${config_version}" ]; then - echo "Version mismatch between config and install. Forcing upgrade to ${image_version} ..." - touch /tmp/version_mismatch - -fi # initialize nextcloud -if vergt "${image_version}" "${installed_version}" || - vergt "${image_version}" "${config_version}" || - [ -f /tmp/migration ] || - [ -f /tmp/version_mismatch ]; then +if vergt "${image_version}" "${installed_version}" || [ -f /tmp/migration ]; then echo "Initializing nextcloud ${image_version} ..." - if [ "${installed_version}" != "0.0.0.0" ] || - [ "${config_version}" != "0.0.0.0" ]; then - echo "Upgrading nextcloud from install: ${installed_version} or config: ${config_version} ..." + if [ "${installed_version}" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from ${installed_version} ..." occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before fi @@ -99,8 +82,7 @@ if vergt "${image_version}" "${installed_version}" || /app/www/public \ /config/www/nextcloud - if [ "${installed_version}" = "0.0.0.0" ] && - [ "${config_version}" = "0.0.0.0" ]; then + if [ "${installed_version}" = "0.0.0.0" ]; then # Install echo "New nextcloud instance" echo "Please run the web-based installer on first connect!" @@ -117,9 +99,7 @@ if vergt "${image_version}" "${installed_version}" || echo "Initializing finished" fi -rm -f \ - /tmp/migration \ - /tmp/version_mismatch +rm -f /tmp/migration lsiown abc:abc \ /app/www/public \ From 04e3db14fde58855c42951385cc742be84f9d3c6 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 10:47:51 -0500 Subject: [PATCH 18/37] Symlink apps rather than using custom_apps Signed-off-by: Eric Nemchik --- Dockerfile | 1 - Dockerfile.aarch64 | 1 - root/app/upgrade.exclude | 1 - root/defaults/config.php | 21 ------------------- .../s6-rc.d/init-nextcloud-config/run | 20 +++++++----------- 5 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 root/defaults/config.php diff --git a/Dockerfile b/Dockerfile index 7c16385..afded74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,7 +92,6 @@ RUN \ /app/www/src --strip-components=1 && \ rm -rf /app/www/src/updater && \ mkdir -p /app/www/src/data && \ - mkdir -p /app/www/src/custom_apps && \ chmod +x /app/www/src/occ && \ echo "**** cleanup ****" && \ rm -rf \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index da2e55a..9ba79c1 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -92,7 +92,6 @@ RUN \ /app/www/src --strip-components=1 && \ rm -rf /app/www/src/updater && \ mkdir -p /app/www/src/data && \ - mkdir -p /app/www/src/custom_apps && \ chmod +x /app/www/src/occ && \ echo "**** cleanup ****" && \ rm -rf \ diff --git a/root/app/upgrade.exclude b/root/app/upgrade.exclude index 354864d..b5d2e1d 100644 --- a/root/app/upgrade.exclude +++ b/root/app/upgrade.exclude @@ -1,5 +1,4 @@ /config/ /data/ -/custom_apps/ /themes/ /version.php diff --git a/root/defaults/config.php b/root/defaults/config.php deleted file mode 100644 index 45ed83c..0000000 --- a/root/defaults/config.php +++ /dev/null @@ -1,21 +0,0 @@ - '\\OC\\Memcache\\APCu', - 'memcache.distributed' => '\\OC\\Memcache\\Memcached', - 'datadirectory' => '/data', - 'apps_paths' => - array ( - 0 => - array ( - 'path' => '/app/www/public/apps', - 'url' => '/apps', - 'writable' => false, - ), - 1 => - array ( - 'path' => '/app/www/public/custom_apps', - 'url' => '/custom_apps', - 'writable' => true, - ), - ), -); diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 372e36c..ce9097b 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -3,11 +3,11 @@ # create folders mkdir -p \ + /app/www/public/apps \ /app/www/public/config \ - /app/www/public/custom_apps \ /app/www/public/themes \ + /config/www/nextcloud/apps \ /config/www/nextcloud/config \ - /config/www/nextcloud/custom_apps \ /config/www/nextcloud/themes \ /data @@ -20,15 +20,15 @@ if [ -f /config/www/nextcloud/version.php ]; then find \ /config/www/nextcloud/ \ -type d -empty \ + ! -path "/config/www/nextcloud/apps" \ ! -path "/config/www/nextcloud/config" \ - ! -path "/config/www/nextcloud/custom_apps" \ ! -path "/config/www/nextcloud/themes" \ -delete touch /tmp/migration fi # symlink config folders -for dir in config custom_apps themes; do +for dir in apps config themes; do if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then rm -rf "/app/www/public/${dir}" ln -s "/config/www/nextcloud/${dir}" "/app/www/public/${dir}" @@ -70,7 +70,7 @@ if vergt "${image_version}" "${installed_version}" || [ -f /tmp/migration ]; the fi rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ - for dir in config data custom_apps themes; do + for dir in apps config data themes; do if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then rsync -rlD --include "/${dir}/*" --exclude '/*' /app/www/src/ /app/www/public/ fi @@ -103,13 +103,13 @@ rm -f /tmp/migration lsiown abc:abc \ /app/www/public \ + /app/www/public/apps \ /app/www/public/config \ - /app/www/public/custom_apps \ /app/www/public/data \ /app/www/public/themes \ /config/www/nextcloud \ + /config/www/nextcloud/apps \ /config/www/nextcloud/config \ - /config/www/nextcloud/custom_apps \ /config/www/nextcloud/themes \ /data @@ -121,12 +121,6 @@ if occ config:system:get installed >/dev/null 2>&1; then if ! occ config:system:get memcache.distributed >/dev/null 2>&1; then occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' fi - if ! occ config:system:get datadirectory >/dev/null 2>&1; then - occ config:system:set datadirectory --value='/data' - fi - if ! occ config:system:get apps_paths >/dev/null 2>&1 || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/apps' || ! occ config:system:get apps_paths | grep -q 'path: /app/www/public/custom_apps'; then - occ config:import < <(echo '{"system":{"apps_paths":[{"path":"\/app\/www\/public\/apps","url":"\/apps","writable":false},{"path":"\/app\/www\/public\/custom_apps","url":"\/custom_apps","writable":true}]}}') - fi fi if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then From 0bccfaed5d0b9caa1be7c380c3b5369edc6eb5d0 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 10:49:29 -0500 Subject: [PATCH 19/37] Include apps in upgrade exclusion Only excluded if not empty Signed-off-by: Eric Nemchik --- root/app/upgrade.exclude | 1 + 1 file changed, 1 insertion(+) diff --git a/root/app/upgrade.exclude b/root/app/upgrade.exclude index b5d2e1d..3de610a 100644 --- a/root/app/upgrade.exclude +++ b/root/app/upgrade.exclude @@ -1,3 +1,4 @@ +/apps/ /config/ /data/ /themes/ From a87e7408b0767c152e6cd09f7cad2faae35d0406 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 11:05:37 -0500 Subject: [PATCH 20/37] Refactor chown Signed-off-by: Eric Nemchik --- .../s6-overlay/s6-rc.d/init-nextcloud-config/run | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index ce9097b..1f33b3e 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -32,6 +32,7 @@ for dir in apps config themes; do if [ "$(readlink /app/www/public/${dir})" != "/config/www/nextcloud/${dir}" ]; then rm -rf "/app/www/public/${dir}" ln -s "/config/www/nextcloud/${dir}" "/app/www/public/${dir}" + lsiown abc:abc "/config/www/nextcloud/${dir}" "/app/www/public/${dir}" fi done @@ -39,6 +40,7 @@ done if [ "$(readlink /app/www/public/data)" != "/data" ]; then rm -rf /app/www/public/data ln -s /data /app/www/public/data + lsiown abc:abc /data /app/www/public/data fi # initialize version variables @@ -101,17 +103,10 @@ fi rm -f /tmp/migration +# permissions lsiown abc:abc \ /app/www/public \ - /app/www/public/apps \ - /app/www/public/config \ - /app/www/public/data \ - /app/www/public/themes \ - /config/www/nextcloud \ - /config/www/nextcloud/apps \ - /config/www/nextcloud/config \ - /config/www/nextcloud/themes \ - /data + /config/www/nextcloud # setup config if occ config:system:get installed >/dev/null 2>&1; then From 1aa1f053bf8015815574ed7337a1e285610eb395 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 11:06:21 -0500 Subject: [PATCH 21/37] rsync persistent data to config Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 1f33b3e..0d4f4d5 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -74,7 +74,7 @@ if vergt "${image_version}" "${installed_version}" || [ -f /tmp/migration ]; the rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ for dir in apps config data themes; do if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then - rsync -rlD --include "/${dir}/*" --exclude '/*' /app/www/src/ /app/www/public/ + rsync -rlD --include "/${dir}" --exclude '/*' /app/www/src/ /config/www/nextcloud/ fi done rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ From 99c22a96460550d530d63c59f8044e2ffa8514cd Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 7 Jun 2023 11:13:42 -0500 Subject: [PATCH 22/37] Data is separate Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 0d4f4d5..0b58261 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -72,11 +72,14 @@ if vergt "${image_version}" "${installed_version}" || [ -f /tmp/migration ]; the fi rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ - for dir in apps config data themes; do + for dir in apps config themes; do if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then rsync -rlD --include "/${dir}" --exclude '/*' /app/www/src/ /config/www/nextcloud/ fi done + if [ -z "$(ls -A /app/www/public/data/ 2>/dev/null)" ]; then + rsync -rlD --include "/data" --exclude '/*' /app/www/src/ / + fi rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ echo "Setting permissions" From e0b9378984450eacfb3bf30c87f76ec3faff0465 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 13:57:04 -0500 Subject: [PATCH 23/37] Remove incomplete memcached config Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 3 --- 1 file changed, 3 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 0b58261..ba9bc99 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -116,9 +116,6 @@ if occ config:system:get installed >/dev/null 2>&1; then if ! occ config:system:get memcache.local >/dev/null 2>&1; then occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' fi - if ! occ config:system:get memcache.distributed >/dev/null 2>&1; then - occ config:system:set memcache.distributed --value='\\OC\\Memcache\\Memcached' - fi fi if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then From 1859718b5b3879a882f0bfc0de9d081297915a6f Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 14:01:49 -0500 Subject: [PATCH 24/37] Replace crontab during migration Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 1 + 1 file changed, 1 insertion(+) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index ba9bc99..abc2deb 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -24,6 +24,7 @@ if [ -f /config/www/nextcloud/version.php ]; then ! -path "/config/www/nextcloud/config" \ ! -path "/config/www/nextcloud/themes" \ -delete + sed -i "s|/config/www/nextcloud/|/app/www/public/|g" /config/crontabs/root touch /tmp/migration fi From 4eb5de15be5f452baf8ac1ead314e544e76be18c Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 14:03:46 -0500 Subject: [PATCH 25/37] Use full file path for cron replacement Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index abc2deb..62aea23 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -24,7 +24,7 @@ if [ -f /config/www/nextcloud/version.php ]; then ! -path "/config/www/nextcloud/config" \ ! -path "/config/www/nextcloud/themes" \ -delete - sed -i "s|/config/www/nextcloud/|/app/www/public/|g" /config/crontabs/root + sed -i "s|/config/www/nextcloud/cron.php|/app/www/public/cron.php|g" /config/crontabs/root touch /tmp/migration fi From 8e814fad1aed7b87063de004c56008bc6ba36838 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 14:33:58 -0500 Subject: [PATCH 26/37] Rework installed version check (again) Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 62aea23..6eb5f5f 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -44,13 +44,11 @@ if [ "$(readlink /app/www/public/data)" != "/data" ]; then lsiown abc:abc /data /app/www/public/data fi -# initialize version variables -installed_version="0.0.0.0" - # get versions image_version=$(php -r "require '/app/www/src/version.php'; echo implode('.', \$OC_Version);" 2>/dev/null) -if occ config:system:get installed >/dev/null 2>&1 && occ config:system:get version >/dev/null 2>&1; then - installed_version=$(occ config:system:get version 2>/dev/null) +installed_version=$(php -r "require '/config/www/nextcloud/config/config.php'; echo \$CONFIG['version'];" 2>/dev/null) +if [ "${installed_version}" = "" ]; then + installed_version="0.0.0.0" fi # compare versions From 19ffc43845e9573bcc0984152812dc13493ccead Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 15:01:05 -0500 Subject: [PATCH 27/37] Account for missing install Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 6eb5f5f..ba2664e 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -63,7 +63,7 @@ if vergt "${installed_version}" "${image_version}"; then fi # initialize nextcloud -if vergt "${image_version}" "${installed_version}" || [ -f /tmp/migration ]; then +if vergt "${image_version}" "${installed_version}" || [ -z "$(ls -A /app/www/public/core/ 2>/dev/null)" ] || [ -f /tmp/migration ]; then echo "Initializing nextcloud ${image_version} ..." if [ "${installed_version}" != "0.0.0.0" ]; then echo "Upgrading nextcloud from ${installed_version} ..." From f45714f6a04810e13068786d1b36c456bd5742d5 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 15:57:13 -0500 Subject: [PATCH 28/37] Add output about taking a long time Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index ba2664e..b9153f9 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -13,7 +13,7 @@ mkdir -p \ # migrate legacy install (copy inside container) if [ -f /config/www/nextcloud/version.php ]; then - echo "Migrating legacy install" + echo "Migrating legacy install (this can take a while) ...)" rsync -rlD --remove-source-files --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ rsync -rlD --remove-source-files --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ rm -rf /config/www/nextcloud/updater/ @@ -64,7 +64,7 @@ fi # initialize nextcloud if vergt "${image_version}" "${installed_version}" || [ -z "$(ls -A /app/www/public/core/ 2>/dev/null)" ] || [ -f /tmp/migration ]; then - echo "Initializing nextcloud ${image_version} ..." + echo "Initializing nextcloud ${image_version} (this can take a while) ..." if [ "${installed_version}" != "0.0.0.0" ]; then echo "Upgrading nextcloud from ${installed_version} ..." occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before From cbda0f1b452c397e9183c16343fd82b2cfd6c812 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 16 Jun 2023 17:09:57 -0500 Subject: [PATCH 29/37] Adjust update wording Signed-off-by: Eric Nemchik --- readme-vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index 8465926..162fddd 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -53,7 +53,7 @@ app_setup_block: | ### Updating Nextcloud - Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one. + Updating Nextcloud is done by pulling the new image, and recreating the container with it. It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16. From 038280e26ed71facff8675181db4bcd6f8c2e793 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 17 Jun 2023 21:37:15 -0500 Subject: [PATCH 30/37] Add max upgrade check Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index b9153f9..2f7f849 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -50,6 +50,10 @@ installed_version=$(php -r "require '/config/www/nextcloud/config/config.php'; e if [ "${installed_version}" = "" ]; then installed_version="0.0.0.0" fi +image_major="${image_version%%.*}" +installed_major="${installed_version%%.*}" +max_upgrade= +((max_upgrade=installed_major+1)) # compare versions vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } @@ -57,6 +61,11 @@ vergt() { ! vergte "${2}" "${1}"; } verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } verlt() { ! verlte "${2}" "${1}"; } +if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_version}" "${max_upgrade}"; then + echo "Can't start Nextcloud because the version of the data (${installed_version}) is more than one major version behind the docker image version (${image_version}) and upgrading more than one major version is not supported. Please run an image tagged for the major version ${max_upgrade} first." + sleep infinity +fi + if vergt "${installed_version}" "${image_version}"; then echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" sleep infinity From 11256def462af0a527c86543aca0c5572e1ccb14 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 17 Jun 2023 21:39:41 -0500 Subject: [PATCH 31/37] Fix max upgrade check Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 2f7f849..40e9d75 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -52,7 +52,6 @@ if [ "${installed_version}" = "" ]; then fi image_major="${image_version%%.*}" installed_major="${installed_version%%.*}" -max_upgrade= ((max_upgrade=installed_major+1)) # compare versions @@ -61,7 +60,7 @@ vergt() { ! vergte "${2}" "${1}"; } verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } verlt() { ! verlte "${2}" "${1}"; } -if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_version}" "${max_upgrade}"; then +if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_major}" "${max_upgrade}"; then echo "Can't start Nextcloud because the version of the data (${installed_version}) is more than one major version behind the docker image version (${image_version}) and upgrading more than one major version is not supported. Please run an image tagged for the major version ${max_upgrade} first." sleep infinity fi From b985143d6ce8b2948b62d7341d6b8e7b4a29387d Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 18 Jun 2023 08:59:02 -0500 Subject: [PATCH 32/37] Rework install/upgrade logic Persist needs_migration in case init sleeps Signed-off-by: Eric Nemchik --- root/app/upgrade.exclude | 1 - .../s6-rc.d/init-nextcloud-config/run | 45 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/root/app/upgrade.exclude b/root/app/upgrade.exclude index 3de610a..6ec8602 100644 --- a/root/app/upgrade.exclude +++ b/root/app/upgrade.exclude @@ -2,4 +2,3 @@ /config/ /data/ /themes/ -/version.php diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index 40e9d75..adbf1c5 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -15,7 +15,6 @@ mkdir -p \ if [ -f /config/www/nextcloud/version.php ]; then echo "Migrating legacy install (this can take a while) ...)" rsync -rlD --remove-source-files --exclude-from=/app/upgrade.exclude /config/www/nextcloud/ /app/www/public/ - rsync -rlD --remove-source-files --include '/version.php' --exclude '/*' /config/www/nextcloud/ /app/www/public/ rm -rf /config/www/nextcloud/updater/ find \ /config/www/nextcloud/ \ @@ -25,7 +24,7 @@ if [ -f /config/www/nextcloud/version.php ]; then ! -path "/config/www/nextcloud/themes" \ -delete sed -i "s|/config/www/nextcloud/cron.php|/app/www/public/cron.php|g" /config/crontabs/root - touch /tmp/migration + touch /config/www/nextcloud/config/needs_migration fi # symlink config folders @@ -52,7 +51,7 @@ if [ "${installed_version}" = "" ]; then fi image_major="${image_version%%.*}" installed_major="${installed_version%%.*}" -((max_upgrade=installed_major+1)) +((max_upgrade = installed_major + 1)) # compare versions vergte() { printf '%s\n%s' "${2}" "${1}" | sort -C -V; } @@ -60,58 +59,68 @@ vergt() { ! vergte "${2}" "${1}"; } verlte() { printf '%s\n%s' "${1}" "${2}" | sort -C -V; } verlt() { ! verlte "${2}" "${1}"; } -if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_major}" "${max_upgrade}"; then - echo "Can't start Nextcloud because the version of the data (${installed_version}) is more than one major version behind the docker image version (${image_version}) and upgrading more than one major version is not supported. Please run an image tagged for the major version ${max_upgrade} first." - sleep infinity -fi - if vergt "${installed_version}" "${image_version}"; then echo "Can't start Nextcloud because the version of the data (${installed_version}) is higher than the docker image version (${image_version}) and downgrading is not supported. Are you sure you have pulled the newest image version?" sleep infinity fi +if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_major}" "${max_upgrade}"; then + echo "Can't start Nextcloud because the version of the data (${installed_version}) is more than one major version behind the docker image version (${image_version}) and upgrading more than one major version is not supported. Please run an image tagged for the major version ${max_upgrade} first." + sleep infinity +fi + +if [ "${installed_version}" = "0.0.0.0" ] || [ ! -f /app/www/public/version.php ]; then + touch /tmp/needs_install +fi + +if [ "${installed_version}" != "0.0.0.0" ] && vergt "${image_version}" "${installed_version}"; then + touch /tmp/needs_upgrade +fi + # initialize nextcloud -if vergt "${image_version}" "${installed_version}" || [ -z "$(ls -A /app/www/public/core/ 2>/dev/null)" ] || [ -f /tmp/migration ]; then +if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_install ] || [ -f /tmp/needs_upgrade ]; then echo "Initializing nextcloud ${image_version} (this can take a while) ..." - if [ "${installed_version}" != "0.0.0.0" ]; then + if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ]; then echo "Upgrading nextcloud from ${installed_version} ..." occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_before fi rsync -rlD --exclude-from=/app/upgrade.exclude /app/www/src/ /app/www/public/ for dir in apps config themes; do - if [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then + if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ] || [ -z "$(ls -A /app/www/public/${dir}/ 2>/dev/null)" ]; then rsync -rlD --include "/${dir}" --exclude '/*' /app/www/src/ /config/www/nextcloud/ fi done if [ -z "$(ls -A /app/www/public/data/ 2>/dev/null)" ]; then rsync -rlD --include "/data" --exclude '/*' /app/www/src/ / fi - rsync -rlD --include '/version.php' --exclude '/*' /app/www/src/ /app/www/public/ echo "Setting permissions" lsiown abc:abc -R \ /app/www/public \ /config/www/nextcloud - if [ "${installed_version}" = "0.0.0.0" ]; then - # Install - echo "New nextcloud instance" - echo "Please run the web-based installer on first connect!" - else + if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_upgrade ]; then # Upgrade occ upgrade occ app:list | sed -n "/Enabled:/,/Disabled:/p" >/tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + else + # Install + echo "New nextcloud instance" + echo "Please run the web-based installer on first connect!" fi rm -f /tmp/list_before /tmp/list_after echo "Initializing finished" fi -rm -f /tmp/migration +rm -f \ + /config/www/nextcloud/config/needs_migration \ + /tmp/needs_install \ + /tmp/needs_upgrade # permissions lsiown abc:abc \ From 002d482a4b11c9a9083fadfd4e6473380a956f32 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 18 Jun 2023 14:20:21 -0500 Subject: [PATCH 33/37] Update new install logic --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index adbf1c5..c843991 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -108,9 +108,11 @@ if [ -f /config/www/nextcloud/config/needs_migration ] || [ -f /tmp/needs_instal echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 else - # Install - echo "New nextcloud instance" - echo "Please run the web-based installer on first connect!" + if [ "${installed_version}" = "0.0.0.0" ]; then + # Install + echo "New nextcloud instance" + echo "Please run the web-based installer on first connect!" + fi fi rm -f /tmp/list_before /tmp/list_after From 6bdb726b5c80f21493af5c00f5270619da59e698 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Mon, 19 Jun 2023 11:25:57 -0500 Subject: [PATCH 34/37] Update readme Signed-off-by: Eric Nemchik --- README.md | 4 ++-- readme-vars.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d3d3db8..9145b50 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Access the webui at `https://:443`, for more information check out [Nex ### Updating Nextcloud -Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one. +Updating Nextcloud is done by pulling the new image, and recreating the container with it. It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16. @@ -246,7 +246,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions -* **06.06.23:** - Move Nextcloud installation inside container. +* **19.06.23:** - Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/). * **25.05.23:** - Rebase to Alpine 3.18, deprecate armhf. * **13.04.23:** - Move ssl.conf include to default.conf. * **21.03.23:** - Add php81-sysvsem as new dep for v26. Update default X-Robots-Tag to `noindex, nofollow``. diff --git a/readme-vars.yml b/readme-vars.yml index 162fddd..d56d441 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -68,7 +68,7 @@ app_setup_block: | # changelog changelogs: - - { date: "06.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater." } + - { date: "19.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/)." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." } - { date: "21.03.23:", desc: "Add php81-sysvsem as new dep for v26. Update default X-Robots-Tag to `noindex, nofollow``." } From aaa5539e72f9539724962f62eb5b355aee53d90e Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 23 Jun 2023 08:02:59 -0500 Subject: [PATCH 35/37] Setup APCu for file locking Signed-off-by: Eric Nemchik --- root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run index c843991..642f3c3 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-nextcloud-config/run @@ -134,6 +134,17 @@ if occ config:system:get installed >/dev/null 2>&1; then if ! occ config:system:get memcache.local >/dev/null 2>&1; then occ config:system:set memcache.local --value='\\OC\\Memcache\\APCu' fi + if ! occ config:system:get filelocking.enabled >/dev/null 2>&1; then + occ config:system:set filelocking.enabled --value=true + fi + if ! occ config:system:get memcache.locking >/dev/null 2>&1; then + occ config:system:set memcache.locking --value='\\OC\\Memcache\\APCu' + fi +else + echo "After completing the web-based installer, restart the Nextcloud container to apply default memory caching and transactional file locking configurations." + echo "Alternatively, you can apply your own configurations by editing /config/www/nextcloud/config/config.php following the documentation:" + echo "https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html" + echo "https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/files_locking_transactional.html" fi if (occ app:list --no-interaction | grep -q richdocumentscode) 2>/dev/null; then From 8a07cc6f8d9a96aea7ab7f054bfd7fd3021c355c Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Fri, 23 Jun 2023 12:45:57 -0500 Subject: [PATCH 36/37] Update dates Signed-off-by: Eric Nemchik --- README.md | 2 +- readme-vars.yml | 2 +- root/defaults/nginx/site-confs/default.conf.sample | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b59fc4f..91e6a6f 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions -* **22.06.23:** - Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/). +* **23.06.23:** - Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/). * **21.06.23:** - Existing users should update `/config/nginx/site-confs/default.conf` - Security fix for real ip settings. * **25.05.23:** - Rebase to Alpine 3.18, deprecate armhf. * **13.04.23:** - Move ssl.conf include to default.conf. diff --git a/readme-vars.yml b/readme-vars.yml index 729714e..89a7e87 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -68,7 +68,7 @@ app_setup_block: | # changelog changelogs: - - { date: "22.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/)." } + - { date: "23.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/)." } - { date: "21.06.23:", desc: "Existing users should update `/config/nginx/site-confs/default.conf` - Security fix for real ip settings." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." } diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample index a8de741..bbf8389 100644 --- a/root/defaults/nginx/site-confs/default.conf.sample +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -1,4 +1,4 @@ -## Version 2023/06/22 - Changelog: https://github.com/linuxserver/docker-nextcloud/commits/master/root/defaults/nginx/site-confs/default.conf.sample +## Version 2023/06/23 - Changelog: https://github.com/linuxserver/docker-nextcloud/commits/master/root/defaults/nginx/site-confs/default.conf.sample # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { From fa12222577238a57dfccf0dee46f8cff1a569ab4 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 25 Jun 2023 09:02:43 -0500 Subject: [PATCH 37/37] Update cstate date Signed-off-by: Eric Nemchik --- README.md | 2 +- readme-vars.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91e6a6f..864920d 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions -* **23.06.23:** - Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/). +* **25.06.23:** - Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-25-nextcloud/). * **21.06.23:** - Existing users should update `/config/nginx/site-confs/default.conf` - Security fix for real ip settings. * **25.05.23:** - Rebase to Alpine 3.18, deprecate armhf. * **13.04.23:** - Move ssl.conf include to default.conf. diff --git a/readme-vars.yml b/readme-vars.yml index 89a7e87..f7fb7a7 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -68,7 +68,7 @@ app_setup_block: | # changelog changelogs: - - { date: "23.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-19-nextcloud/)." } + - { date: "25.06.23:", desc: "Move Nextcloud installation inside container. Remove CLI updater. [See changes announcement](https://info.linuxserver.io/issues/2023-06-25-nextcloud/)." } - { date: "21.06.23:", desc: "Existing users should update `/config/nginx/site-confs/default.conf` - Security fix for real ip settings." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "13.04.23:", desc: "Move ssl.conf include to default.conf." }