restore 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source ../settings/scripts/_common.sh
  8. source /usr/share/yunohost/helpers
  9. # Load common variables for all scripts.
  10. source ../settings/scripts/_variables
  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="Load settings"
  20. app=$YNH_APP_INSTANCE_NAME
  21. final_path=$(ynh_app_setting_get $app final_path)
  22. #=================================================
  23. # CHECK IF THE APP CAN BE RESTORED
  24. #=================================================
  25. test ! -d $final_path \
  26. || ynh_die "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="Restore the app main directory"
  33. ynh_restore_file "$final_path"
  34. #=================================================
  35. # STRETCH COMPATIBILITY
  36. #=================================================
  37. if is_stretch
  38. then
  39. ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
  40. ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
  41. fi
  42. #=================================================
  43. # SPECIFIC RESTORATION
  44. #=================================================
  45. # REINSTALL DEPENDENCIES
  46. #=================================================
  47. ynh_script_progression --message="Reinstall dependencies" --weight=17
  48. # Valid the fucking debconf message
  49. # To find this, install the package, install also debconf-utils
  50. # Then use `debconf-get-selections | grep package`
  51. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  52. ynh_install_app_dependencies $app_depencencies
  53. #=================================================
  54. # RESTORE THE LOGROTATE CONFIGURATION
  55. #=================================================
  56. mkdir -p /var/log/$app
  57. ynh_restore_file "/etc/logrotate.d/$app"
  58. #=================================================
  59. # RESTORE THE CRON FILE
  60. #=================================================
  61. ynh_restore_file "/etc/cron.d/$app"
  62. #=================================================
  63. # RECREATE DIRECTORIES
  64. #=================================================
  65. mkdir -p "/home/yunohost.app/${app}/backup"
  66. #=================================================
  67. # SEND A README FOR THE ADMIN
  68. #=================================================
  69. # Get main domain and buid the url of the admin panel of the app.
  70. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
  71. echo "If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  72. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  73. 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.
  74. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
  75. 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__.
  76. 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
  77. ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore"
  78. #=================================================
  79. # END OF SCRIPT
  80. #=================================================
  81. ynh_script_progression --message="Restoration completed" --last