[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
master
André 2018-07-11 22:08:02 +02:00
parent 22cecc3f85
commit cfb0d3b62c
1 changed files with 29 additions and 3 deletions

View File

@ -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
<string>sql</string>
<key>userPasswordAlgorithm</key>
<string>ssha256</string>
<key>prependPasswordScheme</key>
<string>YES</string>
<key>viewURL</key>
<string>mysql://${DBUSER}:${DBPASS}@mysql:3306/${DBNAME}/sogo_view</string>
<string>mysql://${DBUSER}:${DBPASS}@mysql:3306/${DBNAME}/_sogo_static_view</string>
</dict>
</array>
</dict>" >> /var/lib/sogo/GNUstep/Defaults/sogod.plist