mirror of
https://github.com/YunoHost-Apps/immich_ynh.git
synced 2024-09-03 20:36:24 +02:00
101 lines
4.3 KiB
Bash
Executable file
101 lines
4.3 KiB
Bash
Executable file
#!/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
|
|
|
|
ynh_restore_file --origin_path="$install_dir"
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:$app "$install_dir"
|
|
|
|
#=================================================
|
|
# RESTORE THE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
|
|
|
chown -R $app:$app "$data_dir"
|
|
|
|
#=================================================
|
|
# INSTALL NODEJS
|
|
#=================================================
|
|
ynh_script_progression --message="Reinstalling nodejs..." --weight=5
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
#=================================================
|
|
# RESTORE THE DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the database..." --weight=1
|
|
|
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psql_pwd)
|
|
myynh_create_psql_db
|
|
myynh_restore_psql_db
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
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"
|
|
|
|
systemctl enable "$app-server.service" --quiet
|
|
systemctl enable "$app-microservices.service" --quiet
|
|
systemctl enable "$app-machine-learning.service" --quiet
|
|
|
|
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"
|
|
|
|
ynh_multimedia_build_main_dir
|
|
ynh_multimedia_addaccess --user_name=$app
|
|
|
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|
|
|
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
|
|
|
|
#=================================================
|
|
# RESTORE VARIOUS FILES
|
|
#=================================================
|
|
ynh_restore_file --origin_path="/var/log/$app/"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
#=================================================
|
|
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"
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|