2
0

restore 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
  8. source ../settings/scripts/_common.sh
  9. source /usr/share/yunohost/helpers
  10. #=================================================
  11. # MANAGE SCRIPT FAILURE
  12. #=================================================
  13. # Exit if an error occurs during the execution of the script
  14. ynh_abort_if_errors
  15. #=================================================
  16. # LOAD SETTINGS
  17. #=================================================
  18. ynh_script_progression --message="Loading installation settings..."
  19. app=$YNH_APP_INSTANCE_NAME
  20. final_path=$(ynh_app_setting_get --app=$app --key=final_path)
  21. #=================================================
  22. # CHECK IF THE APP CAN BE RESTORED
  23. #=================================================
  24. ynh_script_progression --message="Validating restoration parameters..."
  25. test ! -d $final_path \
  26. || ynh_die --message="There is already a directory: $final_path "
  27. #=================================================
  28. # STANDARD RESTORATION STEPS
  29. #=================================================
  30. # RESTORE THE APP MAIN DIR
  31. #=================================================
  32. ynh_script_progression --message="Restoring the app main directory..."
  33. ynh_restore_file --origin_path="$final_path"
  34. #=================================================
  35. # SPECIFIC RESTORATION
  36. #=================================================
  37. # REINSTALL DEPENDENCIES
  38. #=================================================
  39. ynh_script_progression --message="Reinstalling dependencies..." --weight=17
  40. # Valid the fucking debconf message
  41. # To find this, install the package, install also debconf-utils
  42. # Then use `debconf-get-selections | grep package`
  43. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  44. ynh_install_app_dependencies $pkg_dependencies
  45. #=================================================
  46. # RESTORE VARIOUS FILES
  47. #=================================================
  48. ynh_script_progression --message="Restoring various files..."
  49. ynh_restore_file --origin_path="/etc/cron.d/$app"
  50. mkdir -p "/home/yunohost.app/${app}/backup"
  51. #=================================================
  52. # RESTORE THE LOGROTATE CONFIGURATION
  53. #=================================================
  54. ynh_script_progression --message="Restoring the logrotate configuration..."
  55. mkdir -p /var/log/$app
  56. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  57. #=================================================
  58. # SEND A README FOR THE ADMIN
  59. #=================================================
  60. # Get main domain and buid the url of the admin panel of the app.
  61. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
  62. echo "If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  63. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  64. Please read the __URL_TAG1__documentation__URL_TAG2__https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md__URL_TAG3__ about the configuration of archivist for more information.
  65. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
  66. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
  67. If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/archivist_ynh__URL_TAG3__." > mail_to_send
  68. ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
  69. #=================================================
  70. # END OF SCRIPT
  71. #=================================================
  72. ynh_script_progression --message="Restoration completed for $app" --last