restore 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. # STRETCH COMPATIBILITY
  37. #=================================================
  38. if is_stretch
  39. then
  40. ynh_replace_string --match_string="yunohost backup create --ignore-apps" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
  41. ynh_replace_string --match_string="yunohost backup create --ignore-system" --replace_string="yunohost backup create" --target_file="$final_path/archivist.sh"
  42. fi
  43. #=================================================
  44. # SPECIFIC RESTORATION
  45. #=================================================
  46. # REINSTALL DEPENDENCIES
  47. #=================================================
  48. ynh_script_progression --message="Reinstalling dependencies..." --weight=17
  49. # Valid the fucking debconf message
  50. # To find this, install the package, install also debconf-utils
  51. # Then use `debconf-get-selections | grep package`
  52. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  53. ynh_install_app_dependencies $app_depencencies
  54. #=================================================
  55. # RESTORE THE LOGROTATE CONFIGURATION
  56. #=================================================
  57. mkdir -p /var/log/$app
  58. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  59. #=================================================
  60. # RESTORE THE CRON FILE
  61. #=================================================
  62. ynh_restore_file --origin_path="/etc/cron.d/$app"
  63. #=================================================
  64. # RECREATE DIRECTORIES
  65. #=================================================
  66. mkdir -p "/home/yunohost.app/${app}/backup"
  67. #=================================================
  68. # SEND A README FOR THE ADMIN
  69. #=================================================
  70. # Get main domain and buid the url of the admin panel of the app.
  71. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
  72. echo "If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  73. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  74. 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.
  75. You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
  76. 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__.
  77. 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
  78. ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
  79. #=================================================
  80. # END OF SCRIPT
  81. #=================================================
  82. ynh_script_progression --message="Restoration completed for $app" --last