restore 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. ynh_systemctl --service="$app" --action="start" --wait_until="No requirements found in frontmatter"
  28. yunohost service add "$app" --description="User-friendly AI Interface (Supports Ollama, OpenAI API, ...)" --log="/var/log/$app/$app.log"
  29. ynh_restore "/etc/logrotate.d/$app"
  30. #ynh_restore "/etc/fail2ban/jail.d/$app.conf"
  31. #ynh_restore "/etc/fail2ban/filter.d/$app.conf"
  32. #ynh_systemctl --action=restart --service=fail2ban
  33. #=================================================
  34. # RESTORE VARIOUS FILES
  35. #=================================================
  36. ynh_restore "/var/log/$app/"
  37. #=================================================
  38. # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
  39. #=================================================
  40. ynh_script_progression "Reloading NGINX web server and $app's service..."
  41. ynh_systemctl --service=nginx --action=reload
  42. #=================================================
  43. # END OF SCRIPT
  44. #=================================================
  45. ynh_script_progression "Restoration completed for $app"