From 4d212be973a73f24ef5ee047b76b1e3b8b9f91e4 Mon Sep 17 00:00:00 2001 From: eric_G <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 23 Aug 2024 08:04:56 +0200 Subject: [PATCH 1/2] Testing (#495) --- ALL_README.md | 1 + README.md | 2 +- README_es.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- README_id.md | 4 +-- README_ru.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++ README_zh_Hans.md | 2 +- conf/config.json | 2 ++ manifest.toml | 22 +++++++------- 11 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 README_ru.md diff --git a/ALL_README.md b/ALL_README.md index 4ed64dd..e3c80d2 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -6,4 +6,5 @@ - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) - [Baca README dalam bahasa bahasa Indonesia](README_id.md) +- [Прочитать README на русский](README_ru.md) - [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README.md b/README.md index c418897..01f9eff 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**Shipped version:** 9.10.0~ynh1 +**Shipped version:** 9.11.0~ynh1 ## Screenshots diff --git a/README_es.md b/README_es.md index 02129d0..28f577b 100644 --- a/README_es.md +++ b/README_es.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**Versión actual:** 9.10.0~ynh1 +**Versión actual:** 9.11.0~ynh1 ## Capturas diff --git a/README_eu.md b/README_eu.md index 2947c8d..bbb1c57 100644 --- a/README_eu.md +++ b/README_eu.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**Paketatutako bertsioa:** 9.10.0~ynh1 +**Paketatutako bertsioa:** 9.11.0~ynh1 ## Pantaila-argazkiak diff --git a/README_fr.md b/README_fr.md index 45fab4b..3c0adbc 100644 --- a/README_fr.md +++ b/README_fr.md @@ -42,7 +42,7 @@ Ce paquet peut installer la version [*Entreprise Edition*](https://docs.mattermo - Données de profilage d'exécution et rapports de surveillance du système -**Version incluse :** 9.10.0~ynh1 +**Version incluse :** 9.11.0~ynh1 ## Captures d’écran diff --git a/README_gl.md b/README_gl.md index bbdf3e1..54f6a7e 100644 --- a/README_gl.md +++ b/README_gl.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**Versión proporcionada:** 9.10.0~ynh1 +**Versión proporcionada:** 9.11.0~ynh1 ## Capturas de pantalla diff --git a/README_id.md b/README_id.md index 33e438d..865fd2b 100644 --- a/README_id.md +++ b/README_id.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**Versi terkirim:** 9.10.0~ynh1 +**Versi terkirim:** 9.11.0~ynh1 ## Tangkapan Layar @@ -54,7 +54,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Website aplikasi resmi: - Dokumentasi pengguna resmi: - Dokumentasi admin resmi: -- Repositori kode aplikasi hulu: +- Depot kode aplikasi hulu: - Gudang YunoHost: - Laporkan bug: diff --git a/README_ru.md b/README_ru.md new file mode 100644 index 0000000..d307c4d --- /dev/null +++ b/README_ru.md @@ -0,0 +1,73 @@ + + +# Mattermost для YunoHost + +[![Уровень интеграции](https://dash.yunohost.org/integration/mattermost.svg)](https://ci-apps.yunohost.org/ci/apps/mattermost/) ![Состояние работы](https://ci-apps.yunohost.org/ci/badges/mattermost.status.svg) ![Состояние сопровождения](https://ci-apps.yunohost.org/ci/badges/mattermost.maintain.svg) + +[![Установите Mattermost с YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mattermost) + +*[Прочтите этот README на других языках.](./ALL_README.md)* + +> *Этот пакет позволяет Вам установить Mattermost быстро и просто на YunoHost-сервер.* +> *Если у Вас нет YunoHost, пожалуйста, посмотрите [инструкцию](https://yunohost.org/install), чтобы узнать, как установить его.* + +## Обзор + +## Mattermost Team Edition + +A free-to-use, open source, self-hosted alternative to proprietary SaaS messaging. Team Edition is your open source “virtual office”, offering all the core productivity benefits of competing SaaS solutions. It deploys as a single Linux binary with PosgreSQL under an MIT license. + +## Mattermost Enterprise Edition + +To explore the benefits of Mattermost’s enterprise features, you can replace the Mattermost Team Edition binary with a Mattermost Enterprise Edition binary. This version supports upgrading to Mattermost Enterprise Edition E10 or E20. + +## YunoHost specific features + +This package can install the [*Entreprise Edition*](https://docs.mattermost.com/overview/product.html#mattermost-enterprise-edition) or the [*Team Edition*](https://docs.mattermost.com/overview/product.html#mattermost-team-edition). + +Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/) + +## Features include: + +- One-to-one and group messaging, file sharing, and unlimited search history +- Threaded messaging, emoji, and custom emoji +- Tools for custom branding +- Continuous archiving +- Multi-factor authentication +- Highly customizable third-party bots, integrations, and command line tools +- Extensive integration support via webhooks, APIs, drivers, and third-party extensions +- Easily scalable to dozens of users per team +- Runtime profiling data and system monitoring reports + + +**Поставляемая версия:** 9.11.0~ynh1 + +## Снимки экрана + +![Снимок экрана Mattermost](./doc/screenshots/screenshot.png) + +## Документация и ресурсы + +- Официальный веб-сайт приложения: +- Официальная документация пользователя: +- Официальная документация администратора: +- Репозиторий кода главной ветки приложения: +- Магазин YunoHost: +- Сообщите об ошибке: + +## Информация для разработчиков + +Пришлите Ваш запрос на слияние в [ветку `testing`](https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing). + +Чтобы попробовать ветку `testing`, пожалуйста, сделайте что-то вроде этого: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug +или +sudo yunohost app upgrade mattermost -u https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug +``` + +**Больше информации о пакетировании приложений:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index c080f09..a09f45a 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -43,7 +43,7 @@ Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/d - Runtime profiling data and system monitoring reports -**分发版本:** 9.10.0~ynh1 +**分发版本:** 9.11.0~ynh1 ## 截图 diff --git a/conf/config.json b/conf/config.json index 708188e..1f187cd 100644 --- a/conf/config.json +++ b/conf/config.json @@ -49,6 +49,7 @@ "CorsDebug": false, "AllowCookiesForSubdomains": false, "ExtendSessionLengthWithActivity": true, + "TerminateSessionsOnPasswordChange": true, "SessionLengthWebInDays": 30, "SessionLengthWebInHours": 720, "SessionLengthMobileInDays": 30, @@ -504,6 +505,7 @@ }, "ElasticsearchSettings": { "ConnectionURL": "http://localhost:9200", + "Backend": "elasticsearch", "Username": "elastic", "Password": "changeme", "EnableIndexing": false, diff --git a/manifest.toml b/manifest.toml index 0179c54..9d0617e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Mattermost" description.en = "Open source collaboration platform built for developers" description.fr = "Plateforme de collaboration open source conçue pour les développeurs" -version = "9.10.0~ynh1" +version = "9.11.0~ynh1" maintainers = ["pmorinerie"] @@ -76,18 +76,18 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - amd64.url = "https://releases.mattermost.com/9.10.0/mattermost-team-9.10.0-linux-amd64.tar.gz" - amd64.sha256 = "eb29b651831cc355222f88743678414e0e959f8bbdaa1bbeff72e5ddade1cdb0" - arm64.url = "https://releases.mattermost.com/9.10.0/mattermost-team-9.10.0-linux-arm64.tar.gz" - arm64.sha256 = "91db9cb5e939eac6e94e854257bd02145783a63cecb944484822a3e3334ef01d" - armhf.url = "https://github.com/remiheens/mattermost-docker-arm/releases/download/v9.9.0/mattermost-v9.9.0-linux-arm.tar.gz" - armhf.sha256 = "612b2a0bca1b1755291d5723dcf617be6d0848474b58727151d8cbf2d5431826" + amd64.url = "https://releases.mattermost.com/9.11.0/mattermost-team-9.11.0-linux-amd64.tar.gz" + amd64.sha256 = "7de2e2f560f2986e3c855e24944f44fc9b95560f7d841072b41b64c0975fd73e" + arm64.url = "https://releases.mattermost.com/9.11.0/mattermost-team-9.11.0-linux-arm64.tar.gz" + arm64.sha256 = "09058a26bb8a9707431b81a90053079df406a29c736ca055b6c82bb48db464dd" + armhf.url = "https://github.com/remiheens/mattermost-docker-arm/releases/download/v9.10.1/mattermost-v9.10.1-linux-arm.tar.gz" + armhf.sha256 = "4e9f00db76785720395173e2563eb91e536f37acf8091adec46a2bd9e18bbb3c" [resources.sources.enterprise] - amd64.url = "https://releases.mattermost.com/9.10.0/mattermost-enterprise-9.10.0-linux-amd64.tar.gz" - amd64.sha256 = "59db22a1640079b1ea1789ee0e232fc2a6a0433593946b32b47eb33832879d7c" - arm64.url = "https://releases.mattermost.com/9.10.0/mattermost-enterprise-9.10.0-linux-arm64.tar.gz" - arm64.sha256 = "d485b3d0a4bba5bd289dc889f7930a2ffe9d1b82414ece0c7f7551cb893978fd" + amd64.url = "https://releases.mattermost.com/9.11.0/mattermost-enterprise-9.11.0-linux-amd64.tar.gz" + amd64.sha256 = "293f2161586302f4a5baa9d9d88197f517426fc12a2ed23242e20a2647fef4da" + arm64.url = "https://releases.mattermost.com/9.11.0/mattermost-enterprise-9.11.0-linux-arm64.tar.gz" + arm64.sha256 = "7f80b7e7e8ad0c63b3bbaaa65835362ec1ac162dcab007133a0cef037991b76e" [resources.system_user] allow_email = true From 58f06b65ed96199cdc3e17806b126ad69cb16f14 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:04:29 +0200 Subject: [PATCH 2/2] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 3 +++ manifest.toml | 3 ++- scripts/_common.sh | 52 ++++++++++++++++++++-------------------------- scripts/backup | 21 ++++++++----------- scripts/change_url | 32 ++++++++++------------------ scripts/install | 44 +++++++++++++++++---------------------- scripts/remove | 27 ++++++++++-------------- scripts/restore | 37 +++++++++++++-------------------- scripts/upgrade | 50 ++++++++++++++++++++------------------------ 9 files changed, 114 insertions(+), 155 deletions(-) diff --git a/.gitignore b/.gitignore index 86a37fb..c55e18e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .vagrant +*~ +*.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index 9d0617e..7348632 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ userdoc = "https://docs.mattermost.com/guides/messaging.html" code = "https://github.com/mattermost/mattermost-server" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64", "armhf", "arm64"] multi_instance = true diff --git a/scripts/_common.sh b/scripts/_common.sh index 58454f3..40febbf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= # We want Mattermost emails to be sent from the main domain @@ -9,19 +9,15 @@ # and not the subdomain or secondary domain used for Mattermost. main_domain=$(cat /etc/yunohost/current_host) -#================================================= -# PERSONAL HELPERS -#================================================= - mariadb-to-pg() { - ynh_print_info --message="Migrating to PostgreSQL database..." + ynh_print_info "Migrating to PostgreSQL database..." # Retrieve MySQL user and password - mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + mysqlpwd=$(ynh_app_setting_get --key=mysqlpwd) mysql_db_user="$db_user" - if ynh_mysql_connect_as --user="mmuser" --password="$mysqlpwd" 2> /dev/null <<< ";"; then + if ynh_mysql_db_shell <<< ";"; then # On old instances db_user is `mmuser` mysql_db_user="mmuser" fi @@ -32,22 +28,26 @@ mariadb-to-pg() { ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DataSource" --value="postgres://$db_user:$db_pwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings" cat "$install_dir/config/config.json" pushd $install_dir - ynh_systemd_action --service_name="$app" --action="stop" + ynh_systemctl --service="$app" --action="stop" set +e - sudo -u $app timeout --preserve-status 300 "./bin/mattermost" + ynh_exec_as_app timeout --preserve-status 300 "./bin/mattermost" if [ "$?" != "0" ] && [ "$?" != "143" ] ; then - ynh_die --message="Failed to run Mattermost to create PostgreSQL database tables" --ret_code=1 + ynh_die "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 - + ynh_psql_db_shell <<< 'DROP INDEX public.idx_fileinfo_content_txt;' + + ynh_psql_db_shell <<< 'DROP INDEX public.idx_posts_message_txt;' + + ynh_mysql_db_shell <<< "ALTER TABLE mattermost.Users DROP COLUMN IF EXISTS acceptedtermsofserviceid;" + + ynh_mysql_db_shell <<< "ALTER TABLE mattermost.SharedChannelRemotes DROP COLUMN IF EXISTS description;" + + ynh_mysql_db_shell <<< "ALTER TABLE mattermost.SharedChannelRemotes DROP COLUMN IF EXISTS nextsyncat;" + # Focalboard is broken in Mattermost 7.3.0 if ynh_compare_current_package_version --comparison eq --version 7.3.0~ynh1 then @@ -81,24 +81,18 @@ 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 + ynh_psql_db_shell <<< 'CREATE INDEX idx_fileinfo_content_txt ON public.fileinfo USING gin (to_tsvector('\''english'\''::regconfig, content))' + + ynh_psql_db_shell <<< 'CREATE INDEX idx_posts_message_txt ON public.posts USING gin (to_tsvector('\''english'\''::regconfig, (message)::text));' 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 + ynh_psql_db_shell <<< "DELETE FROM db_migrations WHERE version=92;" + fi # Remove the MariaDB database - ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name + # FIXMEhelpers2.1 ynh_mysql_drop_db && ynh_mysql_drop_user --db_user=$mysql_db_user --db_name=$db_name } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 565f9ed..d086322 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,42 +6,39 @@ source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE APP DATA #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP THE DATABASE #================================================= -ynh_print_info --message="Backing up the database..." +ynh_print_info "Backing up the database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 06528f0..e699e2d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,55 +1,45 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=4 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" +ynh_systemctl --service=$app --action=stop --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # EDIT MATTERMOST CONFIG #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=3 +ynh_script_progression "Updating configuration..." # Main config File -ynh_replace_string --match_string="\"SiteURL\": \".*\"" --replace_string="\"SiteURL\": \"https://${new_domain}${new_path}\"" --target_file="$install_dir/config/config.json" -ynh_replace_string --match_string="\"FeedbackEmail\": \".*\"" --replace_string="\"FeedbackEmail\": \"no-reply@${new_domain}\"" --target_file="$install_dir/config/config.json" +ynh_replace --match="\"SiteURL\": \".*\"" --replace="\"SiteURL\": \"https://${new_domain}${new_path}\"" --file="$install_dir/config/config.json" +ynh_replace --match="\"FeedbackEmail\": \".*\"" --replace="\"FeedbackEmail\": \"no-reply@${new_domain}\"" --file="$install_dir/config/config.json" -ynh_store_file_checksum --file="$install_dir/config/config.json" +ynh_store_file_checksum "$install_dir/config/config.json" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="Started Mattermost" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 360eead..040e089 100644 --- a/scripts/install +++ b/scripts/install @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=3 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src @@ -24,52 +18,51 @@ elif [ "$version" = "Team" ]; then ynh_setup_source --dest_dir="$install_dir" --source_id="main" fi -chown -R $app:www-data "$install_dir" - +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # EDIT MATTERMOST CONFIG #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=3 +ynh_script_progression "Updating configuration..." smtp_user_pwd=$(ynh_string_random --length=24) url=https://$domain$path -ynh_add_config --template="config.json" --destination="$install_dir/config/config.json" +ynh_config_add --template="config.json" --destination="$install_dir/config/config.json" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log" # Create log directory mkdir -p /var/log/$app -chown $app -R "/var/log/$app" +#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app -R "/var/log/$app" # Setup logrotate -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="Started Mattermost" #================================================= # CREATE ADMIN AND FIRST TEAM #================================================= -ynh_script_progression --message="Create the first administrator and team..." --weight=1 +ynh_script_progression "Create the first administrator and team..." team_name=$(echo "$team_display_name" | iconv -f utf8 -t ascii//TRANSLIT//IGNORE | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z) bin_mmctl="$install_dir/bin/mmctl" @@ -78,16 +71,17 @@ email=$(ynh_user_get_info --username=$admin --key=mail) export MMCTL_LOCAL=true export MMCTL_LOCAL_SOCKET_PATH="/var/run/${app}/mattermost_local.socket" -ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin -ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team create --name "$team_name" --display_name "$team_display_name" --email "$email" -ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team users add "$team_name" "$admin" +ynh_hide_warnings sudo --preserve-env -u $app "$bin_mmctl" user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin +ynh_hide_warnings sudo --preserve-env -u $app "$bin_mmctl" team create --name "$team_name" --display_name "$team_display_name" --email "$email" +ynh_hide_warnings sudo --preserve-env -u $app "$bin_mmctl" team users add "$team_name" "$admin" # Disable mmctl passwordless access -ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$install_dir/config/config.json" -ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Started Mattermost" +# FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file= +ynh_replace '"EnableLocalMode": true' '"EnableLocalMode": false' "$install_dir/config/config.json" +ynh_systemctl --service=$app --action=restart --log_path=systemd --wait_until="Started Mattermost" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 22e3942..fa9a2dc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,36 +1,31 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SYSTEMD SERVICE +# REMOVE SYSTEMD SERVICE + #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression "Removing $app service..." yunohost service remove $app fi # Stop the server, and remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # If the user attempted to upgrade from an older MariaDB-based version, but the upgrade failed, # the 'remove' action will automatically remove the PostgreSQL database – but doesn't know @@ -38,12 +33,12 @@ ynh_remove_nginx_config # In that case, remove the MariaDB database manually. if mysqlshow | grep -q "^| $db_name " then - ynh_script_progression --message="Removing MariaDB database..." --weight=1 - ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + ynh_script_progression "Removing MariaDB database..." + # FIXMEhelpers2.1 ynh_mysql_drop_db && ynh_mysql_drop_user --db_user=$db_user --db_name=$db_name fi #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ea26060..ea9a166 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,29 +1,22 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=2 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chown -R $app:www-data "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=4 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R $app:www-data "$data_dir" @@ -32,37 +25,35 @@ chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_db_shell < "./db.sql"" logs_path="/var/log/$app" mkdir -p $logs_path chown -R $app: $logs_path -ynh_restore_file "/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="Started Mattermost" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index bb135c3..1b3b21a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -14,15 +8,17 @@ source /usr/share/yunohost/helpers #================================================= # Save the language used if not present +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=language --value="en" if [ -z "${language:-}" ]; then language="en" - ynh_app_setting_set --app=$app --key=language --value=$language + ynh_app_setting_set --key=language --value=$language fi # If version setting doesn't exist +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=version --value="Team" if [ -z "${version:-}" ]; then version="Team" - ynh_app_setting_set --app=$app --key=version --value=$version + ynh_app_setting_set --key=version --value=$version fi #================================================= @@ -38,19 +34,17 @@ if mysqlshow | grep -q "^| $db_name "; then mariadb-to-pg fi -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=3 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action=stop --log_path=systemd +ynh_systemctl --service=$app --action=stop --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=2 +ynh_script_progression "Upgrading source files..." # Create a temporary directory tmpdir="$(mktemp -d)" @@ -60,7 +54,7 @@ cp -a "$install_dir/config/config.json" "$tmpdir/config.json" cp -ar "$install_dir/plugins" "$tmpdir/plugins" # Remove the app directory securely -ynh_secure_remove --file="$install_dir" +ynh_safe_rm "$install_dir" if [ "$version" = "Enterprise" ]; then ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" @@ -69,37 +63,37 @@ elif [ "$version" = "Team" ]; then fi # Copy the admin saved settings and plugins from tmp directory to final path -cp -a "$tmpdir/config.json" "$install_dir/config/config.json" +cp -a "$tmpdir/config.json" "$install_dir/config/config.json" + cp -ar --no-clobber "$tmpdir/plugins" "$install_dir/" # Remove the tmp directory securely -ynh_secure_remove --file="$tmpdir" - -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +ynh_safe_rm "$tmpdir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=3 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # 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 +if ynh_app_upgrading_from_version_before 5.37.1~ynh1 then read -r -d '' fix_old_version_sql << EOM ALTER TABLE ChannelMembers ALTER COLUMN mentioncountroot SET DEFAULT '0'::bigint; @@ -114,7 +108,7 @@ 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 + ynh_psql_db_shell <<< "$fix_old_version_sql" # 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... @@ -123,13 +117,13 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" +ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="Started Mattermost" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"