restore 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. # SPECIFIC RESTORATION
  32. #=================================================
  33. # REINSTALL DEPENDENCIES
  34. #=================================================
  35. # Valid the fucking debconf message
  36. # To find this, install the package, install also debconf-utils
  37. # Then use `debconf-get-selections | grep package`
  38. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  39. ynh_install_app_dependencies rsync encfs sshpass
  40. #=================================================
  41. # RESTORE LOGROTATE
  42. #=================================================
  43. mkdir -p /var/log/$app
  44. ynh_restore_file "/etc/logrotate.d/$app"
  45. #=================================================
  46. # RESTORE THE CRON FILE
  47. #=================================================
  48. ynh_restore_file "/etc/cron.d/$app"
  49. #=================================================
  50. # RECREATE DIRECTORIES
  51. #=================================================
  52. mkdir -p "/home/yunohost.app/${app}/backup"
  53. #=================================================
  54. # SEND A README FOR THE ADMIN
  55. #=================================================
  56. message="If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  57. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  58. Please read the documentation (https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
  59. 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"
  60. ynh_send_readme_to_admin --app_message="$message" --recipients="root"