2017-10-28 19:28:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2020-06-28 23:43:03 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-10-28 19:28:51 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
2017-10-28 19:28:51 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2020-06-28 23:43:03 +02:00
|
|
|
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)
|
2017-10-28 19:28:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
2017-10-28 19:28:51 +02:00
|
|
|
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
|
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
2017-10-28 19:28:51 +02:00
|
|
|
test ! -d $final_path \
|
2020-06-28 23:43:03 +02:00
|
|
|
|| ynh_die --message="There is already a directory: $final_path "
|
2017-10-28 19:28:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=3
|
2017-10-28 19:28:51 +02:00
|
|
|
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_restore_file --origin_path="$final_path"
|
|
|
|
|
2017-10-28 19:28:51 +02:00
|
|
|
# Restore permissions on app files
|
2021-04-21 23:52:56 +02:00
|
|
|
chmod 750 $final_path
|
2017-10-28 19:28:51 +02:00
|
|
|
chown -R www-data: $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-11-17 09:08:16 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2020-06-28 23:43:03 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-10-28 19:28:51 +02:00
|
|
|
|
2020-06-28 23:43:03 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|