restore 4.0 KB

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