1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/galette_ynh.git synced 2024-09-03 18:36:28 +02:00
galette_ynh/scripts/restore

79 lines
2.6 KiB
Text
Raw Normal View History

2018-03-21 00:04:12 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-04-13 20:36:45 +02:00
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2019-09-25 21:04:44 +02:00
source ../settings/scripts/_common.sh
2018-03-21 00:04:12 +01:00
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2021-07-22 16:18:37 +02:00
timezone="$(cat /etc/timezone)"
2018-03-21 00:04:12 +01:00
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
2021-01-05 23:31:12 +01:00
ynh_script_progression --message="Restoring the app main directory..." --weight=2
2018-03-21 00:04:12 +01:00
2023-11-11 14:01:42 +01:00
ynh_restore_file --origin_path="$install_dir"
2018-03-21 00:04:12 +01:00
2023-11-11 14:01:42 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2021-07-22 15:39:20 +02:00
#=================================================
2023-11-11 14:14:26 +01:00
# RESTORE THE SQL DATABASE
2021-07-22 15:39:20 +02:00
#=================================================
2022-04-14 19:39:41 +02:00
if [ $database == "pgsql" ]
then
2023-11-11 14:14:26 +01:00
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
else
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
2022-04-14 19:39:41 +02:00
fi
2018-03-21 00:04:12 +01:00
#=================================================
2022-06-26 14:53:49 +02:00
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2023-11-11 14:14:26 +01:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2018-03-21 00:04:12 +01:00
#=================================================
# RESTORE USER RIGHTS
#=================================================
2023-11-11 14:01:42 +01:00
chown "$app" "$install_dir/galette/config"
chmod 750 "$install_dir/galette/config"
2018-03-21 00:04:12 +01:00
for folder in attachments cache exports files imports logs photos templates_c tempimages
do
2023-11-11 14:01:42 +01:00
chown "$app" "$install_dir/galette/data/$folder"
chmod 775 "$install_dir/galette/data/$folder"
2018-03-21 00:04:12 +01:00
done
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
2021-01-05 23:31:12 +01:00
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2018-03-21 00:04:12 +01:00
2021-01-05 23:31:12 +01:00
ynh_script_progression --message="Restoration completed for $app" --last