restore 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
  6. source ../settings/scripts/_common.sh
  7. source /usr/share/yunohost/helpers
  8. #=================================================
  9. # RESTORE THE APP MAIN DIR
  10. #=================================================
  11. ynh_script_progression "Restoring the app main directory..."
  12. ynh_restore "$install_dir"
  13. chown -R "$app:www-data" "$install_dir"
  14. #=================================================
  15. # RESTORE THE DATA DIRECTORY
  16. #=================================================
  17. ynh_script_progression "Restoring the data directory..."
  18. ynh_restore "$data_dir"
  19. chown -R "$app:www-data" "$data_dir"
  20. #=================================================
  21. # RESTORE SYSTEM CONFIGURATION
  22. #=================================================
  23. ynh_script_progression "Restoring system configurations related to $app..."
  24. ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
  25. ynh_restore "/etc/systemd/system/$app.service"
  26. systemctl enable "$app.service" --quiet
  27. yunohost service add "$app" --description="User-friendly AI Interface (Supports Ollama, OpenAI API, ...)" --log="/var/log/$app/$app.log"
  28. ynh_restore "/etc/logrotate.d/$app"
  29. #ynh_restore "/etc/fail2ban/jail.d/$app.conf"
  30. #ynh_restore "/etc/fail2ban/filter.d/$app.conf"
  31. #ynh_systemctl --action=restart --service=fail2ban
  32. #=================================================
  33. # RESTORE VARIOUS FILES
  34. #=================================================
  35. ynh_restore "/var/log/$app/"
  36. #=================================================
  37. # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
  38. #=================================================
  39. ynh_script_progression "Reloading NGINX web server and $app's service..."
  40. ynh_systemctl --service=nginx --action=reload
  41. #=================================================
  42. # END OF SCRIPT
  43. #=================================================
  44. ynh_script_progression "Restoration completed for $app"