From b0236bf0d8e5e87ef7385b151d908e734152a476 Mon Sep 17 00:00:00 2001 From: zokradonh Date: Thu, 22 Aug 2019 09:21:10 +0200 Subject: [PATCH] Cure some quoting issues * Double quotes not needed by docker compose Same issue as here https://github.com/zokradonh/kopano-docker/issues/216 * move deletion of tmpfile into an exit trap otherwise the file is not cleaned up when supported images are built * repair sourcing of env by removing kopano ldap settings from env before sourcing * additional packages env vars should be quoted in .env * adapt start scripts to handle quotes additional packages * treat update-tag script with ldap variable fix from setup.sh fixes #216 * run version.sh in travis (to fail early if something is wrong there) commit forgotten fixes to start scripts --- .travis.yml | 2 ++ Makefile | 4 ++-- core/start-service.sh | 2 +- setup-update-tag.sh | 13 +++++++++---- setup.sh | 8 ++++---- version.sh | 12 +++++++++--- webapp/start.sh | 2 +- zpush/start.sh | 2 +- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index db24718..d2798e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,10 @@ before_install: - sudo pip install --upgrade pip && sudo pip install yamllint - npm install -g eclint install: + - "./version.sh" - make lint - "./test.exp" + - "./version.sh" - make lint # rerun lint to see if output is different with .env in place - echo "docker_repo=$docker_repo" >> .env - echo "DOCKERREADME=yes" >> .env # add DOCKERREADME env var so that make publish also updates readme files on docker hub diff --git a/Makefile b/Makefile index db6d038..9ff6db7 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ endif --build-arg KOPANO_ZPUSH_REPOSITORY_URL=$(KOPANO_ZPUSH_REPOSITORY_URL) \ --build-arg RELEASE_KEY_DOWNLOAD=$(RELEASE_KEY_DOWNLOAD) \ --build-arg DOWNLOAD_COMMUNITY_PACKAGES=$(DOWNLOAD_COMMUNITY_PACKAGES) \ - --build-arg ADDITIONAL_KOPANO_PACKAGES="$(ADDITIONAL_KOPANO_PACKAGES)" \ - --build-arg ADDITIONAL_KOPANO_WEBAPP_PLUGINS="$(ADDITIONAL_KOPANO_WEBAPP_PLUGINS)" \ + --build-arg ADDITIONAL_KOPANO_PACKAGES=$(ADDITIONAL_KOPANO_PACKAGES) \ + --build-arg ADDITIONAL_KOPANO_WEBAPP_PLUGINS=$(ADDITIONAL_KOPANO_WEBAPP_PLUGINS) \ --cache-from $(docker_repo)/kopano_$(component):builder \ -t $(docker_repo)/kopano_$(component) $(component)/ diff --git a/core/start-service.sh b/core/start-service.sh index 7667c8e..50ea311 100755 --- a/core/start-service.sh +++ b/core/start-service.sh @@ -11,7 +11,7 @@ if [ ! -e /kopano/"$SERVICE_TO_START".py ]; then fi [ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update -[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do +[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"'); do # shellcheck disable=SC2016 disable=SC2086 if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then apt --assume-yes --no-upgrade install "$installpkg" diff --git a/setup-update-tag.sh b/setup-update-tag.sh index 96bacf0..fbb06e3 100755 --- a/setup-update-tag.sh +++ b/setup-update-tag.sh @@ -3,6 +3,13 @@ set -euo pipefail IFS=$'\n\t' +function finish { + if [ -e "$tmpfile" ]; then + rm "$tmpfile" + fi +} +trap finish EXIT + if ! command -v reg > /dev/null; then echo "Please install reg in order to run this script." exit 1 @@ -19,6 +26,8 @@ tmpfile=$(mktemp /tmp/kopano-docker-env.XXXXXX) cp ./.env "$tmpfile" sed -i '/LDAP_QUERY_FILTER/s/^/#/g' "$tmpfile" sed -i '/SASLAUTHD_LDAP_FILTER/s/^/#/g' "$tmpfile" +sed -i '/KCUNCOMMENT_LDAP_1/s/^/#/g' "$tmpfile" +sed -i '/KCCOMMENT_LDAP_1/s/^/#/g' "$tmpfile" # shellcheck disable=SC1090 source "$tmpfile" @@ -112,7 +121,3 @@ update_env_file SSL_VERSION "$return_value" tag_question kopano_ldap "${LDAP_VERSION:-latest}" "LDAP container" update_env_file LDAP_VERSION "$return_value" - -if [ -e "$tmpfile" ]; then - rm "$tmpfile" -fi diff --git a/setup.sh b/setup.sh index ae972dd..f616d65 100755 --- a/setup.sh +++ b/setup.sh @@ -282,8 +282,8 @@ SELF_SERVICE_PASSWORD_MIN_DIGIT=1 SELF_SERVICE_PASSWORD_MIN_SPECIAL=1 # switch the value of these two variables to use the activedirectory configuration -KCUNCOMMENT_LDAP_1="!include /usr/share/kopano/ldap.openldap.cfg" -KCCOMMENT_LDAP_1="!include /usr/share/kopano/ldap.active-directory.cfg" +KCUNCOMMENT_LDAP_1=!include /usr/share/kopano/ldap.openldap.cfg +KCCOMMENT_LDAP_1=!include /usr/share/kopano/ldap.active-directory.cfg MYSQL_HOST=$MYSQL_HOST MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD @@ -333,8 +333,8 @@ COMPOSE_FILE=docker-compose.yml:docker-compose.ports.yml #DOWNLOAD_COMMUNITY_PACKAGES=0 # Additional packages to install -ADDITIONAL_KOPANO_PACKAGES= -ADDITIONAL_KOPANO_WEBAPP_PLUGINS=$ADDITIONAL_KOPANO_WEBAPP_PLUGINS +ADDITIONAL_KOPANO_PACKAGES="" +ADDITIONAL_KOPANO_WEBAPP_PLUGINS="$ADDITIONAL_KOPANO_WEBAPP_PLUGINS" EOF else diff --git a/version.sh b/version.sh index 5e9e225..2603f63 100755 --- a/version.sh +++ b/version.sh @@ -4,6 +4,13 @@ if ! command -v jq > /dev/null; then exit 1 fi +function finish { + if [ -e "$tmpfile" ]; then + rm "$tmpfile" + fi +} +trap finish EXIT + source base/create-kopano-repo.sh component=${1:-core} @@ -16,6 +23,8 @@ if [ -e ./.env ]; then cp ./.env "$tmpfile" sed -i '/LDAP_QUERY_FILTER/s/^/#/g' "$tmpfile" sed -i '/SASLAUTHD_LDAP_FILTER/s/^/#/g' "$tmpfile" + sed -i '/KCUNCOMMENT_LDAP_1/s/^/#/g' "$tmpfile" + sed -i '/KCCOMMENT_LDAP_1/s/^/#/g' "$tmpfile" # shellcheck disable=SC1090 source "$tmpfile" else @@ -58,6 +67,3 @@ filename=$(h5ai_query "$component" "$distribution") currentVersion=$(version_from_filename "$filename") echo "$currentVersion" -if [ -e "$tmpfile" ]; then - rm "$tmpfile" -fi diff --git a/webapp/start.sh b/webapp/start.sh index 19a3324..baad625 100755 --- a/webapp/start.sh +++ b/webapp/start.sh @@ -14,7 +14,7 @@ source /kopano/start-helper.sh ADDITIONAL_KOPANO_PACKAGES="$ADDITIONAL_KOPANO_PACKAGES $ADDITIONAL_KOPANO_WEBAPP_PLUGINS" [ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update -[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do +[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"'); do # shellcheck disable=SC2016 disable=SC2086 if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then apt --assume-yes --no-upgrade install "$installpkg" diff --git a/zpush/start.sh b/zpush/start.sh index e93e275..9640276 100755 --- a/zpush/start.sh +++ b/zpush/start.sh @@ -38,7 +38,7 @@ php_cfg_gen() { } [ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update -[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do +[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"'); do # shellcheck disable=SC2016 disable=SC2086 if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then apt --assume-yes --no-upgrade install "$installpkg"