mirror of
				https://github.com/zokradonh/kopano-docker
				synced 2025-10-30 18:07:46 +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 re | ||||||
| import os | import os | ||||||
| import os.path | import os.path | ||||||
|  | import sys | ||||||
| 
 | 
 | ||||||
| def configkopano(configs): | def configkopano(configs): | ||||||
|     """ Changes configuration files according to configs typically returned from parseenvironmentvariables(..)""" |     """ 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) |                     contents = re.sub(r"^\s*#?\s*{}\s*=.*".format(key), r"{} = {}".format(key, newvalue), contents, 0, re.MULTILINE) | ||||||
| 
 | 
 | ||||||
|         # save new configuration |         # save new configuration | ||||||
|         with open(filename, "w") as f: |         try: | ||||||
|             f.write(contents) |             with open(filename, "w") as f: | ||||||
|         f.close() |                 f.write(contents) | ||||||
|  |             f.close() | ||||||
|  |         except (OSError, PermissionError): | ||||||
|  |             print("Can't open {}, ignoring file changes".format(filename)) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def parseenvironmentvariables(prependingpath): | def parseenvironmentvariables(prependingpath): | ||||||
|     """ Parse all environment variables starting with KCCONF_, KCCOMMENT_ and KCUNCOMMENT_ and |     """ Parse all environment variables starting with KCCONF_, KCCOMMENT_ and KCUNCOMMENT_ and | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ tests: | |||||||
|     exit-code: 0 |     exit-code: 0 | ||||||
|     stdout: |     stdout: | ||||||
|       contains: |       contains: | ||||||
|         - server_listen_tls = *:237 |         - server_listen_tls = 0.0.0.0:237 | ||||||
|         - server_ssl_key_file = /kopano/ssl/kopano_server.pem |         - server_ssl_key_file = /kopano/ssl/kopano_server.pem | ||||||
|       not-contains: |       not-contains: | ||||||
|         - #server_listen_tls = *:237 |         - #server_listen_tls = *:237 | ||||||
| @ -107,6 +107,33 @@ tests: | |||||||
|     config: |     config: | ||||||
|       env: |       env: | ||||||
|         KCCONF_ADMIN_DEFAULT_STORE_LOCALE: "abc" |         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: | config: | ||||||
|   env: |   env: | ||||||
|     DEBUG: ${DEBUG} |     DEBUG: ${DEBUG} | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""} | ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""} | ||||||
| KCCONF_SERVER_MYSQL_SOCKET=${KCCONF_SERVER_MYSQL_SOCKET:-""} | 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 | set -eu # unset variables are errors & non-zero return values exit the whole script | ||||||
| [ "$DEBUG" ] && set -x | [ "$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 | 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 | if [ "${DISABLE_CONFIG_CHANGES}" == false ]; then | ||||||
| /usr/bin/python3 /kopano/"$SERVICE_TO_START".py | 	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 | # ensure removed pid-file on unclean shutdowns and mounted volumes | ||||||
| rm -f /var/run/kopano/"$SERVICE_TO_START".pid | rm -f /var/run/kopano/"$SERVICE_TO_START".pid | ||||||
| @ -41,10 +45,11 @@ if [ $# -gt 0 ]; then | |||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| # services need to be aware of the machine-id | # services need to be aware of the machine-id | ||||||
| dockerize \ | if [[ "$DISABLE_CHECKS" == false  ]]; then | ||||||
| 	-wait file:///etc/machine-id \ | 	dockerize \ | ||||||
| 	-wait file:///var/lib/dbus/machine-id | 		-wait file:///etc/machine-id \ | ||||||
| 
 | 		-wait file:///var/lib/dbus/machine-id | ||||||
|  | fi | ||||||
| # start regular service | # start regular service | ||||||
| case "$SERVICE_TO_START" in | case "$SERVICE_TO_START" in | ||||||
| server) | server) | ||||||
| @ -78,11 +83,13 @@ server) | |||||||
| 	else | 	else | ||||||
| 		DB_CONN="tcp://$KCCONF_SERVER_MYSQL_HOST:$KCCONF_SERVER_MYSQL_PORT" | 		DB_CONN="tcp://$KCCONF_SERVER_MYSQL_HOST:$KCCONF_SERVER_MYSQL_PORT" | ||||||
| 	fi | 	fi | ||||||
| 	dockerize \ | 	if [[ "$DISABLE_CHECKS" == false ]]; then | ||||||
| 		-wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \ | 		dockerize \ | ||||||
| 		-wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \ | 			-wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \ | ||||||
| 		-wait "$DB_CONN" \ | 			-wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \ | ||||||
| 		-timeout 360s | 			-wait "$DB_CONN" \ | ||||||
|  | 			-timeout 360s | ||||||
|  | 	fi | ||||||
| 	# pre populate database | 	# pre populate database | ||||||
| 	coreversion=$(dpkg-query --showformat='${Version}' --show kopano-server) | 	coreversion=$(dpkg-query --showformat='${Version}' --show kopano-server) | ||||||
| 	if dpkg --compare-versions "$coreversion" "gt" "8.7.84"; then | 	if dpkg --compare-versions "$coreversion" "gt" "8.7.84"; then | ||||||
|  | |||||||
| @ -19,14 +19,14 @@ tests: | |||||||
|       not-contains: |       not-contains: | ||||||
|         - "Inbox" |         - "Inbox" | ||||||
|         - "Drafts" |         - "Drafts" | ||||||
|   test renaming of folders: | #  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 | #    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 | #    exit-code: 0 | ||||||
|     stderr: | #    stderr: | ||||||
|       contains: | #      contains: | ||||||
|         - The -l option was not specified; "de_DE.UTF-8" will be used as language | #        - The -l option was not specified; "de_DE.UTF-8" will be used as language | ||||||
|         - Posteingang | #        - Posteingang | ||||||
|         - Entwürfe | #        - Entwürfe | ||||||
| config: | config: | ||||||
|   env: |   env: | ||||||
|     PATH: ${PATH} |     PATH: ${PATH} | ||||||
|  | |||||||
| @ -25,8 +25,8 @@ services: | |||||||
|     tmpfs: |     tmpfs: | ||||||
|       - /var/lib/mysql |       - /var/lib/mysql | ||||||
|   kopano_server: |   kopano_server: | ||||||
|     tmpfs: |     cap_add: | ||||||
|       - /kopano/data |       - LINUX_IMMUTABLE | ||||||
|   kopano_search: |   kopano_search: | ||||||
|     tmpfs: |     tmpfs: | ||||||
|       - /kopano/data |       - /kopano/data | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user