mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
Transition to PostgreSQL (#377)
* backup script for PostgreSQL (#376)
Inspired from https://github.com/YunoHost-Apps/moodle_ynh/blob/master/scripts/backup
* Adapt to PostgreSQL (#375)
Question: in https://docs.mattermost.com/install/install-debian.html#install-postgresql-database-server, I see `BindsTo=postgresql.service` while in the original file here I find `Requires=mysql.service`. I don't know which one makes sense, so I keep the orinigal Yunohost version (Requires)
* config.json for PostgreSQL (#374)
Inspired from the original MySQL config.json and from Mattermost documentation https://docs.mattermost.com/install/install-debian.html#install-postgresql-database-server
* Install with PostgreSQL (#373)
I took inspiration from https://github.com/YunoHost-Apps/commento_ynh/blob/master/scripts/install
* install postgresql
* Reordering
* reset config file
* Update _common.sh
* Update config.json
* Fix
* Migration (#382)
* add migration
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Fix
* Fix
* Fix
* Update install
* Update upgrade
* Fix
* Update install
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update upgrade
* Update install
* Fix
* Fix
* Fix
* Update upgrade
* Cleaning up
* Update upgrade
* Update _common.sh
* Update check_process
* Update _common.sh
* Fix
* Update mysql-to-pg.conf
* Update upgrade
* Update systemd.service
* Cleaning
* Update _common.sh
* Fix
* Update upgrade
* Update _common.sh
* Update upgrade
* Update backup
* Fix
* Fix
* Update upgrade
* Update upgrade
* Update systemd.service
* Update _common.sh
* Revert "Update _common.sh"
This reverts commit d880150af9
.
* Cleaning
* Fix
* Update check_process
* Fix
* Update _common.sh
* Fix
* Update _common.sh
* Fix
* Update manifest.json
* Update install
* Update _common.sh
* Update upgrade
* Fix
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Update _common.sh
* Auto-update README
* Update _common.sh
* Upgrade to v7.4.0
* Auto-update README
* Upgrade to v7.5.2
* Auto-update README
* Update config.json
* [fix] mariadb to postgres migration
* Auto-update README
* [fix] Update manifest requirements
* Update manifest.json
* Update config.json
* upgrade config to upstream
* Fix linter
* Update _common.sh
* Fix typo
* Auto-update README
* Update upgrade
* Update scripts/upgrade
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
* [enh] Indentation
* Apply suggestions from code review
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
* [enh] COmments
* Increase timeout for table creation
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
* test upgrade from 7.2.0
* Auto-update README
* fix db_name in case of multi_instance
* Fix 7.3.0 migration
* delete only the problematic value in db_migrations
* Added explanation for migration management from 7.3.0
* mariadb-to-pg: drop stray columns
These should have been removed in a previous migration, but weren't.
See https://github.com/mattermost/mattermost-server/issues/18351#issuecomment-1325648058
* mariadb-to-pg: increase mattermost timeout
On a small VPS the 2 mn timeout is almost reached.
Increase it to 3 mn.
---------
Co-authored-by: biva <biva@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: ljf <ljf+git@grimaud.me>
Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
Co-authored-by: Kay0u <pierre@kayou.io>
This commit is contained in:
parent
4d3df957f6
commit
ec8fa5570a
19 changed files with 220 additions and 64 deletions
|
@ -25,7 +25,6 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t
|
|||
## Features include:
|
||||
|
||||
- One-to-one and group messaging, file sharing, and unlimited search history
|
||||
- Native apps for iOS, Android, Windows, Mac, Linux
|
||||
- Threaded messaging, emoji, and custom emoji
|
||||
- Tools for custom branding
|
||||
- Continuous archiving
|
||||
|
@ -35,10 +34,9 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t
|
|||
- Easily scalable to dozens of users per team
|
||||
- Runtime profiling data and system monitoring reports
|
||||
- New features and improvements released regularly
|
||||
- Multiple languages including U.S. English, Australian English, Bulgarian, Chinese (Simplified and Traditional), Dutch, French, German, Hungarian, Italian, Japanese, Korean, Polish, Brazilian Portuguese, Romanian, Russian, Turkish, Spanish, Swedish, and Ukrainian
|
||||
|
||||
|
||||
**Shipped version:** 7.3.0~ynh1
|
||||
**Shipped version:** 7.5.2~ynh1
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
@ -49,7 +47,7 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t
|
|||
## Configuration
|
||||
|
||||
* How to configure this app: From an admin panel, a plain file with SSH.
|
||||
* How to change from edition version to another (Team<->Enterprise) : Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant : Team or Enterprise. Update your apps and verify the *About* on your mattermost
|
||||
* How to change from edition version to another (Team<->Enterprise): Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant: Team or Enterprise. Update your apps and verify the *About* on your Mattermost
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou
|
|||
## Les fonctionnalités incluent:
|
||||
|
||||
- Messagerie individuelle et de groupe, partage de fichiers et historique de recherche illimité
|
||||
- Applications natives pour iOS, Android, Windows, Mac, Linux
|
||||
- Messagerie, emoji et emoji personnalisés
|
||||
- Outils pour une image de marque personnalisée
|
||||
- Archivage continu
|
||||
|
@ -35,10 +34,9 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou
|
|||
- Facilement évolutif à des dizaines d'utilisateurs par équipe
|
||||
- Données de profilage d'exécution et rapports de surveillance du système
|
||||
- Nouvelles fonctionnalités et améliorations publiées régulièrement
|
||||
- Plusieurs langues dont l'anglais américain, l'anglais australien, le bulgare, le chinois (simplifié et traditionnel), le néerlandais, le français, l'allemand, le hongrois, l'italien, le japonais, le coréen, le polonais, le portugais brésilien, le roumain, le russe, le turc, l'espagnol, le suédois et l'ukrainien
|
||||
|
||||
|
||||
**Version incluse :** 7.3.0~ynh1
|
||||
**Version incluse :** 7.5.2~ynh1
|
||||
|
||||
## Captures d’écran
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=4fa3ee4ad82a6154f2eb858a3da285a35afecef8
|
||||
# 7.2.0
|
||||
upgrade=1 from_commit=738ba505f581ddd72889c889dcb34406250fea35
|
||||
# 7.3.0
|
||||
upgrade=1 from_commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
|
@ -43,11 +46,16 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=4fa3ee4ad82a6154f2eb858a3da285a35afecef8
|
||||
# 7.2.0
|
||||
upgrade=1 from_commit=738ba505f581ddd72889c889dcb34406250fea35
|
||||
# 7.3.0
|
||||
upgrade=1 from_commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df
|
||||
;;; Options
|
||||
Email=kemenaran@gmail.com
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=4fa3ee4ad82a6154f2eb858a3da285a35afecef8
|
||||
name= Merge pull request #268 from YunoHost-Apps/testing
|
||||
; commit=738ba505f581ddd72889c889dcb34406250fea35
|
||||
name=7.2.0
|
||||
; commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df
|
||||
name=7.3.0
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://releases.mattermost.com/7.3.0/mattermost-team-7.3.0-linux-amd64.tar.gz
|
||||
SOURCE_SUM=47602e67b457a4871fd459f32a67f44e3353e4152989157eced2ad3bff5f634b
|
||||
SOURCE_URL=https://releases.mattermost.com/7.5.2/mattermost-team-7.5.2-linux-amd64.tar.gz
|
||||
SOURCE_SUM=b2162bc12b0b8763809f0795f429bc59018c712b14461db63158b453710fa885
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.3.0/mattermost-v7.3.0-linux-arm64.tar.gz
|
||||
SOURCE_SUM=9ea92cee34bf8209ce8e9a1fb186541a4784dd6ee63c93f6d9d0e3af078cd2aa
|
||||
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.5.2/mattermost-v7.5.2-linux-arm64.tar.gz
|
||||
SOURCE_SUM=85fac79f33d83b7f95b2532a055bbebecb28c60d6c1d955d9613de698d69b29e
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.3.0/mattermost-v7.3.0-linux-arm.tar.gz
|
||||
SOURCE_SUM=742314c0e9cb2f26d444c658c72794bd506a00c79066f7d908e9058ed48cdaa4
|
||||
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.5.2/mattermost-v7.5.2-linux-arm.tar.gz
|
||||
SOURCE_SUM=b26a4b676ee92ac848fa2993aa67559238ba7d8c1d0e6f7ffdd79ad8fb4942f3
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
"ExperimentalEnableDefaultChannelLeaveJoinMessages": true,
|
||||
"ExperimentalGroupUnreadChannels": "disabled",
|
||||
"EnableAPITeamDeletion": false,
|
||||
"EnableAPITriggerAdminNotifications": false,
|
||||
"EnableAPIUserDeletion": false,
|
||||
"ExperimentalEnableHardenedMode": false,
|
||||
"ExperimentalStrictCSRFEnforcement": false,
|
||||
|
@ -88,6 +89,7 @@
|
|||
"EnableSVGs": false,
|
||||
"EnableLatex": false,
|
||||
"EnableInlineLatex": true,
|
||||
"PostPriority": false,
|
||||
"EnableAPIChannelDeletion": false,
|
||||
"EnableLocalMode": true,
|
||||
"LocalModeSocketLocation": "/var/run/__APP__/mattermost_local.socket",
|
||||
|
@ -112,6 +114,7 @@
|
|||
"CustomBrandText": "",
|
||||
"CustomDescriptionText": "",
|
||||
"RestrictDirectMessage": "any",
|
||||
"EnableLastActiveTime": true,
|
||||
"UserStatusAwayTimeout": 300,
|
||||
"MaxChannelsPerTeam": 2000,
|
||||
"MaxNotificationsPerChannel": 1000,
|
||||
|
@ -130,8 +133,8 @@
|
|||
"IosMinVersion": ""
|
||||
},
|
||||
"SqlSettings": {
|
||||
"DriverName": "mysql",
|
||||
"DataSource": "__DB_USER__:__DB_PWD__@tcp(localhost:3306)/__DB_NAME__?charset=utf8mb4,utf8",
|
||||
"DriverName": "postgres",
|
||||
"DataSource": "postgres://__DB_USER__:__DB_PWD__@127.0.0.1:5432/__DB_NAME__?sslmode=disable&connect_timeout=10",
|
||||
"DataSourceReplicas": [],
|
||||
"DataSourceSearchReplicas": [],
|
||||
"MaxIdleConns": 20,
|
||||
|
@ -456,7 +459,6 @@
|
|||
"LinkMetadataTimeoutMilliseconds": 5000,
|
||||
"RestrictSystemAdmin": false,
|
||||
"UseNewSAMLLibrary": false,
|
||||
"CloudBilling": false,
|
||||
"EnableSharedChannels": false,
|
||||
"EnableRemoteClusterService": false,
|
||||
"EnableAppBar": false
|
||||
|
@ -525,6 +527,9 @@
|
|||
"CleanupJobsThresholdDays": -1,
|
||||
"CleanupConfigThresholdDays": -1
|
||||
},
|
||||
"ProductSettings": {
|
||||
"EnablePublicSharedBoards": false
|
||||
},
|
||||
"PluginSettings": {
|
||||
"Enable": true,
|
||||
"EnableUploads": false,
|
||||
|
@ -602,9 +607,9 @@
|
|||
"GraphQL": false,
|
||||
"InsightsEnabled": true,
|
||||
"CommandPalette": false,
|
||||
"AdvancedTextEditor": true,
|
||||
"BoardsProduct": false,
|
||||
"PlanUpgradeButtonText": "upgrade"
|
||||
"SendWelcomePost": true,
|
||||
"PostPriority": false
|
||||
},
|
||||
"ImportSettings": {
|
||||
"Directory": "./import",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://releases.mattermost.com/7.3.0/mattermost-enterprise-7.3.0-linux-amd64.tar.gz
|
||||
SOURCE_SUM=7c88dab1a68010c3cb6b1a3ce8c7c04aa4e9ff45b3cd30ca24008a5ae59bcbf0
|
||||
SOURCE_URL=https://releases.mattermost.com/7.5.2/mattermost-enterprise-7.5.2-linux-amd64.tar.gz
|
||||
SOURCE_SUM=66fce67ba3a0fcb2ec4f85f2143010b1c3603be8c2c30cc30f2b583a8e2a3345
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
[Unit]
|
||||
Description=Mattermost
|
||||
After=network.target
|
||||
After=mysql.service
|
||||
Requires=mysql.service
|
||||
Requires=postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
ExecStart=__FINALPATH__/bin/mattermost
|
||||
TimeoutStartSec=3600
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
WorkingDirectory=__FINALPATH__
|
||||
RuntimeDirectory=__APP__
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
LimitNOFILE=49152
|
||||
|
||||
# Sandboxing options to harden security
|
||||
|
|
|
@ -7,7 +7,6 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t
|
|||
## Features include:
|
||||
|
||||
- One-to-one and group messaging, file sharing, and unlimited search history
|
||||
- Native apps for iOS, Android, Windows, Mac, Linux
|
||||
- Threaded messaging, emoji, and custom emoji
|
||||
- Tools for custom branding
|
||||
- Continuous archiving
|
||||
|
@ -17,4 +16,3 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t
|
|||
- Easily scalable to dozens of users per team
|
||||
- Runtime profiling data and system monitoring reports
|
||||
- New features and improvements released regularly
|
||||
- Multiple languages including U.S. English, Australian English, Bulgarian, Chinese (Simplified and Traditional), Dutch, French, German, Hungarian, Italian, Japanese, Korean, Polish, Brazilian Portuguese, Romanian, Russian, Turkish, Spanish, Swedish, and Ukrainian
|
||||
|
|
|
@ -7,7 +7,6 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou
|
|||
## Les fonctionnalités incluent:
|
||||
|
||||
- Messagerie individuelle et de groupe, partage de fichiers et historique de recherche illimité
|
||||
- Applications natives pour iOS, Android, Windows, Mac, Linux
|
||||
- Messagerie, emoji et emoji personnalisés
|
||||
- Outils pour une image de marque personnalisée
|
||||
- Archivage continu
|
||||
|
@ -17,4 +16,3 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou
|
|||
- Facilement évolutif à des dizaines d'utilisateurs par équipe
|
||||
- Données de profilage d'exécution et rapports de surveillance du système
|
||||
- Nouvelles fonctionnalités et améliorations publiées régulièrement
|
||||
- Plusieurs langues dont l'anglais américain, l'anglais australien, le bulgare, le chinois (simplifié et traditionnel), le néerlandais, le français, l'allemand, le hongrois, l'italien, le japonais, le coréen, le polonais, le portugais brésilien, le roumain, le russe, le turc, l'espagnol, le suédois et l'ukrainien
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Configuration
|
||||
|
||||
* How to configure this app: From an admin panel, a plain file with SSH.
|
||||
* How to change from edition version to another (Team<->Enterprise) : Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant : Team or Enterprise. Update your apps and verify the *About* on your mattermost
|
||||
* How to change from edition version to another (Team<->Enterprise): Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant: Team or Enterprise. Update your apps and verify the *About* on your Mattermost
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Open source collaboration platform built for developers",
|
||||
"fr": "Plateforme de collaboration open source conçue pour les développeurs"
|
||||
},
|
||||
"version": "7.3.0~ynh1",
|
||||
"version": "7.5.2~ynh1",
|
||||
"url": "http://www.mattermost.org/",
|
||||
"upstream": {
|
||||
"license": "GPL-3.0-only",
|
||||
|
@ -27,7 +27,7 @@
|
|||
"mysql"
|
||||
],
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
"yunohost": ">= 11.1.6"
|
||||
},
|
||||
"arguments": {
|
||||
"install": [
|
||||
|
@ -39,7 +39,7 @@
|
|||
"name": "path",
|
||||
"type": "path",
|
||||
"example": "/mattermost",
|
||||
"default": "/chat"
|
||||
"default": "/mattermost"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
|
|
|
@ -4,10 +4,89 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="postgresql postgresql-contrib pgloader"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
mariadb-to-pg() {
|
||||
|
||||
ynh_print_info --message="Migrating to PostgreSQL database..."
|
||||
|
||||
mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
|
||||
# In old instance db_user is `mmuser`
|
||||
mysql_db_user="$db_user"
|
||||
if ynh_mysql_connect_as --user="mmuser" --password="$mysqlpwd" 2> /dev/null <<< ";"; then
|
||||
mysql_db_user="mmuser"
|
||||
fi
|
||||
|
||||
# Initialize PostgreSQL database
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$mysqlpwd
|
||||
psqlpwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
# Configure the new database and run Mattermost in order to create tables
|
||||
ynh_write_var_in_file --file="$final_path/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings"
|
||||
ynh_write_var_in_file --file="$final_path/config/config.json" --key="DataSource" --value="postgres://$db_user:$psqlpwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings"
|
||||
cat "$final_path/config/config.json"
|
||||
pushd $final_path
|
||||
ynh_systemd_action --service_name="$app" --action="stop"
|
||||
set +e
|
||||
sudo -u mattermost timeout --preserve-status 180 "./bin/mattermost"
|
||||
if [ "$?" != "0" ] && [ "$?" != "143" ] ; then
|
||||
ynh_die --message="Failed to run Mattermost to create PostgreSQL database tables" --ret_code=1
|
||||
fi
|
||||
set -e
|
||||
popd
|
||||
|
||||
# Some fixes to let the MariaDB -> PostgreSQL conversion working
|
||||
ynh_psql_execute_as_root --sql='DROP INDEX public.idx_fileinfo_content_txt;' --database=$db_name
|
||||
ynh_psql_execute_as_root --sql='DROP INDEX public.idx_posts_message_txt;' --database=$db_name
|
||||
ynh_mysql_execute_as_root --sql="ALTER TABLE mattermost.Users DROP COLUMN IF EXISTS acceptedtermsofserviceid;" --database=$db_name
|
||||
ynh_mysql_execute_as_root --sql="ALTER TABLE mattermost.SharedChannelRemotes DROP COLUMN IF EXISTS description;" --database=$db_name
|
||||
ynh_mysql_execute_as_root --sql="ALTER TABLE mattermost.SharedChannelRemotes DROP COLUMN IF EXISTS nextsyncat;" --database=$db_name
|
||||
|
||||
# Use pgloader to migrate database content from MariaDB to PostgreSQL
|
||||
tmpdir="$(mktemp -d)"
|
||||
|
||||
cat <<EOT > $tmpdir/commands.load
|
||||
LOAD DATABASE
|
||||
FROM mysql://$mysql_db_user:$mysqlpwd@127.0.0.1:3306/$db_name
|
||||
INTO postgresql://$db_user:$psqlpwd@127.0.0.1:5432/$db_name
|
||||
|
||||
WITH include no drop, truncate, create no tables,
|
||||
create no indexes, preserve index names, no foreign keys,
|
||||
data only, workers = 16, concurrency = 1
|
||||
|
||||
SET MySQL PARAMETERS
|
||||
net_read_timeout = '90',
|
||||
net_write_timeout = '180'
|
||||
|
||||
ALTER SCHEMA '$db_name' RENAME TO 'public'
|
||||
|
||||
;
|
||||
EOT
|
||||
pgloader $tmpdir/commands.load
|
||||
|
||||
# Rebuild INDEX
|
||||
ynh_psql_execute_as_root --sql='CREATE INDEX idx_fileinfo_content_txt ON public.fileinfo USING gin (to_tsvector('\''english'\''::regconfig, content))' --database=$db_name
|
||||
ynh_psql_execute_as_root --sql='CREATE INDEX idx_posts_message_txt ON public.posts USING gin (to_tsvector('\''english'\''::regconfig, (message)::text));' --database=$db_name
|
||||
|
||||
|
||||
if ynh_compare_current_package_version --comparison eq --version 7.3.0~ynh1
|
||||
then
|
||||
# There is a problem with version 7.3.0 and the database migration.
|
||||
# More information here: https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194/6
|
||||
ynh_psql_execute_as_root --sql="DELETE FROM db_migrations WHERE version=92;" --database=$db_name
|
||||
fi
|
||||
# Remove the MariaDB database
|
||||
ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name
|
||||
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -66,9 +66,9 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
#=================================================
|
||||
# BACKUP THE DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_print_info --message="Backing up the database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -68,6 +68,13 @@ ynh_script_progression --message="Finding an available port..." --weight=3
|
|||
port=$(ynh_find_port --port=8065)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -77,14 +84,15 @@ ynh_script_progression --message="Configuring system user..." --weight=3
|
|||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
# CREATE A DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..." --weight=10
|
||||
ynh_script_progression --message="Creating a database..." --weight=10
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -141,6 +149,7 @@ ynh_script_progression --message="Modifying a config file..." --weight=3
|
|||
|
||||
smtp_user_pwd=$(ynh_string_random --length=24)
|
||||
url=https://$domain$path_url
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
ynh_add_config --template="../conf/config.json" --destination="$final_path/config/config.json"
|
||||
|
||||
|
|
|
@ -44,12 +44,28 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
|
|||
ynh_remove_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MySQL DATABASE
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the database..." --weight=2
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=3
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
|
@ -79,16 +95,11 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
|
|||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOG FILE
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..." --weight=1
|
||||
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ test ! -d $final_path \
|
|||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
|
@ -83,13 +84,22 @@ chmod -R o-rwx "$data_path"
|
|||
chown -R $app:www-data "$data_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=6
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
||||
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the database..." --weight=6
|
||||
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
|
|
|
@ -31,9 +31,14 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
version=$(ynh_app_setting_get --app=$app --key=version)
|
||||
data_path=$(ynh_app_setting_get --app=$app --key=data_path)
|
||||
team_display_name=$(ynh_app_setting_get --app=$app --key=team_display_name)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
email=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -97,6 +102,25 @@ if ynh_legacy_permissions_exists; then
|
|||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=10
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# MIGRATING DATABASE
|
||||
#=================================================
|
||||
|
||||
# Check if using MariaDB
|
||||
# This migration should be done before the upgrade
|
||||
if mysqlshow | grep -q "^| $db_name "; then
|
||||
# Mattermost only support MySQL and PostgreSQL (not MariaDB...)
|
||||
# Migrate the database from MariaDB to PostgreSQL
|
||||
mariadb-to-pg
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -166,6 +190,31 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# Fix old migrations
|
||||
#=================================================
|
||||
# Crazy fix for old unupgraded version
|
||||
# IMPORTANT: THIS fix should be done after setup new sources and running mattermost
|
||||
if ynh_compare_current_package_version --comparison lt --version 5.37.1~ynh1
|
||||
then
|
||||
read -r -d '' fix_old_version_sql << EOM
|
||||
ALTER TABLE ChannelMembers ALTER COLUMN mentioncountroot SET DEFAULT '0'::bigint;
|
||||
UPDATE ChannelMembers SET mentioncountroot=0 WHERE mentioncountroot IS NULL;
|
||||
ALTER TABLE ChannelMembers ALTER COLUMN msgcountroot SET DEFAULT '0'::bigint;
|
||||
UPDATE ChannelMembers SET msgcountroot=0 WHERE msgcountroot IS NULL;
|
||||
ALTER TABLE Channels ALTER COLUMN totalmsgcountroot SET DEFAULT '0'::bigint;
|
||||
UPDATE Channels SET totalmsgcountroot=0 WHERE totalmsgcountroot IS NULL;
|
||||
UPDATE SidebarCategories SET collapsed=False where collapsed IS NULL;
|
||||
UPDATE SidebarCategories SET muted=False where muted IS NULL;
|
||||
UPDATE SidebarCategories set sorting = 'manual' where sorting='';
|
||||
UPDATE SidebarCategories set sorting = 'manual' where sorting IS NULL;
|
||||
EOM
|
||||
ynh_psql_execute_as_root --sql="$fix_old_version_sql" --database=$db_name
|
||||
|
||||
# Note: it's possible that some instances need other fixes
|
||||
# If nothing is displayed in the sidebar it may be needed to change the Id of SidebarCategories...
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
@ -186,12 +235,6 @@ yunohost service add $app --description="Collaboration platform built for develo
|
|||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
|
||||
# A lengthy database migration runs when upgrading from a version < 6.0.
|
||||
if dpkg --compare-versions "$previous_upstream_version" lt "6.0.0"
|
||||
then
|
||||
ynh_print_warn --message="Lengthy database migrations will now run. This may take a while..."
|
||||
fi
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue