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/_common.sh

58 lines
2 KiB
Bash
Raw Normal View History

2021-01-11 23:46:48 +01:00
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
2022-06-22 10:58:12 +02:00
# dependencies used by the app
pkg_dependencies="postgresql postgresql-contrib pgloader"
2022-06-22 10:58:12 +02:00
2021-01-11 23:46:48 +01:00
#=================================================
# PERSONAL HELPERS
#=================================================
2022-06-28 23:12:39 +02:00
mysql-to-pg() {
if mysqlshow | grep -q "^| $db_name "; then
2022-06-28 23:18:11 +02:00
ynh_script_progression --message="Migrating to PostgreSQL database..." --weight=10
2022-06-28 23:12:39 +02:00
2022-09-27 22:45:00 +02:00
mysql_db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
2022-06-28 23:18:11 +02:00
ynh_psql_test_if_first_run
2022-09-27 15:00:45 +02:00
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
2022-09-27 22:45:00 +02:00
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
2022-06-28 23:12:39 +02:00
2022-06-28 23:18:11 +02:00
# Migrating from MySQL to PostgreSQL
2022-09-27 22:45:00 +02:00
pgloader mysql://mattermost:$mysql_db_pwd@localhost:3306/mattermost postgresql://mattermost:$db_pwd@localhost:5432/mattermost
2022-06-29 00:30:55 +02:00
2022-09-27 16:53:38 +02:00
#ynh_replace_string --match_string="\"DriverName\":*," --replace_string="\"DriverName\": \"postgres\"," --target_file="$final_path/config/config.json"
#ynh_replace_string --match_string="\"DataSource\":*," --replace_string="\"DataSource\": \"postgres://$db_user:$db_pwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10\"," --target_file="$final_path/config/config.json"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
2022-09-27 21:00:14 +02:00
#ynh_script_progression --message="Modifying a config file..." --weight=3
2022-09-27 16:53:38 +02:00
2022-09-27 21:00:14 +02:00
#smtp_user_pwd=$(ynh_string_random --length=24)
#url=https://$domain$path_url
#db_pwd=$(psqlpwd)
2022-09-27 16:53:38 +02:00
2022-09-27 21:00:14 +02:00
#ynh_add_config --template="../conf/config.json" --destination="$final_path/config/config.json"
2022-09-27 16:53:38 +02:00
2022-06-28 23:18:11 +02:00
# Removinging MySQL database
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
2022-06-28 23:12:39 +02:00
else
2022-06-28 23:18:11 +02:00
ynh_print_info --message="No migration needed"
2022-06-28 23:12:39 +02:00
fi
}
2021-01-11 23:46:48 +01:00
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================