fix(preferences): Fix the issue when signature is too long and preferences are not saved. Note that MySQL profile table should be updated with a migration script

This commit is contained in:
smizrahi
2023-07-25 17:22:11 +02:00
parent ec27f7e714
commit 326bc68f4c
13 changed files with 95 additions and 9 deletions

View File

@@ -0,0 +1,26 @@
#!/bin/bash
set -euo pipefail
# This script only works with PostgreSQL and MySQL - it does:
#
# - increase the c_defaults column of user profile table to medium text
profiletype=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ SOGoProfileURL =/ {print $2}' | awk -F: '{ print $1 }')
if [ -z "$profiletype" ]; then
echo "Failed to obtain session table type" >&2
exit 1
fi
if [[ "$profiletype" == "mysql" ]]; then
profiletable=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ SOGoProfileURL =/ {print $2}' | awk -F/ '{print $NF}')
mysqlargs=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ SOGoProfileURL =/ {print $2}' | sed 's/mysql:\/\/\([^:]\+\):\([^@]\+\)@\([^\:]\+\):\([^\/]\+\)\/\([^\/]\+\).\+/-h \3 -P \4 -u \1 -p\2 \5/')
echo "Converting c_defaults from TEXT to MEDIUMTEXT in sessions table ($profiletable)"
mysql -v $mysqlargs -e "ALTER TABLE $profiletable MODIFY c_defaults MEDIUMTEXT;"
else
echo "Unsupported database type $profiletype"
exit 1
fi
exit 0