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-30 12:07:09 +02:00
mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
2022-06-28 23:18:11 +02:00
ynh_psql_test_if_first_run
2022-09-30 12:12:11 +02:00
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$mysqlpwd
2022-09-30 12:07:09 +02:00
psqlpwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
2022-09-28 22:20:41 +02:00
2022-06-28 23:12:39 +02:00
2022-06-28 23:18:11 +02:00
# Migrating from MySQL to PostgreSQL
2022-09-30 13:16:16 +02:00
pgloader mysql://$db_user:$mysqlpwd@localhost:3306/$db_name postgresql://$db_user@localhost:5432/$db_name
2022-06-29 00:30:55 +02:00
2022-09-30 08:58:39 +02:00
ynh_replace_string --match_string="\"DriverName\":*," --replace_string="\"DriverName\": \"postgres\"," --target_file="$final_path/config/config.json"
2022-09-30 12:07:09 +02:00
ynh_replace_string --match_string="\"DataSource\":*," --replace_string="\"DataSource\": \"postgres://$db_user:$psqlpwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10\"," --target_file="$final_path/config/config.json"
2022-09-29 11:05:50 +02:00
2022-09-27 16:53:38 +02:00
#=================================================
# 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-30 08:58:39 +02:00
#smtp_user_pwd=$(ynh_string_random --length=24)
#url=https://$domain$path_url
2022-09-27 16:53:38 +02:00
2022-09-30 08:58:39 +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
#=================================================