From e0270b2dfa5ed59f7fe570e02d2415309ec39e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 17 Dec 2025 15:14:37 +0100 Subject: [PATCH 1/2] refactor check for non-empty workdir introduce new envvar ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT if it is true, skip checks for empty docroot. if it is false and the docroot is not empty, abort. if it is empty and the docroot is not empty, print a warning and sleep, giving the user the chance to manually abort. this keeps backwards compatibility with existing deployments (that do not have the envvar set) the sleep timeout has been raise to 60seconds, so the user has more time to manually abort (in a autostart context this will add an additional delay, but shouldn't actually be harmful) Closes: https://github.com/roundcube/roundcubemail-docker/issues/384 --- templates/docker-entrypoint.sh | 48 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/templates/docker-entrypoint.sh b/templates/docker-entrypoint.sh index 600d0f04b..03874e7a9 100644 --- a/templates/docker-entrypoint.sh +++ b/templates/docker-entrypoint.sh @@ -3,6 +3,47 @@ # PWD=`pwd` +check_empty_docroot() { + local dirty_docroot_timeout=60 + + # check if ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT is valid + case "$(echo "${ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT}" | tr '[:upper:]' '[:lower:]')" in + yes|y|true|t|on|1) + # valid and truish: nothing to do + return 0 + ;; + no|n|false|f|off|0|"") + # valid and either falsish or unset: proceed to the test + ;; + *) + # invalid; proceed + cat >&2 <&2 <&2 <&2 "roundcubemail not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi + + check_empty_docroot + tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR" # update Roundcube in docroot From 993c26a4450534730b48f5417d3487f426653499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 17 Dec 2025 15:15:58 +0100 Subject: [PATCH 2/2] update entrypoint scripts for the various variants --- apache/docker-entrypoint.sh | 48 ++++++++++++++++++++++++++++++--- fpm-alpine/docker-entrypoint.sh | 48 ++++++++++++++++++++++++++++++--- fpm/docker-entrypoint.sh | 48 ++++++++++++++++++++++++++++++--- 3 files changed, 132 insertions(+), 12 deletions(-) diff --git a/apache/docker-entrypoint.sh b/apache/docker-entrypoint.sh index 600d0f04b..03874e7a9 100755 --- a/apache/docker-entrypoint.sh +++ b/apache/docker-entrypoint.sh @@ -3,6 +3,47 @@ # PWD=`pwd` +check_empty_docroot() { + local dirty_docroot_timeout=60 + + # check if ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT is valid + case "$(echo "${ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT}" | tr '[:upper:]' '[:lower:]')" in + yes|y|true|t|on|1) + # valid and truish: nothing to do + return 0 + ;; + no|n|false|f|off|0|"") + # valid and either falsish or unset: proceed to the test + ;; + *) + # invalid; proceed + cat >&2 <&2 <&2 <&2 "roundcubemail not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi + + check_empty_docroot + tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR" # update Roundcube in docroot diff --git a/fpm-alpine/docker-entrypoint.sh b/fpm-alpine/docker-entrypoint.sh index 600d0f04b..03874e7a9 100755 --- a/fpm-alpine/docker-entrypoint.sh +++ b/fpm-alpine/docker-entrypoint.sh @@ -3,6 +3,47 @@ # PWD=`pwd` +check_empty_docroot() { + local dirty_docroot_timeout=60 + + # check if ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT is valid + case "$(echo "${ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT}" | tr '[:upper:]' '[:lower:]')" in + yes|y|true|t|on|1) + # valid and truish: nothing to do + return 0 + ;; + no|n|false|f|off|0|"") + # valid and either falsish or unset: proceed to the test + ;; + *) + # invalid; proceed + cat >&2 <&2 <&2 <&2 "roundcubemail not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi + + check_empty_docroot + tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR" # update Roundcube in docroot diff --git a/fpm/docker-entrypoint.sh b/fpm/docker-entrypoint.sh index 600d0f04b..03874e7a9 100755 --- a/fpm/docker-entrypoint.sh +++ b/fpm/docker-entrypoint.sh @@ -3,6 +3,47 @@ # PWD=`pwd` +check_empty_docroot() { + local dirty_docroot_timeout=60 + + # check if ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT is valid + case "$(echo "${ROUNDCUBEMAIL_ALLOW_DIRTY_DOCROOT}" | tr '[:upper:]' '[:lower:]')" in + yes|y|true|t|on|1) + # valid and truish: nothing to do + return 0 + ;; + no|n|false|f|off|0|"") + # valid and either falsish or unset: proceed to the test + ;; + *) + # invalid; proceed + cat >&2 <&2 <&2 <&2 "roundcubemail not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) - fi + + check_empty_docroot + tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR" # update Roundcube in docroot