2
0

restore 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #=================================================
  10. # MANAGE SCRIPT FAILURE
  11. #=================================================
  12. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # LOAD SETTINGS
  16. #=================================================
  17. app=$YNH_APP_INSTANCE_NAME
  18. final_path=$(ynh_app_setting_get $app final_path)
  19. #=================================================
  20. # CHECK IF THE APP CAN BE RESTORED
  21. #=================================================
  22. test ! -d $final_path \
  23. || ynh_die "There is already a directory: $final_path "
  24. #=================================================
  25. # STANDARD RESTORATION STEPS
  26. #=================================================
  27. # RESTORE THE APP MAIN DIR
  28. #=================================================
  29. ynh_restore_file "$final_path"
  30. #=================================================
  31. # STRETCH COMPATIBILITY
  32. #=================================================
  33. if is_stretch
  34. then
  35. ynh_replace_string "yunohost backup create --ignore-apps" "yunohost backup create" "$final_path/archivist.sh"
  36. ynh_replace_string "yunohost backup create --ignore-system" "yunohost backup create" "$final_path/archivist.sh"
  37. fi
  38. #=================================================
  39. # SPECIFIC RESTORATION
  40. #=================================================
  41. # REINSTALL DEPENDENCIES
  42. #=================================================
  43. # Valid the fucking debconf message
  44. # To find this, install the package, install also debconf-utils
  45. # Then use `debconf-get-selections | grep package`
  46. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  47. ynh_install_app_dependencies rsync encfs sshpass
  48. #=================================================
  49. # RESTORE LOGROTATE
  50. #=================================================
  51. mkdir -p /var/log/$app
  52. ynh_restore_file "/etc/logrotate.d/$app"
  53. #=================================================
  54. # RESTORE THE CRON FILE
  55. #=================================================
  56. ynh_restore_file "/etc/cron.d/$app"
  57. #=================================================
  58. # RECREATE DIRECTORIES
  59. #=================================================
  60. mkdir -p "/home/yunohost.app/${app}/backup"
  61. #=================================================
  62. # SEND A README FOR THE ADMIN
  63. #=================================================
  64. message="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 documentation (https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
  67. 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"
  68. ynh_send_readme_to_admin --app_message="$message" --recipients="root"