From cfb0d3b62caaa42154e459467361411ba3d0568e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= Date: Wed, 11 Jul 2018 22:08:02 +0200 Subject: [PATCH] [SOGo] Create a sogo_update_password trigger in SQL [SOGo] prependPasswordScheme=YES in user sources [SOGo] Use new "static view" as viewURL for much faster table lookups on large systems --- data/Dockerfiles/sogo/bootstrap-sogo.sh | 32 ++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/data/Dockerfiles/sogo/bootstrap-sogo.sh b/data/Dockerfiles/sogo/bootstrap-sogo.sh index 3574a3327..2a6f70908 100755 --- a/data/Dockerfiles/sogo/bootstrap-sogo.sh +++ b/data/Dockerfiles/sogo/bootstrap-sogo.sh @@ -9,8 +9,8 @@ done # Wait until port becomes free and send sig until ! nc -z sogo-mailcow 20000; do - killall -TERM sogod - sleep 3 + killall -TERM sogod + sleep 3 done # Recreate view @@ -34,6 +34,30 @@ EOF fi done +# Recreate password update trigger + +mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "DROP TRIGGER IF EXISTS sogo_update_password" + +while [[ ${TRIGGER_OK} != 'OK' ]]; do + mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} << EOF +DELIMITER - +CREATE TRIGGER sogo_update_password AFTER UPDATE ON _sogo_static_view +FOR EACH ROW +BEGIN +UPDATE mailbox SET password = NEW.c_password WHERE NEW.c_uid = username; +END; +- +DELIMITER ; +EOF + if [[ ! -z $(mysql --host mysql -u ${DBUSER} -p${DBPASS} ${DBNAME} -B -e "SELECT 'OK' FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME = 'sogo_update_password'") ]]; then + TRIGGER_OK=OK + else + echo "Will retry to setup SOGo password update trigger in 3s" + sleep 3 + fi +done + + mkdir -p /var/lib/sogo/GNUstep/Defaults/ # Generate plist header with timezone data @@ -97,8 +121,10 @@ while read line sql userPasswordAlgorithm ssha256 + prependPasswordScheme + YES viewURL - mysql://${DBUSER}:${DBPASS}@mysql:3306/${DBNAME}/sogo_view + mysql://${DBUSER}:${DBPASS}@mysql:3306/${DBNAME}/_sogo_static_view " >> /var/lib/sogo/GNUstep/Defaults/sogod.plist