From 22e3aae21424b2a8afc3be1956aee40970b2081a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sat, 11 Nov 2017 13:17:49 +0100 Subject: [PATCH] Upgrade to 0.25.0 --- conf/armv7.src | 2 +- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/install | 1 + scripts/psql.sh | 17 +++++++++++++++++ scripts/restore | 1 + scripts/upgrade | 2 +- sources/synapse_port_db | 34 ++++++++++++++++++++++++++-------- 8 files changed, 49 insertions(+), 12 deletions(-) diff --git a/conf/armv7.src b/conf/armv7.src index 8add7f3..3d5b884 100644 --- a/conf/armv7.src +++ b/conf/armv7.src @@ -1,6 +1,6 @@ SOURCE_URL=https://github.com/Josue-T/synapse_python_build/releases/download/v__APP_VERSION__/matrix-synapse___APP_VERSION__-bin1_armv7l.tar.gz -SOURCE_SUM=20b6b3b195210aa778a017796a310b4327d8ecbd1b423214e83603aae319957c +SOURCE_SUM=e1a1790936d10624faf7bbb51b72924a76a6385fc4ed909629e371b4cdc240bf # (Optional) Program to check the integrity (sha256sum, md5sum...) # default: sha256 SOURCE_SUM_PRG=sha256sum diff --git a/manifest.json b/manifest.json index e9902c5..01b073c 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Instant messaging server who use matrix", "fr": "Un serveur de messagerie instantané basé sur matrix" }, - "version": "0.24.1", + "version": "0.25.0", "url": "http://matrix.org", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index d0e155d..1a8c9de 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,7 +16,7 @@ get_app_version_from_json() { APP_VERSION=$(get_app_version_from_json) install_dependances() { - ynh_install_app_dependencies coturn build-essential python2.7-dev libffi-dev python-pip python-setuptools sqlite3 libssl-dev python-virtualenv libxml2-dev libxslt1-dev python-lxml libjpeg-dev libpq-dev postgresql + ynh_install_app_dependencies coturn build-essential python2.7-dev libffi-dev python-pip python-setuptools sqlite3 libssl-dev python-virtualenv libxml2-dev libxslt1-dev python-lxml libjpeg-dev libpq-dev postgresql acl pip install --upgrade pip pip install --upgrade virtualenv } diff --git a/scripts/install b/scripts/install index a4069c7..926d0c6 100644 --- a/scripts/install +++ b/scripts/install @@ -56,6 +56,7 @@ install_dependances ynh_system_user_create $synapse_user /var/lib/matrix-synapse # Create postgresql database +ynh_psql_test_if_first_run ynh_psql_create_user $synapse_db_user $synapse_db_pwd ynh_psql_execute_as_root \ "CREATE DATABASE $synapse_db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $synapse_db_user;" diff --git a/scripts/psql.sh b/scripts/psql.sh index 81b44cb..46a3401 100644 --- a/scripts/psql.sh +++ b/scripts/psql.sh @@ -49,4 +49,21 @@ ynh_psql_drop_db() { # | arg: user - the user name to drop ynh_psql_drop_user() { sudo su -c "dropuser ${1}" - postgres +} + +ynh_psql_test_if_first_run() { + if [ -f /etc/yunohost/psql ]; + then + echo "PostgreSQL is already installed, no need to create master password" + else + local pgsql=$(ynh_string_random) + echo "$pgsql" >> /etc/yunohost/psql + systemctl start postgresql + sudo -u postgres psql -c "ALTER user postgres WITH PASSWORD '${pgsql}'" + # we can t use peer since YunoHost create users with nologin + sed -i '/local\s*all\s*all\s*peer/i \ + local all all password' /etc/postgresql/9.4/main/pg_hba.conf + systemctl enable postgresql + systemctl reload postgresql + fi } \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index fd9c16b..c64644e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,6 +47,7 @@ python $final_path/add_sso_conf.py set_certificat_access # Restore postgresql database +ynh_psql_test_if_first_run ynh_psql_create_user $synapse_db_user $synapse_db_pwd ynh_psql_execute_as_root \ "CREATE DATABASE $synapse_db_name diff --git a/scripts/upgrade b/scripts/upgrade index e8290dc..4c34756 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,7 +34,7 @@ ynh_abort_if_errors if [[ -z $synapse_old_version ]] then # To be sure that the migration is sucessfull we check that the old synapse version is compatible with the synapse_port_db script. - if [[ $(dpkg -l | grep -c -E "ii.*matrix-synapse.*0.23") != 1 ]] && [[ $(dpkg -l | grep -c -E "ii.*matrix-synapse.*0.24") != 1 ]] + if [[ $(dpkg -l | grep -c -E "ii.*matrix-synapse.*0.25") != 1 ]] && [[ $(dpkg -l | grep -c -E "ii.*matrix-synapse.*0.24") != 1 ]] then systemctl start matrix-synapse.service ynh_die "Update from this synapse version is not available now. You need to wait for the next update." diff --git a/sources/synapse_port_db b/sources/synapse_port_db index a3979d3..a032e43 100644 --- a/sources/synapse_port_db +++ b/sources/synapse_port_db @@ -43,6 +43,13 @@ BOOLEAN_COLUMNS = { "device_lists_outbound_pokes": ["sent"], "users_who_share_rooms": ["share_private"], "groups": ["is_public"], + "group_rooms": ["is_public"], + "group_users": ["is_public", "is_admin"], + "group_summary_rooms": ["is_public"], + "group_room_categories": ["is_public"], + "group_summary_users": ["is_public"], + "group_roles": ["is_public"], + "local_group_membership": ["is_publicised", "is_admin"], } @@ -319,7 +326,7 @@ class Porter(object): backward_chunk = min(row[0] for row in brows) - 1 rows = frows + brows - self._convert_rows(table, headers, rows) + rows = self._convert_rows(table, headers, rows) def insert(txn): self.postgres_store.insert_many_txn( @@ -555,17 +562,29 @@ class Porter(object): i for i, h in enumerate(headers) if h in bool_col_names ] + class BadValueException(Exception): + pass + def conv(j, col): if j in bool_cols: return bool(col) + elif isinstance(col, basestring) and "\0" in col: + logger.warn("DROPPING ROW: NUL value in table %s col %s: %r", table, headers[j], col) + raise BadValueException(); return col + outrows = [] for i, row in enumerate(rows): - rows[i] = tuple( - conv(j, col) - for j, col in enumerate(row) - if j > 0 - ) + try: + outrows.append(tuple( + conv(j, col) + for j, col in enumerate(row) + if j > 0 + )) + except BadValueException: + pass + + return outrows @defer.inlineCallbacks def _setup_sent_transactions(self): @@ -593,7 +612,7 @@ class Porter(object): "select", r, ) - self._convert_rows("sent_transactions", headers, rows) + rows = self._convert_rows("sent_transactions", headers, rows) inserted_rows = len(rows) if inserted_rows: @@ -954,4 +973,3 @@ if __name__ == "__main__": if end_error_exec_info: exc_type, exc_value, exc_traceback = end_error_exec_info traceback.print_exception(exc_type, exc_value, exc_traceback) -