1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00
mattermost_ynh/scripts/install

231 lines
8.3 KiB
Text
Raw Normal View History

2015-10-21 13:03:49 +02:00
#!/bin/bash
2017-09-12 19:14:18 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2015-10-21 13:03:49 +02:00
2021-01-11 23:46:48 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2017-09-12 19:14:18 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2021-01-11 23:46:48 +01:00
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2017-09-12 19:14:18 +02:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
2020-02-08 23:33:19 +01:00
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
2021-01-11 23:46:48 +01:00
admin=$YNH_APP_ARG_ADMIN
2021-01-28 17:02:43 +01:00
email=$(ynh_user_get_info --username=$admin --key=mail)
2021-01-11 23:46:48 +01:00
password=$YNH_APP_ARG_PASSWORD
language=$YNH_APP_ARG_LANGUAGE
team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME
version=$YNH_APP_ARG_VERSION
2021-01-11 23:46:48 +01:00
app=$YNH_APP_INSTANCE_NAME
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Validating installation parameters..." --weight=1
2016-04-17 18:35:42 +02:00
2021-01-11 23:46:48 +01:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
2015-10-21 16:24:51 +02:00
2021-01-11 23:46:48 +01:00
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
2015-10-21 16:24:51 +02:00
2018-01-29 13:40:03 +01:00
#=================================================
2021-01-11 23:46:48 +01:00
# STORE SETTINGS FROM MANIFEST
2018-01-29 13:40:03 +01:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Storing installation settings..." --weight=6
2018-01-29 13:40:03 +01:00
2021-01-11 23:46:48 +01:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=password --value="$password"
2021-01-11 23:46:48 +01:00
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=version --value=$version
2021-01-11 23:46:48 +01:00
ynh_app_setting_set --app=$app --key=team_display_name --value=$team_display_name
2015-10-21 13:03:49 +02:00
2018-01-29 13:40:03 +01:00
#=================================================
# FIND AN AVAILABLE PORT
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Finding an available port..." --weight=3
2018-01-29 13:40:03 +01:00
# Find an available port
2021-01-11 23:46:48 +01:00
port=$(ynh_find_port --port=8065)
ynh_app_setting_set --app=$app --key=port --value=$port
2018-01-29 13:40:03 +01:00
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
2021-09-16 11:39:20 +02:00
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
2017-09-12 19:14:18 +02:00
#=================================================
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
# CREATE A DATABASE
2017-09-12 19:14:18 +02:00
#=================================================
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
ynh_script_progression --message="Creating a database..." --weight=10
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Setting up source files..." --weight=3
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
if [ "$version" = "Enterprise" ]; then
# Get Enterprise binary path
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
ynh_setup_source --dest_dir="$final_path" --source_id="enterprise_$YNH_ARCH"
elif [ "$version" = "Team" ]; then
# Get Team binary path
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
ynh_setup_source --dest_dir="$final_path" --source_id="team_$YNH_ARCH"
fi
2016-05-23 07:41:12 +02:00
2021-09-16 11:39:20 +02:00
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# CREATE DIRECTORY FOR DATA
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Creating the data directory..." --weight=1
2017-09-12 19:14:18 +02:00
2021-09-16 11:39:20 +02:00
data_path=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=data_path --value=$data_path
mkdir -p $data_path
chmod 750 "$data_path"
chmod -R o-rwx "$data_path"
chown -R $app:www-data "$data_path"
2016-04-17 18:35:42 +02:00
2021-01-11 23:46:48 +01:00
#=================================================
# HANDLE LOG FILES AND LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Create log directory
mkdir -p /var/log/$app
chown $app -R "/var/log/$app"
2021-01-11 23:46:48 +01:00
# Setup logrotate
ynh_use_logrotate
2017-09-12 19:14:18 +02:00
#=================================================
# EDIT MATTERMOST CONFIG
#=================================================
2021-01-11 23:46:48 +01:00
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=3
2017-09-12 19:14:18 +02:00
smtp_user_pwd=$(ynh_string_random --length=24)
url=https://$domain$path_url
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411) * Upgrade to v7.3.0 * Auto-update README * Update config.json * Upgrade auto-updater (#407) * [autopatch] Upgrade auto-updater * Auto-update README --------- Co-authored-by: tituspijean <titus@pijean.ovh> * 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 d880150af94cc164c69802f4ae46d7e6529482f9. * 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> * Change arm64 source (#409) * add entreprise for arm64, use the official build for arm64 * Auto-update README * update auto-updater script --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> * delete the psql db if the migration fails * Drop all Focalbard tables if mattermost is in 7.3.0 --------- Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com> Co-authored-by: tituspijean <titus@pijean.ovh> Co-authored-by: biva <biva@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: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
2021-01-11 23:46:48 +01:00
ynh_add_config --template="../conf/config.json" --destination="$final_path/config/config.json"
2015-10-21 14:46:47 +02:00
2017-09-12 19:14:18 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2015-10-21 13:03:49 +02:00
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# SETUP SYSTEMD
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Configuring a systemd service..." --weight=2
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
2015-10-21 13:03:49 +02:00
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
2015-10-21 14:33:49 +02:00
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# START SYSTEMD SERVICE
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=2
2017-09-12 19:14:18 +02:00
2021-01-11 23:46:48 +01:00
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost"
2015-10-21 13:03:49 +02:00
#=================================================
# CREATE ADMIN AND FIRST TEAM
#=================================================
ynh_script_progression --message="Create the first administrator and team..." --weight=1
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="$final_path/bin/mmctl"
# mmctl is not packaged with ARM versions yet
2021-11-12 22:05:35 +01:00
if [[ -f "$bin_mmctl" ]]; then
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"
fi
# Disable mmctl passwordless access
ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$final_path/config/config.json"
ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Started Mattermost"
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-11 23:46:48 +01:00
# SETUP SSOWAT
2017-09-12 19:14:18 +02:00
#=================================================
2021-01-28 17:04:45 +01:00
ynh_script_progression --message="Configuring permissions..." --weight=1
2021-01-11 23:46:48 +01:00
if [ $is_public -eq 1 ]
then
2021-01-28 17:04:45 +01:00
ynh_permission_update --permission="main" --add="visitors"
2021-01-11 23:46:48 +01:00
fi
#=================================================
2021-01-11 23:46:48 +01:00
# RELOAD NGINX
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
2021-01-11 23:46:48 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2021-01-11 23:46:48 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2021-01-11 23:46:48 +01:00
ynh_script_progression --message="Installation of $app completed" --last