From eb928d5bb39b02a22d3b47b8c3c710d438ae398b Mon Sep 17 00:00:00 2001 From: akhil Date: Fri, 30 Jul 2021 17:26:47 +0530 Subject: [PATCH 1/2] Disabled rsync step when version not updated --- custom_entrypoint.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/custom_entrypoint.sh b/custom_entrypoint.sh index e69c4bab..ccbc7502 100644 --- a/custom_entrypoint.sh +++ b/custom_entrypoint.sh @@ -1,23 +1,36 @@ #!/bin/sh +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + echo "Custom eCloud entrypoint" rsync_options="-rlDog --chown www-data:www-data --delete" SRC_DIR="/usr/src/nextcloud" DST_DIR="/var/www/html" -rsync $rsync_options --include "/news/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/notes/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/quota_warning/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/calendar/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/contacts/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/user_backend_sql_raw/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/rainloop" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/email-recovery" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ -rsync $rsync_options --include "/ecloud_drop_account" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ - -rsync $rsync_options --include "/eelo/" --exclude '/*' $SRC_DIR/themes/ $DST_DIR/themes/ - +installed_version="0.0.0.0" +if [ -f /var/www/html/version.php ]; then + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" +fi +image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + +if version_greater "$image_version" "$installed_version"; then + rsync $rsync_options --include "/news/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/notes/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/quota_warning/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/calendar/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/contacts/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/user_backend_sql_raw/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/rainloop" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/email-recovery" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + rsync $rsync_options --include "/ecloud_drop_account" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + + rsync $rsync_options --include "/eelo/" --exclude '/*' $SRC_DIR/themes/ $DST_DIR/themes/ +else + echo "Skipping rsync step as version not updated!" +fi # force eelo theme not to be disabled even when there is an upgrade process launched sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('theme', 'eelo');/g" $DST_DIR/lib/base.php -- GitLab From c768c7c75ba5edcd27aa1cc1db70886e7fb6ac82 Mon Sep 17 00:00:00 2001 From: akhil Date: Mon, 2 Aug 2021 15:05:38 +0530 Subject: [PATCH 2/2] removed sed from entrypoint; added to Dockerfile; bumped version number --- Dockerfile | 5 ++++- custom_entrypoint.sh | 16 +--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcd23bba..1cf58c06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ ${TMP_PATCH_DIR}/ COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh -RUN sed -i 's/20,0,11,1/20,0,11,5/' ${BASE_DIR}/version.php +RUN sed -i 's/20,0,11,1/20,0,11,6/' ${BASE_DIR}/version.php # Install unzip for unzipping artifacts RUN apt-get update && apt-get install unzip @@ -75,6 +75,9 @@ RUN curl -fsSL -o ecloud_drop_account.tar.gz \ # Remove unzip when unzipping is done RUN apt-get -y remove unzip +# force eelo theme not to be disabled even when there is an upgrade process launched +RUN sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('theme', 'eelo');/g" ${BASE_DIR}/lib/base.php + # Patches RUN patch -u ${BASE_DIR}/core/Controller/LoginController.php -i ${TMP_PATCH_DIR}/002-login-without-domain.patch RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch diff --git a/custom_entrypoint.sh b/custom_entrypoint.sh index ccbc7502..892723e2 100644 --- a/custom_entrypoint.sh +++ b/custom_entrypoint.sh @@ -31,19 +31,5 @@ if version_greater "$image_version" "$installed_version"; then else echo "Skipping rsync step as version not updated!" fi -# force eelo theme not to be disabled even when there is an upgrade process launched -sed -i "s/\$systemConfig->setValue('theme', '');/\$systemConfig->setValue('theme', 'eelo');/g" $DST_DIR/lib/base.php -/entrypoint.sh "$@" - -# force eelo theme to be (re)loaded after an upgrade - if [ "$(id -u)" = 0 ]; then - su -p www-data -s /bin/sh -c "php /var/www/html/occ config:system:set theme --value eelo" - su -p www-data -s /bin/sh -c "php /var/www/html/occ maintenance:theme:update" - else - sh -c "php /var/www/html/occ config:system:set theme --value eelo" - sh -c "php /var/www/html/occ maintenance:theme:update" - fi - - -echo "NC ready!" +/entrypoint.sh "$@" \ No newline at end of file -- GitLab