fix restore script

This commit is contained in:
Benedikt Tissot 2021-04-05 15:43:02 +02:00
parent 5c14127b70
commit b703c82de5

View file

@ -29,30 +29,21 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) 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) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) mautrix_bridge_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_name)
db_user=$db_name mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) mautrix_bridge_db_user=$mautrix_bridge_db_name
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 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 \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # 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 # 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 # 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_psql_test_if_first_run
# ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql 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 # RESTORE SYSTEMD
@ -121,7 +117,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
# ynh_restore_file --origin_path="/etc/$app/" ynh_restore_file --origin_path="$app_service_registration_path"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION