restore 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. if [ ! -e _common.sh ]; then
  8. # Get the _common.sh file if it's not in the current directory
  9. cp ../settings/scripts/_common.sh ./_common.sh
  10. chmod a+rx _common.sh
  11. fi
  12. source _common.sh
  13. source /usr/share/yunohost/helpers
  14. #=================================================
  15. # MANAGE SCRIPT FAILURE
  16. #=================================================
  17. # Exit if an error occurs during the execution of the script
  18. ynh_abort_if_errors
  19. #=================================================
  20. # LOAD SETTINGS
  21. #=================================================
  22. app=$YNH_APP_INSTANCE_NAME
  23. final_path=$(ynh_app_setting_get $app final_path)
  24. #=================================================
  25. # CHECK IF THE APP CAN BE RESTORED
  26. #=================================================
  27. test ! -d $final_path \
  28. || ynh_die "There is already a directory: $final_path "
  29. #=================================================
  30. # STANDARD RESTORATION STEPS
  31. #=================================================
  32. # RESTORE THE APP MAIN DIR
  33. #=================================================
  34. ynh_restore_file "$final_path"
  35. #=================================================
  36. # SPECIFIC RESTORATION
  37. #=================================================
  38. # REINSTALL DEPENDENCIES
  39. #=================================================
  40. # Valid the fucking debconf message
  41. # To find this, install the package, install also debconf-utils
  42. # Then use `debconf-get-selections | grep package`
  43. echo "encfs encfs/security-information boolean true" | debconf-set-selections
  44. ynh_install_app_dependencies rsync encfs sshpass
  45. #=================================================
  46. # RESTORE LOGROTATE
  47. #=================================================
  48. mkdir -p /var/log/$app
  49. ynh_restore_file "/etc/logrotate.d/$app"
  50. #=================================================
  51. # RESTORE THE CRON FILE
  52. #=================================================
  53. ynh_restore_file "/etc/cron.d/$app"
  54. #=================================================
  55. # RECREATE DIRECTORIES
  56. #=================================================
  57. mkdir -p "/home/yunohost.app/${app}/backup"
  58. #=================================================
  59. # SEND A README FOR THE ADMIN
  60. #=================================================
  61. message="If you want to change the frequency of Archivist, have a look to the file /etc/cron.d/$app.
  62. The configuration file of Archivist has been restored at $final_path/Backup_list.conf
  63. Please read the documentation (https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
  64. 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"
  65. ynh_send_readme_to_admin "$message" "root"