diff --git a/data/Dockerfiles/sogo/bootstrap-sogo.sh b/data/Dockerfiles/sogo/bootstrap-sogo.sh
index 3574a332..2a6f7090 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