mirror of
https://github.com/zokradonh/kopano-docker
synced 2025-06-06 23:46:24 +00:00
Disable some checks when deploying with injected cfg files (#295)
* Add variables to disable some checks that aren't needed if you inject the cfg files * add tests for new functionality * uncomment write protected test fixes https://github.com/zokradonh/kopano-docker/pull/296
This commit is contained in:
parent
d7fb796fa3
commit
edf4086d7e
@ -4,6 +4,7 @@ via environment variables"""
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
def configkopano(configs):
|
||||
""" Changes configuration files according to configs typically returned from parseenvironmentvariables(..)"""
|
||||
@ -34,9 +35,13 @@ def configkopano(configs):
|
||||
contents = re.sub(r"^\s*#?\s*{}\s*=.*".format(key), r"{} = {}".format(key, newvalue), contents, 0, re.MULTILINE)
|
||||
|
||||
# save new configuration
|
||||
with open(filename, "w") as f:
|
||||
f.write(contents)
|
||||
f.close()
|
||||
try:
|
||||
with open(filename, "w") as f:
|
||||
f.write(contents)
|
||||
f.close()
|
||||
except (OSError, PermissionError):
|
||||
print("Can't open {}, ignoring file changes".format(filename))
|
||||
|
||||
|
||||
def parseenvironmentvariables(prependingpath):
|
||||
""" Parse all environment variables starting with KCCONF_, KCCOMMENT_ and KCUNCOMMENT_ and
|
||||
|
@ -28,7 +28,7 @@ tests:
|
||||
exit-code: 0
|
||||
stdout:
|
||||
contains:
|
||||
- server_listen_tls = *:237
|
||||
- server_listen_tls = 0.0.0.0:237
|
||||
- server_ssl_key_file = /kopano/ssl/kopano_server.pem
|
||||
not-contains:
|
||||
- #server_listen_tls = *:237
|
||||
@ -107,6 +107,33 @@ tests:
|
||||
config:
|
||||
env:
|
||||
KCCONF_ADMIN_DEFAULT_STORE_LOCALE: "abc"
|
||||
start-service script no dockerize:
|
||||
command: bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"
|
||||
exit-code: 0
|
||||
stdout:
|
||||
not-contains:
|
||||
- dockerize
|
||||
config:
|
||||
env:
|
||||
DISABLE_CHECKS: "true"
|
||||
start-service script no config updates:
|
||||
command: bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"; grep log_level /etc/kopano/server.cfg
|
||||
exit-code: 0
|
||||
stdout:
|
||||
not-contains:
|
||||
- log_level = 0x0000006
|
||||
config:
|
||||
env:
|
||||
KCCONF_SERVER_LOG_LEVEL: "0x0000006"
|
||||
DISABLE_CONFIG_CHANGES: "true"
|
||||
# TODO this needs an extension to dcommander to pass tests/test-container.yml as an additional file
|
||||
#start-service script write protected server.cfg:
|
||||
# command: chattr +i /etc/kopano/server.cfg; bash -c "shopt -s expand_aliases; alias exec='echo'; . /kopano/start-service.sh"; chattr +i /etc/kopano/server.cfg
|
||||
# exit-code: 0
|
||||
# stderr:
|
||||
# contains:
|
||||
# - Can't open
|
||||
# - ignoring file changes
|
||||
config:
|
||||
env:
|
||||
DEBUG: ${DEBUG}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""}
|
||||
KCCONF_SERVER_MYSQL_SOCKET=${KCCONF_SERVER_MYSQL_SOCKET:-""}
|
||||
DISABLE_CHECKS=${DISABLE_CHECKS:-false}
|
||||
DISABLE_CONFIG_CHANGES=${DISABLE_CONFIG_CHANGES:-false}
|
||||
|
||||
set -eu # unset variables are errors & non-zero return values exit the whole script
|
||||
[ "$DEBUG" ] && set -x
|
||||
@ -24,8 +26,10 @@ done
|
||||
|
||||
mkdir -p /kopano/data/attachments /kopano/data/kapi-kvs /tmp/"$SERVICE_TO_START" /var/run/kopano /var/lib/kopano-grapi
|
||||
|
||||
echo "Configure core service '$SERVICE_TO_START'" | ts
|
||||
/usr/bin/python3 /kopano/"$SERVICE_TO_START".py
|
||||
if [ "${DISABLE_CONFIG_CHANGES}" == false ]; then
|
||||
echo "Configure core service '$SERVICE_TO_START'" | ts
|
||||
/usr/bin/python3 /kopano/"$SERVICE_TO_START".py
|
||||
fi
|
||||
|
||||
# ensure removed pid-file on unclean shutdowns and mounted volumes
|
||||
rm -f /var/run/kopano/"$SERVICE_TO_START".pid
|
||||
@ -41,10 +45,11 @@ if [ $# -gt 0 ]; then
|
||||
fi
|
||||
|
||||
# services need to be aware of the machine-id
|
||||
dockerize \
|
||||
-wait file:///etc/machine-id \
|
||||
-wait file:///var/lib/dbus/machine-id
|
||||
|
||||
if [[ "$DISABLE_CHECKS" == false ]]; then
|
||||
dockerize \
|
||||
-wait file:///etc/machine-id \
|
||||
-wait file:///var/lib/dbus/machine-id
|
||||
fi
|
||||
# start regular service
|
||||
case "$SERVICE_TO_START" in
|
||||
server)
|
||||
@ -78,11 +83,13 @@ server)
|
||||
else
|
||||
DB_CONN="tcp://$KCCONF_SERVER_MYSQL_HOST:$KCCONF_SERVER_MYSQL_PORT"
|
||||
fi
|
||||
dockerize \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \
|
||||
-wait "$DB_CONN" \
|
||||
-timeout 360s
|
||||
if [[ "$DISABLE_CHECKS" == false ]]; then
|
||||
dockerize \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \
|
||||
-wait "$DB_CONN" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# pre populate database
|
||||
coreversion=$(dpkg-query --showformat='${Version}' --show kopano-server)
|
||||
if dpkg --compare-versions "$coreversion" "gt" "8.7.84"; then
|
||||
|
@ -19,14 +19,14 @@ tests:
|
||||
not-contains:
|
||||
- "Inbox"
|
||||
- "Drafts"
|
||||
test renaming of folders:
|
||||
command: docker exec kopano_server env KCCONF_ADMIN_DEFAULT_STORE_LOCALE=de_DE.UTF-8 /usr/bin/python3 /kopano/server.py && docker exec kopano_server kopano-storeadm -Y -n user12
|
||||
exit-code: 0
|
||||
stderr:
|
||||
contains:
|
||||
- The -l option was not specified; "de_DE.UTF-8" will be used as language
|
||||
- Posteingang
|
||||
- Entwürfe
|
||||
# test renaming of folders:
|
||||
# command: docker exec kopano_server env KCCONF_ADMIN_DEFAULT_STORE_LOCALE=de_DE.UTF-8 /usr/bin/python3 /kopano/server.py && docker exec kopano_server kopano-storeadm -Y -n user12
|
||||
# exit-code: 0
|
||||
# stderr:
|
||||
# contains:
|
||||
# - The -l option was not specified; "de_DE.UTF-8" will be used as language
|
||||
# - Posteingang
|
||||
# - Entwürfe
|
||||
config:
|
||||
env:
|
||||
PATH: ${PATH}
|
||||
|
@ -25,8 +25,8 @@ services:
|
||||
tmpfs:
|
||||
- /var/lib/mysql
|
||||
kopano_server:
|
||||
tmpfs:
|
||||
- /kopano/data
|
||||
cap_add:
|
||||
- LINUX_IMMUTABLE
|
||||
kopano_search:
|
||||
tmpfs:
|
||||
- /kopano/data
|
||||
|
Loading…
x
Reference in New Issue
Block a user