mirror of
https://github.com/zokradonh/kopano-docker.git
synced 2026-08-11 16:32:59 +00:00
implement new env variable to disable all automatic actions (#434)
* implement new env variable to disable all automatic actions fixes https://github.com/zokradonh/kopano-docker/issues/360 * wrap the remaining services in checks if autoconfigure/disable_checks is used * move definition of AUTOCONFIGURE variable into base image * add logic to kapps and kdav container * add autoconfigure to konnect container * update build stage to latest golang * add autoconfig to remaining images * delete obsolete apache config in z-push folder * when specifying config paths use KOPANO_CONFIG_PATH * also use env variable in helper scripts * add message about removal of kopano-cli
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/kopano-autorespond -C /tmp/kopano/autorespond.cfg "$@"
|
||||
/usr/sbin/kopano-autorespond -C "$KOPANO_CONFIG_PATH/autorespond.cfg" "$@"
|
||||
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/kopano-cli --config /tmp/kopano/admin.cfg "$@"
|
||||
if [ ! -f /usr/sbin/kopano-cli ]; then
|
||||
echo "kopano-cli has been removed from Kopano Groupware Core 10 and upwards. Please use kopano-admin instead."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/usr/sbin/kopano-cli --config "$KOPANO_CONFIG_PATH/admin.cfg" "$@"
|
||||
|
||||
+147
-123
@@ -4,6 +4,7 @@ set -eu # unset variables are errors & non-zero return values exit the whole scr
|
||||
[ "$DEBUG" ] && set -x
|
||||
|
||||
ADDITIONAL_KOPANO_PACKAGES=${ADDITIONAL_KOPANO_PACKAGES:-""}
|
||||
AUTOCONFIGURE=${AUTOCONFIGURE:-true} # when set to false will disable all automatic configuration actions
|
||||
KCCONF_SERVER_MYSQL_SOCKET=${KCCONF_SERVER_MYSQL_SOCKET:-""}
|
||||
DISABLE_CHECKS=${DISABLE_CHECKS:-false}
|
||||
DISABLE_CONFIG_CHANGES=${DISABLE_CONFIG_CHANGES:-false}
|
||||
@@ -16,47 +17,50 @@ KCCONF_SPOOLER_SERVER_SOCKET=${KCCONF_SPOOLER_SERVER_SOCKET:-"file:///var/run/ko
|
||||
KOPANO_CON=${KOPANO_CON:-"file:///var/run/kopano/server.sock"}
|
||||
KCCONF_SPOOLER_SMTP_SERVER=${KCCONF_SPOOLER_SMTP_SERVER:-mail}
|
||||
KCCONF_SPOOLER_SMTP_PORT=${KCCONF_SPOOLER_SMTP_PORT:-25}
|
||||
KOPANO_CONFIG_PATH=${KOPANO_CONFIG_PATH:-/tmp/kopano}
|
||||
|
||||
# copy configuration files to /tmp/kopano to prevent modification of mounted config files
|
||||
mkdir -p /tmp/kopano
|
||||
cp /etc/kopano/*.cfg /tmp/kopano
|
||||
if [ "${AUTOCONFIGURE}" == true ]; then
|
||||
# copy configuration files to /tmp/kopano (default value of $KOPANO_CONFIG_PATH) 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
|
||||
if [ ! -e /kopano/"$SERVICE_TO_START".py ]; then
|
||||
echo "Invalid service specified: $SERVICE_TO_START" | ts
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Hint: this is not compatible with a read-only container.
|
||||
# The general recommendation is to already build a container that has all required packages installed.
|
||||
ADDITIONAL_KOPANO_PACKAGES=$(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"')
|
||||
if [ -n "$(mkdir -p "/var/lib/apt/lists/" 2&> /dev/null)" ]; then
|
||||
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update
|
||||
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do
|
||||
# shellcheck disable=SC2016 disable=SC2086
|
||||
if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then
|
||||
DEBIAN_FRONTEND=noninteractive apt --assume-yes --no-upgrade install "$installpkg"
|
||||
else
|
||||
echo "INFO: $installpkg is already installed"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Notice: Container is run read-only, skipping package installation."
|
||||
echo "If you want to have additional packages installed in the container either:"
|
||||
echo "- build your own image with the packages already included"
|
||||
echo "- switch the container to 'read_only: false'"
|
||||
fi
|
||||
|
||||
mkdir -p /tmp/"$SERVICE_TO_START" /var/run/kopano
|
||||
|
||||
# TODO is this still required now that we won't modify configuration mounted to /etc/kopano?
|
||||
if [ "${DISABLE_CONFIG_CHANGES}" == false ]; then
|
||||
echo "Configure core service '$SERVICE_TO_START'" | ts
|
||||
/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
|
||||
fi
|
||||
|
||||
# Hint: this is not compatible with a read-only container.
|
||||
# The general recommendation is to already build a container that has all required packages installed.
|
||||
ADDITIONAL_KOPANO_PACKAGES=$(echo "$ADDITIONAL_KOPANO_PACKAGES" | tr -d '"')
|
||||
if [ -n "$(mkdir -p "/var/lib/apt/lists/" 2&> /dev/null)" ]; then
|
||||
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && apt update
|
||||
[ -n "${ADDITIONAL_KOPANO_PACKAGES// }" ] && for installpkg in $ADDITIONAL_KOPANO_PACKAGES; do
|
||||
# shellcheck disable=SC2016 disable=SC2086
|
||||
if [ "$(dpkg-query -W -f='${Status}' $installpkg 2>/dev/null | grep -c 'ok installed')" -eq 0 ]; then
|
||||
DEBIAN_FRONTEND=noninteractive apt --assume-yes --no-upgrade install "$installpkg"
|
||||
else
|
||||
echo "INFO: $installpkg is already installed"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Notice: Container is run read-only, skipping package installation."
|
||||
echo "If you want to have additional packages installed in the container either:"
|
||||
echo "- build your own image with the packages already included"
|
||||
echo "- switch the container to 'read_only: false'"
|
||||
fi
|
||||
|
||||
mkdir -p /tmp/"$SERVICE_TO_START" /var/run/kopano
|
||||
|
||||
# TODO is this still required now that we won't modify configuration mounted to /etc/kopano?
|
||||
if [ "${DISABLE_CONFIG_CHANGES}" == false ]; then
|
||||
echo "Configure core service '$SERVICE_TO_START'" | ts
|
||||
/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
|
||||
|
||||
coreversion=$(dpkg-query --showformat='${Version}' --show kopano-server)
|
||||
echo "Using Kopano Groupware Core: $coreversion"
|
||||
|
||||
@@ -67,7 +71,7 @@ if [ $# -gt 0 ]; then
|
||||
fi
|
||||
|
||||
# services need to be aware of the machine-id
|
||||
if [[ "$DISABLE_CHECKS" == false ]]; then
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait file:///etc/machine-id \
|
||||
-wait file:///var/lib/dbus/machine-id
|
||||
@@ -119,78 +123,88 @@ fi
|
||||
# start regular service
|
||||
case "$SERVICE_TO_START" in
|
||||
server)
|
||||
echo "Set ownership" | ts
|
||||
mkdir -p /kopano/data/attachments
|
||||
chown kopano:kopano /kopano/data/ /kopano/data/attachments
|
||||
|
||||
if [[ "$DISABLE_CHECKS" == false ]]; then
|
||||
# determine db connection mode (unix vs. network socket)
|
||||
if [ -n "$KCCONF_SERVER_MYSQL_SOCKET" ]; then
|
||||
DB_CON="file://$KCCONF_SERVER_MYSQL_SOCKET"
|
||||
else
|
||||
DB_CON="tcp://$KCCONF_SERVER_MYSQL_HOST:$KCCONF_SERVER_MYSQL_PORT"
|
||||
fi
|
||||
if [ "${AUTOCONFIGURE}" == true ]; then
|
||||
echo "Set ownership" | ts
|
||||
mkdir -p /kopano/data/attachments
|
||||
chown kopano:kopano /kopano/data/ /kopano/data/attachments
|
||||
|
||||
dockerize \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_CA_FILE" \
|
||||
-wait file://"$KCCONF_SERVER_SERVER_SSL_KEY_FILE" \
|
||||
-wait "$DB_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# pre populate database
|
||||
if dpkg --compare-versions "$coreversion" "gt" "8.7.84"; then
|
||||
kopano-dbadm -c /tmp/kopano/server.cfg populate
|
||||
if [[ "$DISABLE_CHECKS" == false ]]; then
|
||||
# determine db connection mode (unix vs. network socket)
|
||||
if [ -n "$KCCONF_SERVER_MYSQL_SOCKET" ]; then
|
||||
DB_CON="file://$KCCONF_SERVER_MYSQL_SOCKET"
|
||||
else
|
||||
DB_CON="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_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# pre populate database
|
||||
if dpkg --compare-versions "$coreversion" "gt" "8.7.84"; then
|
||||
kopano-dbadm -c "$KOPANO_CONFIG_PATH/server.cfg" populate
|
||||
fi
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -F
|
||||
;;
|
||||
dagent)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -l
|
||||
;;
|
||||
gateway)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -F
|
||||
;;
|
||||
ical)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -F
|
||||
;;
|
||||
grapi)
|
||||
LC_CTYPE=en_US.UTF-8
|
||||
export socket_path=/var/run/kopano/grapi
|
||||
export pid_file="$socket_path/grapi.pid"
|
||||
mkdir -p "$socket_path" /var/lib/kopano-grapi
|
||||
chown -R kapi:kopano "$socket_path"
|
||||
chown kapi:kopano /var/lib/kopano-grapi
|
||||
# TODO there could be a case where multiple backends are desired
|
||||
case $GRAPI_BACKEND in
|
||||
ldap)
|
||||
[ -n "$KCCONF_GRAPI_LDAP_URI" ] && export LDAP_URI="${KCCONF_GRAPI_LDAP_URI}"
|
||||
[ -n "$KCCONF_GRAPI_LDAP_BASEDN" ] && export LDAP_BASEDN="${KCCONF_GRAPI_LDAP_BASEDN}"
|
||||
[ -n "$KCCONF_GRAPI_LDAP_BINDDN" ] && export LDAP_BINDDN="${KCCONF_GRAPI_LDAP_BINDDN}"
|
||||
if [ -n "$KCCONF_GRAPI_LDAP_BINDPW_FILE" ]; then
|
||||
bindpw="$(cat "${KCCONF_GRAPI_LDAP_BINDPW_FILE}")"
|
||||
export LDAP_BINDPW="${bindpw}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
sed s/\ *=\ */=/g /tmp/kopano/grapi.cfg > /tmp/grapi-env
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -v '^#' /tmp/grapi-env | xargs -d '\n')
|
||||
if [ "${AUTOCONFIGURE}" == true ]; then
|
||||
LC_CTYPE=en_US.UTF-8
|
||||
export socket_path=/var/run/kopano/grapi
|
||||
export pid_file="$socket_path/grapi.pid"
|
||||
mkdir -p "$socket_path" /var/lib/kopano-grapi
|
||||
chown -R kapi:kopano "$socket_path"
|
||||
chown kapi:kopano /var/lib/kopano-grapi
|
||||
# TODO there could be a case where multiple backends are desired
|
||||
case $GRAPI_BACKEND in
|
||||
ldap)
|
||||
[ -n "$KCCONF_GRAPI_LDAP_URI" ] && export LDAP_URI="${KCCONF_GRAPI_LDAP_URI}"
|
||||
[ -n "$KCCONF_GRAPI_LDAP_BASEDN" ] && export LDAP_BASEDN="${KCCONF_GRAPI_LDAP_BASEDN}"
|
||||
[ -n "$KCCONF_GRAPI_LDAP_BINDDN" ] && export LDAP_BINDDN="${KCCONF_GRAPI_LDAP_BINDDN}"
|
||||
if [ -n "$KCCONF_GRAPI_LDAP_BINDPW_FILE" ]; then
|
||||
bindpw="$(cat "${KCCONF_GRAPI_LDAP_BINDPW_FILE}")"
|
||||
export LDAP_BINDPW="${bindpw}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
sed s/\ *=\ */=/g "$KOPANO_CONFIG_PATH/grapi.cfg" > /tmp/grapi-env
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -v '^#' /tmp/grapi-env | xargs -d '\n')
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
# the backend option is only available in more recent versions of grapi
|
||||
@@ -203,65 +217,75 @@ grapi)
|
||||
fi
|
||||
;;
|
||||
kapi)
|
||||
mkdir -p /kopano/data/kapi-kvs
|
||||
if [ "$KCCONF_KAPID_INSECURE" = "yes" ]; then
|
||||
dockerize \
|
||||
-skip-tls-verify \
|
||||
-wait "$KCCONF_KAPID_OIDC_ISSUER_IDENTIFIER"/.well-known/openid-configuration \
|
||||
-timeout 360s
|
||||
else
|
||||
dockerize \
|
||||
-wait "$KCCONF_KAPID_OIDC_ISSUER_IDENTIFIER"/.well-known/openid-configuration \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ]; then
|
||||
mkdir -p /kopano/data/kapi-kvs
|
||||
if [ "$KCCONF_KAPID_INSECURE" = "yes" ]; then
|
||||
dockerize \
|
||||
-skip-tls-verify \
|
||||
-wait "$KCCONF_KAPID_OIDC_ISSUER_IDENTIFIER"/.well-known/openid-configuration \
|
||||
-timeout 360s
|
||||
else
|
||||
dockerize \
|
||||
-wait "$KCCONF_KAPID_OIDC_ISSUER_IDENTIFIER"/.well-known/openid-configuration \
|
||||
-timeout 360s
|
||||
fi
|
||||
LC_CTYPE=en_US.UTF-8
|
||||
sed s/\ *=\ */=/g "$KOPANO_CONFIG_PATH/kapid.cfg" > /tmp/kapid-env
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -v '^#' /tmp/kapid-env | xargs -d '\n')
|
||||
"$EXE" setup
|
||||
fi
|
||||
kapiversion=$(dpkg-query --showformat='${Version}' --show kopano-kapid)
|
||||
echo "Using Kopano Kapi: $kapiversion"
|
||||
LC_CTYPE=en_US.UTF-8
|
||||
sed s/\ *=\ */=/g /tmp/kopano/kapid.cfg > /tmp/kapid-env
|
||||
# shellcheck disable=SC2046
|
||||
export $(grep -v '^#' /tmp/kapid-env | xargs -d '\n')
|
||||
"$EXE" setup
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
kapiversion=$(dpkg-query --showformat='${Version}' --show kopano-kapid)
|
||||
echo "Using Kopano Kapi: $kapiversion"
|
||||
exec "$EXE" serve --log-timestamp=false
|
||||
;;
|
||||
monitor)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -F
|
||||
;;
|
||||
search)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
# give kopano-server a moment to settler before starting search
|
||||
sleep 5
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
# give kopano-server a moment to settler before starting search
|
||||
sleep 5
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
# with commit 702bb3fccb3 search does not need -F any longer
|
||||
searchversion=$(dpkg-query --showformat='${Version}' --show kopano-search)
|
||||
if dpkg --compare-versions "$searchversion" "gt" "8.7.82.165"; then
|
||||
exec "$EXE" --config /tmp/kopano/search.cfg
|
||||
exec "$EXE" --config "$KOPANO_CONFIG_PATH/search.cfg"
|
||||
else
|
||||
exec /usr/bin/python3 "$EXE" --config /tmp/kopano/search.cfg -F
|
||||
exec /usr/bin/python3 "$EXE" --config "$KOPANO_CONFIG_PATH/search.cfg" -F
|
||||
fi
|
||||
;;
|
||||
spamd)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-timeout 360s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" --config /tmp/kopano/spamd.cfg -F
|
||||
exec "$EXE" --config "$KOPANO_CONFIG_PATH/spamd.cfg" -F
|
||||
;;
|
||||
spooler)
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-wait tcp://"$KCCONF_SPOOLER_SMTP_SERVER":"$KCCONF_SPOOLER_SMTP_PORT" \
|
||||
-timeout 1080s
|
||||
if [ "${AUTOCONFIGURE}" == true ] && [ "$DISABLE_CHECKS" == false ]; then
|
||||
dockerize \
|
||||
-wait "$KOPANO_CON" \
|
||||
-wait tcp://"$KCCONF_SPOOLER_SMTP_SERVER":"$KCCONF_SPOOLER_SMTP_PORT" \
|
||||
-timeout 1080s
|
||||
fi
|
||||
# cleaning up env variables
|
||||
unset "${!KCCONF_@}"
|
||||
exec "$EXE" -F
|
||||
|
||||
Reference in New Issue
Block a user