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

102 lines
4.3 KiB
Text
Raw Normal View History

2022-08-30 19:10:45 +02:00
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-08-30 19:10:45 +02:00
2024-03-26 06:53:38 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2022-08-30 19:10:45 +02:00
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="$data_dir" --not_mandatory
2022-08-30 19:10:45 +02:00
2024-03-26 06:53:38 +01:00
chown -R $app:$app "$data_dir"
2022-08-30 19:10:45 +02:00
2024-03-28 07:40:12 +01:00
#=================================================
# CHECK PYTHON VERSION AND COMPILE IF NEEDED
#=================================================
ynh_script_progression --message="Check Python version & compile the required one if needed..." --weight=1
py_required_version=$(ynh_app_setting_get --app="$app" --key=python)
myynh_install_python --python="$py_required_version"
2024-07-28 10:29:00 +02:00
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Reinstalling nodejs..." --weight=5
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
# RESTORE THE DATABASE
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
ynh_script_progression --message="Restoring the database..." --weight=1
2022-08-30 19:10:45 +02:00
2024-03-26 06:53:38 +01:00
db_pwd=$(ynh_app_setting_get --app="$app" --key=psql_pwd)
myynh_create_psql_db
myynh_restore_psql_db
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-08-30 19:10:45 +02:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service"
2024-06-15 13:39:04 +02:00
ynh_restore_file --origin_path="/etc/systemd/system/$app-microservices.service"
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app-machine-learning.service"
2022-08-30 19:10:45 +02:00
2024-03-26 06:53:38 +01:00
systemctl enable "$app-server.service" --quiet
2024-06-15 13:39:04 +02:00
systemctl enable "$app-microservices.service" --quiet
2024-03-26 06:53:38 +01:00
systemctl enable "$app-machine-learning.service" --quiet
2022-08-30 19:10:45 +02:00
2024-03-26 06:53:38 +01:00
yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log"
2024-06-15 13:39:04 +02:00
yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log"
2024-03-26 06:53:38 +01:00
yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log"
2022-08-30 19:10:45 +02:00
2024-05-04 21:58:35 +02:00
ynh_multimedia_build_main_dir
ynh_multimedia_addaccess --user_name=$app
2022-08-30 19:10:45 +02:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
# RESTORE VARIOUS FILES
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
ynh_restore_file --origin_path="/var/log/$app/"
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2022-08-30 19:10:45 +02:00
#=================================================
2024-03-26 06:53:38 +01:00
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
2024-06-15 14:02:59 +02:00
ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is running" --log_path="/var/log/$app/$app-microservices.log"
2024-03-26 06:53:38 +01:00
ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log"
ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log"
2022-08-30 19:10:45 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last