restore 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
  8. source ../settings/scripts/_common.sh
  9. source /usr/share/yunohost/helpers
  10. #=================================================
  11. # STANDARD RESTORATION STEPS
  12. #=================================================
  13. # RESTORE THE APP MAIN DIR
  14. #=================================================
  15. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  16. ynh_restore_file --origin_path="$install_dir"
  17. #=================================================
  18. # RESTORE THE DATA DIRECTORY
  19. #=================================================
  20. ynh_script_progression --message="Restoring the data directory..." --weight=1
  21. ynh_restore_file --origin_path="$data_dir" --not_mandatory
  22. mkdir -p $data_dir
  23. #=================================================
  24. # RESTORE FAIL2BAN CONFIGURATION
  25. #=================================================
  26. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  27. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  28. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  29. ynh_systemd_action --action=restart --service_name=fail2ban
  30. #=================================================
  31. # SPECIFIC RESTORATION
  32. #=================================================
  33. # RESTORE THE NGINX CONFIGURATION
  34. #=================================================
  35. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  36. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  37. #=================================================
  38. # REINSTALL COUCHDB
  39. #=================================================
  40. ynh_script_progression --message="Reinstalling couchdb..." --weight=40
  41. echo "\
  42. couchdb couchdb/mode select standalone
  43. couchdb couchdb/mode seen true
  44. couchdb couchdb/bindaddress string 127.0.0.1
  45. couchdb couchdb/bindaddress seen true
  46. couchdb couchdb/cookie string $password
  47. couchdb couchdb/adminpass password $password
  48. couchdb couchdb/adminpass seen true
  49. couchdb couchdb/adminpass_again password $password
  50. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  51. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  52. ynh_install_extra_app_dependencies \
  53. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  54. --key="https://couchdb.apache.org/repo/keys.asc" \
  55. --package="couchdb"
  56. chmod 750 "$install_dir"
  57. chmod -R o-rwx "$install_dir"
  58. chown -R $app:$app "$install_dir"
  59. chmod 750 "$data_dir"
  60. chmod -R o-rwx "$data_dir"
  61. chown -R $app:www-data "$data_dir"
  62. #=================================================
  63. # RESTORE THE LOGROTATE CONFIGURATION
  64. #=================================================
  65. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  66. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  67. #=================================================
  68. # INTEGRATE SERVICE IN YUNOHOST
  69. #=================================================
  70. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  71. yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log"
  72. #=================================================
  73. # GENERIC FINALIZATION
  74. #=================================================
  75. # RELOAD NGINX
  76. #=================================================
  77. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  78. ynh_systemd_action --service_name=nginx --action=reload
  79. #=================================================
  80. # END OF SCRIPT
  81. #=================================================
  82. ynh_script_progression --message="Restoration completed for $app" --last