2017-03-02 15:44:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-09-03 23:31:52 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2017-03-02 15:44:54 +01:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2018-09-03 23:31:52 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2017-03-02 15:44:54 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2018-09-03 23:31:52 +02:00
|
|
|
#=================================================
|
|
|
|
# MANAGE SCRIPT FAILURE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_clean_setup () {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
2018-09-03 23:31:52 +02:00
|
|
|
|
2017-03-29 19:25:52 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2020-07-10 19:22:37 +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)
|
2022-10-06 00:00:31 +02:00
|
|
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
2020-07-10 19:22:37 +02:00
|
|
|
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
|
|
|
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
2018-09-03 23:31:52 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2021-01-20 08:46:17 +01:00
|
|
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
2018-09-03 23:31:52 +02:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
test ! -d $final_path \
|
|
|
|
|| ynh_die --message="There is already a directory: $final_path "
|
2017-03-09 17:27:59 +01:00
|
|
|
|
2018-09-03 23:31:52 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
2018-09-03 23:39:42 +02:00
|
|
|
#=================================================
|
|
|
|
# RECREATE THE DEDICATED USER
|
|
|
|
#=================================================
|
2021-01-20 08:46:17 +01:00
|
|
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
2018-09-03 23:39:42 +02:00
|
|
|
|
|
|
|
# Create the dedicated user (if not existing)
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
2017-03-10 16:59:58 +01:00
|
|
|
|
2021-09-09 22:54:05 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=2
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="$final_path"
|
|
|
|
|
2021-03-27 00:19:32 +01:00
|
|
|
chown -R $app:www-data "$final_path"
|
2021-03-26 19:57:20 +01:00
|
|
|
find "$final_path" -type f -exec chmod 640 {} \;
|
|
|
|
find "$final_path/bin" -type f -exec chmod 750 {} \;
|
|
|
|
find "$final_path" -type d -exec chmod 750 {} \;
|
|
|
|
find "$final_path" -type d -exec chmod +s {} \;
|
2017-03-09 17:27:59 +01:00
|
|
|
|
2018-09-03 21:35:41 +02:00
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
# SPECIFIC RESTORATION
|
2021-02-07 17:05:09 +01:00
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
2021-02-07 17:05:09 +01:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
# Define and install dependencies
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2021-02-07 17:05:09 +01:00
|
|
|
|
|
|
|
#=================================================
|
2018-09-03 23:31:52 +02:00
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
2018-09-03 21:35:41 +02:00
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
|
2018-09-03 21:35:41 +02:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
2017-03-02 15:44:54 +01:00
|
|
|
|
2021-11-29 20:25:33 +01:00
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
2021-11-29 20:25:33 +01:00
|
|
|
#=================================================
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
2021-11-29 20:25:33 +01:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE VARIOUS FILES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring various files..." --weight=1
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|
|
|
chmod 644 /etc/cron.d/$app
|
2017-03-09 17:27:59 +01:00
|
|
|
|
2018-09-03 23:31:52 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX AND PHP-FPM
|
|
|
|
#=================================================
|
2021-01-20 08:52:18 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
2017-04-01 17:03:40 +02:00
|
|
|
|
2022-10-06 00:00:31 +02:00
|
|
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
2020-07-10 19:22:37 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-10-26 15:25:19 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-20 08:46:17 +01:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|