From d880150af94cc164c69802f4ae46d7e6529482f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 6 Aug 2022 22:59:54 +0200 Subject: [PATCH] Update _common.sh --- scripts/_common.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d970f80..6ed0daf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,19 +16,21 @@ mysql-to-pg() { if mysqlshow | grep -q "^| $db_name "; then ynh_script_progression --message="Migrating to PostgreSQL database..." --weight=10 + + db_name=$(ynh_sanitize_dbid --db_name=$app) + db_user=$db_name + db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - mysql_db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - - db_pwd=$(ynh_string_random --length=24) - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + postgresql_db_pwd=$(ynh_string_random --length=24) + ynh_app_setting_set --app=$app --key=postgresql_db_pwd --value=$postgresql_db_pwd ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd # Migrating from MySQL to PostgreSQL - pgloader mysql://mattermost:$mysql_db_pwd@localhost:3306/mattermost postgresql://mattermost:$db_pwd@localhost:5432/mattermost + pgloader mysql://mattermost:$db_pwd@localhost:3306/mattermost postgresql://mattermost:$postgresql_db_pwd@localhost:5432/mattermost 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" + ynh_replace_string --match_string="\"DataSource\":*," --replace_string="\"DataSource\": \"postgres://$db_user:$postgresql_db_pwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10\"," --target_file="$final_path/config/config.json" # Removinging MySQL database ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name