restore 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. app=$YNH_APP_INSTANCE_NAME
  20. final_path=$(ynh_app_setting_get $app final_path)
  21. #=================================================
  22. # CHECK IF THE APP CAN BE RESTORED
  23. #=================================================
  24. test ! -d $final_path \
  25. || ynh_die "There is already a directory: $final_path "
  26. #=================================================
  27. # STANDARD RESTORATION STEPS
  28. #=================================================
  29. # RESTORE THE APP MAIN DIR
  30. #=================================================
  31. ynh_restore_file "$final_path"
  32. #=================================================
  33. # STRETCH COMPATIBILITY
  34. #=================================================
  35. if is_stretch
  36. then
  37. ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
  38. ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
  39. fi
  40. #=================================================
  41. # SPECIFIC RESTORATION
  42. #=================================================
  43. # REINSTALL DEPENDENCIES
  44. #=================================================
  45. # Valid the fucking debconf message
  46. # To find this, install the package, install also debconf-utils
  47. # Then use `debconf-get-selections | grep package`
  48. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  49. ynh_install_app_dependencies $app_depencencies
  50. #=================================================
  51. # RESTORE LOGROTATE
  52. #=================================================
  53. mkdir -p /var/log/$app
  54. ynh_restore_file "/etc/logrotate.d/$app"
  55. #=================================================
  56. # RESTORE THE CRON FILE
  57. #=================================================
  58. ynh_restore_file "/etc/cron.d/$app"
  59. #=================================================
  60. # RECREATE DIRECTORIES
  61. #=================================================
  62. mkdir -p "/home/yunohost.app/${app}/backup"
  63. #=================================================
  64. # SEND A README FOR THE ADMIN
  65. #=================================================
  66. message="If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  67. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  68. Please read the documentation (https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
  69. If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/archivist_ynh"
  70. ynh_send_readme_to_admin --app_message="$message" --recipients="root"