1
0
mirror of https://github.com/zokradonh/kopano-docker synced 2025-06-07 07:56:12 +00:00
kopano-docker/meet/start-service.sh
Felix Bartels 70e9940b38
Run all containers read-only (#314)
* switch containers in compose file to read-only
related to https://github.com/zokradonh/kopano-docker/issues/310
* make scheduler container read-only
* make meet container read-only
* fix konnect for read-only
* make core mostly read-only
* add custom location for ldap.cfg to default config
* sort config option for readability
* update makefile pull workaround
* make kdav read-only
* remove locale generation code from core startup
* fix commander tests
* fix store language tests
* add test for a dutch mailbox
* make it possible to run webapp read-only
* add locale hint to the compose file
* finish read-only mode for z-push
2020-01-14 14:31:53 +01:00

78 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""}
set -eu # unset variables are errors & non-zero return values exit the whole script
[ "$DEBUG" ] && set -x
# copy configuration files to /tmp/kopano to prevent modification of mounted config files
mkdir -p /tmp/kopano
cp /etc/kopano/*.cfg /tmp/kopano
if [ ! -e /kopano/"$SERVICE_TO_START".py ]; then
echo "Invalid service specified: $SERVICE_TO_START" | ts
exit 1
fi
# TODO how to best move this to /tmp?
echo "Configure service '$SERVICE_TO_START'" | ts
/usr/bin/python3 /kopano/"$SERVICE_TO_START".py
meetversion=$(dpkg-query --showformat='${Version}' --show kopano-meet-webapp)
echo "Using Kopano Meet: $meetversion"
# allow helper commands given by "docker-compose run"
if [ $# -gt 0 ]; then
exec "$@"
exit
fi
cp /usr/share/doc/kopano-meet-webapp/config.json.in /tmp/meet.json
CONFIG_JSON="/tmp/meet.json"
echo "Updating $CONFIG_JSON"
for setting in $(compgen -A variable KCCONF_MEET); do
setting2=${setting#KCCONF_MEET_}
# dots in setting2 need to be escaped to not be handled as separate entities in the json file
case ${!setting} in
true|TRUE|false|FALSE)
jq ".\"${setting2//_/\".\"}\" = ${!setting}" $CONFIG_JSON | sponge $CONFIG_JSON
;;
*)
jq ".\"${setting2//_/\".\"}\" = \"${!setting}\"" $CONFIG_JSON | sponge $CONFIG_JSON
;;
esac
done
# Populate app grid
# Note: if below variables are set to "no" kpop will fall back to its default behaviour and show all known apps.
# enable Kopano Konnect in the app grid
if [ "${GRID_KONNECT:-yes}" = "yes" ]; then
jq '.apps.enabled += ["kopano-konnect"]' $CONFIG_JSON | sponge $CONFIG_JSON
fi
# enable Kopano Meet in the app grid
if [ "${GRID_MEET:-yes}" = "yes" ]; then
jq '.apps.enabled += ["kopano-meet"]' $CONFIG_JSON | sponge $CONFIG_JSON
fi
# enable Kopano WebApp in the app grid
if [ "${GRID_WEBAPP:-yes}" = "yes" ]; then
jq '.apps.enabled += ["kopano-webapp"]' $CONFIG_JSON | sponge $CONFIG_JSON
fi
# todo do not replace here, but in a temp location
sed s/\ *=\ */=/g /tmp/kopano/kwebd.cfg > /tmp/kweb-env
# always disable tls
export tls=no
# shellcheck disable=SC2046
export $(grep -v '^#' /tmp/kweb-env | xargs -d '\n')
# services need to be aware of the machine-id
dockerize \
-wait file:///etc/machine-id \
-wait file:///var/lib/dbus/machine-id
# cleaning up env variables
unset "${!KCCONF_@}"
exec kopano-kwebd serve