2020-10-14 12:53:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-10-14 18:38:47 +02:00
|
|
|
ynh_script_progression --message="Loading settings..." --weight=1
|
2020-10-14 12:53:53 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
|
|
|
|
|
|
|
test ! -d $final_path \
|
|
|
|
|| ynh_die --message="There is already a directory: $final_path "
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# RECREATE THE DEDICATED USER
|
|
|
|
#=================================================
|
2020-10-14 14:30:12 +02:00
|
|
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
2020-10-14 12:53:53 +02:00
|
|
|
|
2020-10-14 14:30:12 +02:00
|
|
|
# Create the dedicated user (if not existing)
|
2021-05-27 17:16:06 +02:00
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
2020-10-14 12:53:53 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-05-27 17:16:06 +02:00
|
|
|
# RESTORE THE APP MAIN DIR
|
2020-10-14 12:53:53 +02:00
|
|
|
#=================================================
|
2021-05-27 17:16:06 +02:00
|
|
|
ynh_script_progression --message="Restoring Bludit main directory..." --weight=2
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="$final_path"
|
2020-10-14 12:53:53 +02:00
|
|
|
|
2021-05-27 17:16:06 +02:00
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
|
|
|
chown -R $app:www-data "$final_path"
|
2020-10-14 12:53:53 +02:00
|
|
|
|
|
|
|
#=================================================
|
2021-11-22 15:56:04 +01:00
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
|
|
|
|
|
|
|
# Define and install dependencies
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
2022-05-12 20:04:50 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=6
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|
|
|
|
2022-07-05 18:43:59 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
2020-10-14 12:53:53 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX AND PHP-FPM
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
|
|
|
|
|
2020-12-06 11:27:44 +01:00
|
|
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
2020-10-14 12:53:53 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-11-22 15:56:04 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|