1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-06-07 16:06:14 +00:00

Make z-push configurable through env (#128)

* change current config changes to use php_cfg_gen
* add remaining (for kopano relevant config files)
* add autodiscover to z-push image
* add more autodiscover aliases to kweb

fixes #114 #39
This commit is contained in:
Felix Bartels 2019-03-25 10:16:46 +01:00 committed by GitHub
parent 67e8f44eac
commit aefcf10485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 11 deletions

View File

@ -152,6 +152,20 @@
try_duration 30s try_duration 30s
} }
proxy /Autodiscover/Autodiscover.xml kopano_zpush:80 {
transparent
keepalive 0
fail_timeout 10s
try_duration 30s
}
proxy /autodiscover/autodiscover.xml kopano_zpush:80 {
transparent
keepalive 0
fail_timeout 10s
try_duration 30s
}
proxy /caldav/ kopano_ical:8080 { proxy /caldav/ kopano_ical:8080 {
fail_timeout 10s fail_timeout 10s
try_duration 30s try_duration 30s

View File

@ -29,7 +29,7 @@ php_cfg_gen() {
cat "$cfg_file" cat "$cfg_file"
exit 1 exit 1
fi fi
else else
echo "Error: Config file $cfg_file not found. Plugin not installed?" echo "Error: Config file $cfg_file not found. Plugin not installed?"
local dir local dir
dir=$(dirname "$cfg_file") dir=$(dirname "$cfg_file")

View File

@ -46,6 +46,8 @@ RUN \
z-push-kopano \ z-push-kopano \
z-push-config-apache \ z-push-config-apache \
z-push-kopano-gabsync \ z-push-kopano-gabsync \
z-push-autodiscover \
z-push-config-apache-autodiscover \
ca-certificates \ ca-certificates \
${ADDITIONAL_KOPANO_PACKAGES} \ ${ADDITIONAL_KOPANO_PACKAGES} \
&& rm -rf /var/cache/apt /var/lib/apt/lists && rm -rf /var/cache/apt /var/lib/apt/lists

View File

@ -7,6 +7,36 @@ ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""}
set -eu # unset variables are errors & non-zero return values exit the whole script set -eu # unset variables are errors & non-zero return values exit the whole script
php_cfg_gen() {
local cfg_file="$1"
local cfg_setting="$2"
local cfg_value="$3"
if [ -e "$cfg_file" ]; then
if grep -q "$cfg_setting" "$cfg_file"; then
echo "Setting $cfg_setting = $cfg_value in $cfg_file"
case $cfg_value in
true|TRUE|false|FALSE)
echo boolean value
sed -ri "s#(\s*define).+${cfg_setting}.+#\tdefine(\x27${cfg_setting}\x27, ${cfg_value}\);#g" "$cfg_file"
;;
*)
sed -ri "s#(\s*define).+${cfg_setting}.+#\tdefine(\x27${cfg_setting}\x27, \x27${cfg_value}\x27\);#g" "$cfg_file"
;;
esac
else
echo "Error: Config option $cfg_setting not found in $cfg_file"
cat "$cfg_file"
exit 1
fi
else
echo "Error: Config file $cfg_file not found. Plugin not installed?"
local dir
dir=$(dirname "$cfg_file")
ls -la "$dir"
exit 1
fi
}
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update [ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do [ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do
# shellcheck disable=SC2016 disable=SC2086 # shellcheck disable=SC2016 disable=SC2086
@ -15,33 +45,67 @@ set -eu # unset variables are errors & non-zero return values exit the whole scr
fi fi
done done
echo "Ensure directories" # Ensure directories
mkdir -p /run/sessions mkdir -p /run/sessions
if [ "$KCCONF_SERVERHOSTNAME" == "127.0.0.1" ]; then if [ "$KCCONF_SERVERHOSTNAME" == "127.0.0.1" ]; then
echo "Z-Push is using the default: connection" echo "Z-Push is using the default: connection"
else else
echo "Z-Push is using an ip connection" echo "Z-Push is using an ip connection"
sed -e "s#define([\"']MAPI_SERVER[\"'],\s*[\"']default:[\"'])#define('MAPI_SERVER', 'https://${KCCONF_SERVERHOSTNAME}:${KCCONF_SERVERPORT}/kopano')#" \ php_cfg_gen /etc/z-push/kopano.conf.php MAPI_SERVER "https://${KCCONF_SERVERHOSTNAME}:${KCCONF_SERVERPORT}/kopano"
-i /etc/z-push/kopano.conf.php
fi fi
echo "Configuring Z-Push for use behind a reverse proxy" echo "Configuring Z-Push for use behind a reverse proxy"
sed -e "s#define([\"']USE_CUSTOM_REMOTE_IP_HEADER[\"'],\s*false)#define('USE_CUSTOM_REMOTE_IP_HEADER', 'HTTP_X_FORWARDED_FOR')#" \ php_cfg_gen /etc/z-push/z-push.conf.php USE_CUSTOM_REMOTE_IP_HEADER HTTP_X_FORWARDED_FOR
-i /etc/z-push/z-push.conf.php
sed -e "s#define([\"']USERNAME[\"'],\s*'')#define('USERNAME', 'SYSTEM')#" \ # configuring z-push from env
-i /etc/z-push/gabsync.conf.php for setting in $(compgen -A variable KCCONF_ZPUSH_); do
setting2=${setting#KCCONF_ZPUSH_}
php_cfg_gen /etc/z-push/z-push.conf.php "${setting2}" "${!setting}"
done
# configuring autodiscover
for setting in $(compgen -A variable KCCONF_ZPUSHAUTODISCOVER_); do
setting2=${setting#KCCONF_ZPUSHAUTODISCOVER_}
php_cfg_gen /etc/z-push/autodiscover.conf.php "${setting2}" "${!setting}"
done
# configuring z-push gabsync
php_cfg_gen /etc/z-push/gabsync.conf.php USERNAME SYSTEM
for setting in $(compgen -A variable KCCONF_ZPUSHGABSYNC_); do
setting2=${setting#KCCONF_ZPUSHGAVSYNC_}
php_cfg_gen /etc/z-push/z-push.conf.php "${setting2}" "${!setting}"
done
# configuring z-push sql state engine
for setting in $(compgen -A variable KCCONF_ZPUSHSQL_); do
setting2=${setting#KCCONF_ZPUSHSQL_}
php_cfg_gen /etc/z-push/state-sql.conf.php "${setting2}" "${!setting}"
done
# configuring z-push memcached
for setting in $(compgen -A variable KCCONF_ZPUSHMEMCACHED_); do
setting2=${setting#KCCONF_ZPUSHMEMCACHED_}
php_cfg_gen /etc/z-push/memcached.conf.php "${setting2}" "${!setting}"
done
# configuring z-push gab2contacts
for setting in $(compgen -A variable KCCONF_ZPUSHGA2CONTACTS_); do
setting2=${setting#KCCONF_ZPUSHSQL_}
php_cfg_gen /etc/z-push/gab2contacts.conf.php "${setting2}" "${!setting}"
done
echo "Ensure config ownership" echo "Ensure config ownership"
chown -R www-data:www-data /run/sessions chown -R www-data:www-data /run/sessions
echo "Activate z-push log rerouting" echo "Activate z-push log rerouting"
touch /var/log/z-push/z-push.log touch /var/log/z-push/{z-push.log,z-push-error.log,autodiscover.log,autodiscover-error.log}
touch /var/log/z-push/z-push-error.log chown -R www-data:www-data /var/log/z-push
chown www-data:www-data /var/log/z-push/z-push.log /var/log/z-push/z-push-error.log
tail --pid=$$ -F --lines=0 -q /var/log/z-push/z-push.log & tail --pid=$$ -F --lines=0 -q /var/log/z-push/z-push.log &
tail --pid=$$ -F --lines=0 -q /var/log/z-push/z-push-error.log & tail --pid=$$ -F --lines=0 -q /var/log/z-push/z-push-error.log &
tail --pid=$$ -F --lines=0 -q /var/log/z-push/autodiscover.log &
tail --pid=$$ -F --lines=0 -q /var/log/z-push/autodiscover-error.log &
echo "Starting Apache" echo "Starting Apache"
rm -f /run/apache2/apache2.pid rm -f /run/apache2/apache2.pid