From b703c82de57dd3e8335fbb7525c8d08160b95ad4 Mon Sep 17 00:00:00 2001 From: Benedikt Tissot Date: Mon, 5 Apr 2021 15:43:02 +0200 Subject: [PATCH] fix restore script --- scripts/restore | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/restore b/scripts/restore index 6cd2493..fedb9f6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,30 +29,21 @@ ynh_script_progression --message="Loading installation settings..." --time --wei app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +mautrix_bridge_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_name) +mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd) +mautrix_bridge_db_user=$mautrix_bridge_db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -91,9 +82,14 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # ynh_script_progression --message="Restoring the MySQL database..." --time --weight=1 -# db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -# ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -# ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + +ynh_psql_test_if_first_run +ynh_print_OFF +ynh_psql_create_user $mautrix_bridge_db_user $mautrix_bridge_db_pwd +ynh_print_ON +ynh_psql_execute_as_root \ +--sql="CREATE DATABASE ""$mautrix_bridge_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_bridge_db_user"";" +ynh_psql_connect_as --user=$mautrix_bridge_db_user --password=$mautrix_bridge_db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD @@ -121,7 +117,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # RESTORE VARIOUS FILES #================================================= -# ynh_restore_file --origin_path="/etc/$app/" +ynh_restore_file --origin_path="$app_service_registration_path" #================================================= # RESTORE THE LOGROTATE CONFIGURATION