restore 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. source ../settings/scripts/_common.sh
  3. source /usr/share/yunohost/helpers
  4. # RESTORE THE APP MAIN DIR
  5. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  6. ynh_restore_file --origin_path="$install_dir"
  7. # restore the apps settings
  8. ynh_script_progression --message="Restoring flohmarkts settings..." --weight=1
  9. ynh_restore_file --origin_path="/etc/yunohost/apps/$app"
  10. # RESTORE THE DATA DIRECTORY
  11. ynh_script_progression --message="Restoring the data directory..." --weight=1
  12. ynh_restore_file --origin_path="$data_dir" --not_mandatory
  13. mkdir -p $data_dir
  14. # RESTORE FAIL2BAN CONFIGURATION
  15. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  16. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  17. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  18. ynh_systemd_action --action=restart --service_name=fail2ban
  19. # RESTORE THE NGINX CONFIGURATION
  20. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  21. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  22. # REINSTALL COUCHDB
  23. ynh_script_progression --message="Reinstalling couchdb..." --weight=40
  24. echo "\
  25. couchdb couchdb/mode select standalone
  26. couchdb couchdb/mode seen true
  27. couchdb couchdb/bindaddress string 127.0.0.1
  28. couchdb couchdb/bindaddress seen true
  29. couchdb couchdb/cookie string $couchdb_magic_cookie
  30. couchdb couchdb/adminpass password $password_couchdb_admin
  31. couchdb couchdb/adminpass seen true
  32. couchdb couchdb/adminpass_again password $password_couchdb_admin
  33. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  34. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  35. ynh_install_extra_app_dependencies \
  36. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  37. --key="https://couchdb.apache.org/repo/keys.asc" \
  38. --package="couchdb"
  39. # stop couchdb
  40. systemctl stop couchdb
  41. # add couchdb configuration
  42. ynh_script_progression --message="Adding a configuration file..." --weight=2
  43. ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
  44. chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
  45. chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
  46. # restore couchdb directory
  47. ynh_script_progression --message="Restoring couchdb directory..." --weight=1
  48. ynh_restore_file --origin_path="/var/lib/couchdb"
  49. # start couchdb
  50. systemctl start couchdb
  51. systemctl status couchdb
  52. # RESTORE THE LOGROTATE CONFIGURATION
  53. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  54. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  55. # INTEGRATE SERVICE IN YUNOHOST
  56. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  57. yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log"
  58. # RELOAD NGINX
  59. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  60. ynh_systemd_action --service_name=nginx --action=reload
  61. ynh_script_progression --message="Restoration completed for $app" --last