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-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
|
|
|
# INSTALL NODEJS
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Reinstalling nodejs..." --weight=5
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
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 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"
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-microservices.service"
|
|
|
|
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
|
|
|
|
systemctl enable "$app-microservices.service" --quiet
|
|
|
|
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"
|
|
|
|
yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log"
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is listening" --log_path="/var/log/$app/$app-microservices.log"
|
|
|
|
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
|