2018-11-25 14:43:49 +01:00
|
|
|
#!/bin/bash
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2018-11-25 14:43:49 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
2019-04-13 15:37:56 +02:00
|
|
|
source ../settings/scripts/_common.sh
|
2018-11-25 14:43:49 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2020-11-01 16:49:03 +01:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
2018-11-25 14:43:49 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
2018-11-25 14:43:49 +01:00
|
|
|
|
2023-04-06 13:42:27 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2018-11-25 14:43:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC RESTORATION
|
|
|
|
#=================================================
|
|
|
|
# REINSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2023-04-06 13:48:27 +02:00
|
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=15
|
2022-06-08 03:24:51 +02:00
|
|
|
|
2018-11-25 15:02:49 +01:00
|
|
|
#Check & regen local
|
|
|
|
for i in $lang ; do
|
2022-06-10 20:52:48 +02:00
|
|
|
ynh_replace_string --match_string="# $i" --replace_string="$i" --target_file="/etc/locale.gen"
|
2018-11-25 15:02:49 +01:00
|
|
|
done
|
|
|
|
locale-gen
|
2018-11-25 14:43:49 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2023-04-06 14:03:18 +02:00
|
|
|
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE MYSQL DATABASE
|
|
|
|
#=================================================
|
2023-04-06 13:48:27 +02:00
|
|
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
2022-06-08 03:24:51 +02:00
|
|
|
|
|
|
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
2019-05-19 18:59:47 +02:00
|
|
|
|
2018-11-25 15:02:49 +01:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
# RESTORE VARIOUS FILES
|
2018-11-25 15:02:49 +01:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_script_progression --message="Restoring various files..." --weight=10
|
2019-05-21 13:49:14 +02:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
|
|
|
|
|
|
|
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle"
|
2020-11-01 16:49:03 +01:00
|
|
|
yunohost tools regen-conf postfix
|
2018-11-25 15:02:49 +01:00
|
|
|
|
2019-05-19 18:59:47 +02:00
|
|
|
#create an alias for deleted junk adresses
|
2019-05-22 10:58:07 +02:00
|
|
|
if ! grep -q "devnull:/dev/null" /etc/aliases ; then
|
2019-05-19 18:59:47 +02:00
|
|
|
cp /etc/aliases /etc/aliases.emailpoubelle.bak #backup it
|
|
|
|
echo "devnull:/dev/null" | tee -a /etc/aliases
|
|
|
|
newaliases
|
|
|
|
fi
|
2018-11-25 14:43:49 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_systemd_action --service_name=postfix --action=reload
|
2018-11-25 14:43:49 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
# RELOAD NGINX AND PHP-FPM
|
2018-11-25 14:43:49 +01:00
|
|
|
#=================================================
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
|
2019-05-21 13:37:11 +02:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
2019-05-21 13:37:11 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2018-11-25 15:02:49 +01:00
|
|
|
|
2019-05-21 13:37:11 +02:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2018-11-25 15:02:49 +01:00
|
|
|
|
2022-06-08 03:24:51 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|