2019-02-21 10:52:01 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_script_progression --message="Loading settings..." --weight=1
|
2019-02-21 10:52:01 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
2019-02-21 10:52:01 +01:00
|
|
|
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
|
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
2019-02-21 10:52:01 +01:00
|
|
|
test ! -d $final_path \
|
2020-10-10 19:02:26 +02:00
|
|
|
|| ynh_die --message="There is already a directory: $final_path "
|
2019-02-21 10:52:01 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_script_progression --message="Restoring Mindmaps main directory..." --weight=1
|
2019-02-21 10:52:01 +01:00
|
|
|
|
|
|
|
ynh_restore_file "$final_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE USER RIGHTS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Restore permissions on app files
|
|
|
|
chown -R root: $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2019-02-21 10:52:01 +01:00
|
|
|
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-02-21 10:52:01 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-10-10 19:02:26 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for Mindmaps" --last
|