1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-06-07 07:56:12 +00:00
kopano-docker/version.sh
zokradonh b0236bf0d8 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
2019-08-22 09:21:10 +02:00

70 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
if ! command -v jq > /dev/null; then
echo "Please install jq in order to run this build script."
exit 1
fi
function finish {
if [ -e "$tmpfile" ]; then
rm "$tmpfile"
fi
}
trap finish EXIT
source base/create-kopano-repo.sh
component=${1:-core}
distribution=${2:-Debian_9.0}
if [ -e ./.env ]; then
# this is a kind of ugly hack to be able to source the env file
# this is sadly needed since postfix in https://github.com/tomav/docker-mailserver/ cannot deal with quoted values
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"
else
tmpfile="undefined"
fi
case $component in
core)
KOPANO_CORE_REPOSITORY_URL=${KOPANO_CORE_REPOSITORY_URL:-""}
if [[ $KOPANO_CORE_REPOSITORY_URL == http* ]]; then
version=$(curl -s -S -L "$KOPANO_CORE_REPOSITORY_URL"/Packages | grep -A2 "Package: kopano-server-packages")
echo "${version##* }"
exit
fi
;;
webapp)
KOPANO_WEBAPP_REPOSITORY_URL=${KOPANO_WEBAPP_REPOSITORY_URL:-""}
if [[ $KOPANO_WEBAPP_REPOSITORY_URL == http* ]]; then
version=$(curl -s -S -L "$KOPANO_WEBAPP_REPOSITORY_URL"/Packages | grep -m1 -A1 "Package: kopano-webapp")
echo "${version##* }"
exit
fi
;;
zpush)
KOPANO_ZPUSH_REPOSITORY_URL=${KOPANO_ZPUSH_REPOSITORY_URL:-"http://repo.z-hub.io/z-push:/final/Debian_9.0/"}
if [[ $KOPANO_ZPUSH_REPOSITORY_URL == http* ]]; then
version=$(curl -s -S -L "$KOPANO_ZPUSH_REPOSITORY_URL"/Packages | grep -m2 -A2 "Package: z-push-kopano")
echo "${version##* }"
exit
fi
;;
kdav)
git ls-remote --tags https://stash.kopano.io/scm/kc/kdav.git | awk -F/ '{ print $3 }' | tail -1 | sed 's/^.//'
exit
esac
# query community server by h5ai API
filename=$(h5ai_query "$component" "$distribution")
currentVersion=$(version_from_filename "$filename")
echo "$currentVersion"