1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cac-proxy_ynh.git synced 2024-09-03 18:16:07 +02:00
cac-proxy_ynh/scripts/restore

72 lines
2.5 KiB
Text
Raw Normal View History

2023-01-11 18:59:44 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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-01-05 16:20:44 +01:00
ynh_restore_file --origin_path="$install_dir"
2023-01-11 18:59:44 +01:00
2024-01-05 16:20:44 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2023-01-11 18:59:44 +01:00
2023-01-14 10:17:35 +01:00
#Make sure the .ssh and files have the correct access rights
2024-01-05 16:20:44 +01:00
if [ -n "$public_key" ]; then
chown -R $app:$app "$install_dir/.ssh"
chmod 700 "$install_dir/.ssh"
chmod 600 "$install_dir/.ssh/authorized_keys"
_install_restart_script_and_sudoers
2023-01-14 10:17:35 +01:00
fi
2023-01-11 18:59:44 +01:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2024-01-05 16:20:44 +01:00
ynh_script_progression --message="Reinstalling NodeJS..." --weight=21
2023-01-11 18:59:44 +01:00
# Define and install dependencies
2024-01-05 16:44:26 +01:00
ynh_install_nodejs --nodejs_version="$nodejs_version"
2023-01-11 18:59:44 +01:00
ynh_use_nodejs
#=================================================
2024-01-05 16:20:44 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2023-01-11 18:59:44 +01:00
#=================================================
2024-01-05 16:20:44 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2023-01-11 18:59:44 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2024-01-05 16:20:44 +01:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2023-01-11 18:59:44 +01:00
2024-07-21 10:55:12 +02:00
mkdir --parents /var/log/$app
2023-01-11 18:59:44 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
2023-01-12 09:21:17 +01:00
yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
2023-01-11 18:59:44 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2024-01-05 16:20:44 +01:00
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
2023-01-11 18:59:44 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last