restore 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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"